Files
itgmania212121/stepmania/src/TransitionKeepAlive.cpp
T

118 lines
2.9 KiB
C++
Raw Normal View History

#include "stdafx.h"
/*
-----------------------------------------------------------------------------
2002-04-01 02:04:43 +00:00
Class: TransitionKeepAlive
2002-04-01 02:04:43 +00:00
Desc: See header.
2002-05-19 01:59:48 +00:00
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
2002-08-27 16:53:25 +00:00
Chris Danford
-----------------------------------------------------------------------------
*/
#include "TransitionKeepAlive.h"
2002-08-27 16:53:25 +00:00
#include "RageUtil.h"
2002-05-01 19:14:55 +00:00
#include "GameConstantsAndTypes.h"
2002-07-23 01:41:40 +00:00
#include "PrefsManager.h"
2002-08-27 16:53:25 +00:00
#include "RageMusic.h"
#define STOP_MUSIC_ON_NEXT THEME->GetMetricB("TransitionKeepAlive","StopMusicOnNext")
#define KEEP_ALIVE_TYPE THEME->GetMetricI("TransitionKeepAlive","KeepAliveType")
enum KeepAliveType // for use with the metric above
{
KEEP_ALIVE_TYPE_MAX = 0,
KEEP_ALIVE_TYPE_5TH,
};
KeepAliveType g_KeepAliveType; // hack: This is just a cache so we don't have to read the ThemeMetric on every update
2002-05-01 19:14:55 +00:00
const float KEEP_ALIVE_FORWARD_TRANSITION_TIME = 0.8f;
const float KEEP_ALIVE_BACKWARD_TRANSITION_TIME = 0.4f;
2002-04-01 02:04:43 +00:00
2002-08-27 16:53:25 +00:00
TransitionKeepAlive::TransitionKeepAlive()
{
2002-08-27 16:53:25 +00:00
g_KeepAliveType = (KeepAliveType)KEEP_ALIVE_TYPE;
m_sprLogo.Load( THEME->GetPathTo("Graphics","keep alive") );
m_sprLogo.SetXY( CENTER_X, CENTER_Y );
}
void TransitionKeepAlive::Update( float fDeltaTime )
{
// hack: Smooth out the big hickups.
fDeltaTime = min( fDeltaTime, 1/15.0f );
Transition::Update( fDeltaTime );
}
2002-05-19 01:59:48 +00:00
void TransitionKeepAlive::DrawPrimitives()
{
2002-05-28 20:01:22 +00:00
// draw keep alive graphic
2002-08-27 16:53:25 +00:00
switch( g_KeepAliveType )
{
case KEEP_ALIVE_TYPE_MAX:
{
float fPercentClosed = 1 - this->GetPercentageOpen();
fPercentClosed = min( 1, fPercentClosed*2 );
const float fPercentColor = fPercentClosed;
const float fPercentAlpha = min( fPercentClosed * 2, 1 );
m_sprLogo.SetDiffuse( RageColor(fPercentColor,fPercentColor,fPercentColor,fPercentAlpha) );
2002-08-27 16:53:25 +00:00
m_sprLogo.SetZoomY( fPercentClosed );
if( fPercentClosed > 0 )
m_sprLogo.Draw();
}
break;
case KEEP_ALIVE_TYPE_5TH:
{
float fPercentClosed = 1 - this->GetPercentageOpen();
m_sprLogo.SetDiffuse( RageColor(1,1,1,fPercentClosed) );
2002-08-27 16:53:25 +00:00
m_sprLogo.Draw();
}
break;
default:
ASSERT(0);
break;
}
2002-05-28 20:01:22 +00:00
2002-05-01 19:14:55 +00:00
}
2002-05-19 01:59:48 +00:00
void TransitionKeepAlive::OpenWipingRight( ScreenMessage send_when_done )
2002-05-01 19:14:55 +00:00
{
this->SetTransitionTime( KEEP_ALIVE_FORWARD_TRANSITION_TIME );
Transition::OpenWipingRight( send_when_done );
}
2002-05-19 01:59:48 +00:00
void TransitionKeepAlive::OpenWipingLeft( ScreenMessage send_when_done )
2002-05-01 19:14:55 +00:00
{
2002-08-27 16:53:25 +00:00
if( STOP_MUSIC_ON_NEXT )
MUSIC->Stop();
2002-05-01 19:14:55 +00:00
this->SetTransitionTime( KEEP_ALIVE_BACKWARD_TRANSITION_TIME );
Transition::OpenWipingLeft( send_when_done );
}
2002-05-19 01:59:48 +00:00
void TransitionKeepAlive::CloseWipingRight(ScreenMessage send_when_done )
2002-05-01 19:14:55 +00:00
{
this->SetTransitionTime( KEEP_ALIVE_FORWARD_TRANSITION_TIME );
Transition::CloseWipingRight( send_when_done );
}
2002-05-19 01:59:48 +00:00
void TransitionKeepAlive::CloseWipingLeft( ScreenMessage send_when_done )
2002-05-01 19:14:55 +00:00
{
this->SetTransitionTime( KEEP_ALIVE_BACKWARD_TRANSITION_TIME );
Transition::CloseWipingLeft( send_when_done );
}