MenuTimer cleanup

This commit is contained in:
Chris Danford
2003-03-11 21:33:11 +00:00
parent 35bf217063
commit a11de99043
19 changed files with 134 additions and 127 deletions
+5 -27
View File
@@ -40,22 +40,6 @@ MenuElements::MenuElements()
{
}
void MenuElements::StealthTimer( int iActive )
{
m_MenuTimer.StealthTimer( iActive ); // go a bit deeper... get rid of the sound...
if (iActive == 0) // leave it on screen
{
// m_MenuTimer.SetXY( MENU_TIMER_X, MENU_TIMER_Y ); // set it on-screen
}
else if (iActive == 1) // hide the timer
{
// otherwise position it off-screen
m_MenuTimer.StopTweening();
m_MenuTimer.SetXY( 1000, 1000 );
}
}
void MenuElements::Load( CString sClassName, bool bEnableTimer, bool bLoadStyleIcon )
{
LOG->Trace( "MenuElements::MenuElements()" );
@@ -82,15 +66,9 @@ void MenuElements::Load( CString sClassName, bool bEnableTimer, bool bLoadStyleI
m_MenuTimer.Command( TIMER_ON_COMMAND );
if( bEnableTimer && PREFSMAN->m_bMenuTimer && !GAMESTATE->m_bEditing )
{
m_MenuTimer.SetTimer( THEME->GetMetricI(m_sClassName,"TimerSeconds") );
}
m_MenuTimer.SetSeconds( THEME->GetMetricI(m_sClassName,"TimerSeconds") );
else
{
m_MenuTimer.SetTimer( 99 );
m_MenuTimer.Update( 0 );
m_MenuTimer.StopTimer();
}
m_MenuTimer.Disable();
this->AddChild( &m_MenuTimer );
m_sprFooter.Load( THEME->GetPathTo("Graphics",m_sClassName+" footer") );
@@ -122,8 +100,8 @@ void MenuElements::Load( CString sClassName, bool bEnableTimer, bool bLoadStyleI
void MenuElements::StartTransitioning( ScreenMessage smSendWhenDone )
{
m_MenuTimer.SetTimer( 0 );
m_MenuTimer.StopTimer();
m_MenuTimer.SetSeconds( 0 );
m_MenuTimer.Stop();
m_sprHeader.Command( HEADER_OFF_COMMAND );
m_sprStyleIcon.Command( STYLE_ICON_OFF_COMMAND );
@@ -139,7 +117,7 @@ void MenuElements::Back( ScreenMessage smSendWhenDone )
if( m_Back.IsTransitioning() )
return; // ignore
m_MenuTimer.StopTimer();
m_MenuTimer.Stop();
m_Back.StartTransitioning( smSendWhenDone );
m_soundBack.Play();
}
-2
View File
@@ -36,8 +36,6 @@ public:
void Load( CString sClassName, bool bEnableTimer = true, bool bLoadStyleIcon = true );
void StealthTimer( int iActive );
void DrawTopLayer();
void DrawBottomLayer();
+92 -61
View File
@@ -25,7 +25,7 @@ MenuTimer::MenuTimer()
{
m_fSecondsLeft = TIMER_SECONDS;
m_fStallSeconds = 0;
m_bTimerStopped = false;
m_bPaused = false;
m_textDigit1.LoadFromNumbers( THEME->GetPathTo("Numbers","MenuTimer numbers") );
m_textDigit2.LoadFromNumbers( THEME->GetPathTo("Numbers","MenuTimer numbers") );
@@ -45,35 +45,31 @@ MenuTimer::MenuTimer()
m_soundBeep.Load( THEME->GetPathTo("Sounds","MenuTimer tick") );
}
void MenuTimer::StealthTimer( int iActive )
void MenuTimer::EnableStealth( bool bStealth )
{
if ( iActive == 0 ) // we wanna keep everything as it is...
{
m_soundBeep.Load( THEME->GetPathTo("Sounds","menu timer") ); // reload the sound
}
else if ( iActive == 1 ) // otherwise we wanna make the timer invisible and silent....
if( bStealth )
{
m_soundBeep.Unload(); // unload the sound
// HACK: this is not a good way to keep the numbers from drawing...
m_textDigit1.SetZoomY( 0 );
m_textDigit2.SetZoomY( 0 );
}
else
{
m_soundBeep.Load( THEME->GetPathTo("Sounds","MenuTimer tick") ); // reload the sound
m_textDigit1.SetZoomY( 1 );
m_textDigit2.SetZoomY( 1 );
}
// else take no action
}
void MenuTimer::Update( float fDeltaTime )
{
ActorFrame::Update( fDeltaTime );
if( m_bTimerStopped )
{
m_textDigit1.SetText( ssprintf("%d", ((int)m_fSecondsLeft)/10) );
m_textDigit2.SetText( ssprintf("%d", ((int)m_fSecondsLeft)%10) );
m_textDigit1.SetZoomX( 1 );
m_textDigit2.SetZoomX( 1 );
if( m_bPaused )
return;
}
// run down the stall time if any
if( m_fStallSeconds > 0 )
{
m_fStallSeconds -= fDeltaTime;
@@ -81,76 +77,111 @@ void MenuTimer::Update( float fDeltaTime )
}
float fOldSecondsLeft = m_fSecondsLeft;
float fNewSecondsLeft = fOldSecondsLeft - fDeltaTime;
m_fSecondsLeft -= fDeltaTime;
CLAMP( m_fSecondsLeft, 0, 99 );
float fNewSecondsLeft = m_fSecondsLeft;
int iOldDisplay = (int)(fOldSecondsLeft + 0.99f);
int iNewDisplay = (int)(fNewSecondsLeft + 0.99f);
if( fOldSecondsLeft > 5.5 && fNewSecondsLeft < 5.5 ) // transition to below 5.5
SOUNDMAN->PlayOnceFromDir( ANNOUNCER->GetPathTo("hurry up") );
else if( fOldSecondsLeft > 5 && fNewSecondsLeft < 5 ) // transition to below 5
if( iOldDisplay != iNewDisplay )
{
m_textDigit1.SetEffectGlowShift( 0.15f, RageColor(1,0,0,0), RageColor(1,0,0,1) );
m_textDigit2.SetEffectGlowShift( 0.15f, RageColor(1,0,0,0), RageColor(1,0,0,1) );
m_soundBeep.Play();
}
else if( fOldSecondsLeft > 4 && fNewSecondsLeft < 4 ) // transition to below 4
m_soundBeep.Play();
else if( fOldSecondsLeft > 3 && fNewSecondsLeft < 3 ) // transition to below 3
m_soundBeep.Play();
else if( fOldSecondsLeft > 2 && fNewSecondsLeft < 2 ) // transition to below 2
m_soundBeep.Play();
else if( fOldSecondsLeft > 1 && fNewSecondsLeft < 1 ) // transition to below 1
m_soundBeep.Play();
else if( fOldSecondsLeft > 0 && fNewSecondsLeft < 0 ) // transition to below 0
SCREENMAN->SendMessageToTopScreen( SM_MenuTimer, 0 );
SetText( iNewDisplay );
m_fSecondsLeft = fNewSecondsLeft;
m_fSecondsLeft = max( 0, m_fSecondsLeft );
switch( iNewDisplay )
{
case 6: // transition to below 6
m_textDigit1.StopTweening();
m_textDigit1.BeginTweening( 0.8f ); // sleep
m_textDigit1.BeginTweening( 0.2f );
m_textDigit1.SetTweenZoomX( 0 );
m_textDigit2.StopTweening();
m_textDigit2.BeginTweening( 0.8f ); // sleep
m_textDigit2.BeginTweening( 0.2f );
m_textDigit2.SetTweenZoomX( 0 );
break;
case 5: // transition to below 5
m_textDigit1.SetEffectGlowShift( 0.15f, RageColor(1,0,0,0), RageColor(1,0,0,1) );
m_textDigit2.SetEffectGlowShift( 0.15f, RageColor(1,0,0,0), RageColor(1,0,0,1) );
// fall through
case 4:
case 3:
case 2:
case 1:
m_textDigit1.StopTweening();
m_textDigit1.BeginTweening( 0.2f );
m_textDigit1.SetTweenZoomX( 1 );
m_textDigit1.BeginTweening( 0.6f ); // sleep
m_textDigit1.BeginTweening( 0.2f );
m_textDigit1.SetTweenZoomX( 0 );
m_textDigit2.StopTweening();
m_textDigit2.BeginTweening( 0.2f );
m_textDigit2.SetTweenZoomX( 1 );
m_textDigit2.BeginTweening( 0.6f ); // sleep
m_textDigit2.BeginTweening( 0.2f );
m_textDigit2.SetTweenZoomX( 0 );
m_textDigit1.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)/10) );
m_textDigit2.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)%10) );
// "flip" the numbers
float fRemainder = m_fSecondsLeft - (int)m_fSecondsLeft;
float fDistFromNearestNumber = min( fRemainder, 1-fRemainder ); // this is between 0 and 0.5;
if( m_fSecondsLeft == 0 )
{
m_textDigit1.SetZoomX( 1 );
m_textDigit2.SetZoomX( 1 );
}
else if( m_fSecondsLeft < 4.5f )
{
m_textDigit1.SetZoomX( min(1, fDistFromNearestNumber*8) );
m_textDigit2.SetZoomX( min(1, fDistFromNearestNumber*8) );
m_soundBeep.Play();
break;
case 0:
SCREENMAN->SendMessageToTopScreen( SM_MenuTimer, 0 );
Stop();
break;
}
}
}
void MenuTimer::StopTimer()
void MenuTimer::Pause()
{
SetTimer( 0 );
m_bTimerStopped = true;
m_bPaused = true;
}
void MenuTimer::StallTimer()
void MenuTimer::Stop()
{
SetSeconds( 0 );
Pause();
}
void MenuTimer::Disable()
{
SetSeconds( 99 );
Pause();
}
void MenuTimer::Stall()
{
m_fStallSeconds = 0.5f;
}
void MenuTimer::SetTimer( int iSeconds )
void MenuTimer::SetSeconds( int iSeconds )
{
m_fSecondsLeft = (float)iSeconds;
CLAMP( m_fSecondsLeft, 0, 99 );
m_textDigit1.StopTweening();
m_textDigit2.StopTweening();
m_textDigit1.SetZoomX( 1 );
m_textDigit2.SetZoomX( 1 );
m_textDigit1.SetEffectNone();
m_textDigit2.SetEffectNone();
m_textDigit1.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)/10) );
m_textDigit2.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)%10) );
SetText( iSeconds );
}
void MenuTimer::StartTimer()
void MenuTimer::Start()
{
m_bTimerStopped = false;
m_bPaused = false;
}
void MenuTimer::SetText( int iSeconds )
{
int iDigit1 = (int)(iSeconds)/10;
int iDigit2 = (int)(iSeconds)%10;
m_textDigit1.SetText( ssprintf("%d",iDigit1) );
m_textDigit2.SetText( ssprintf("%d",iDigit2) );
}
+9 -7
View File
@@ -25,18 +25,20 @@ public:
virtual void Update( float fDeltaTime );
void SetTimer( int iTimerSeconds );
void StartTimer();
void StopTimer();
void StallTimer();
void StealthTimer(int iActive);
void SetSeconds( int iTimerSeconds );
void Start(); // resume countdown from paused
void Pause(); // don't count down
void Stop(); // set to "00" and pause
void Disable(); // set to "99" and pause
void Stall(); // pause countdown for a sec
void EnableStealth( bool bStealth ); // make timer invisible and silent
protected:
float m_fSecondsLeft;
float m_fStallSeconds;
bool m_bPaused;
bool m_bTimerStopped;
void SetText( int iSeconds );
BitmapText m_textDigit1;
BitmapText m_textDigit2;
+1 -2
View File
@@ -72,8 +72,7 @@ ScreenAppearanceOptions::ScreenAppearanceOptions() :
g_AppearanceOptionsLines,
NUM_APPEARANCE_OPTIONS_LINES,
false );
m_Menu.m_MenuTimer.SetTimer( 99 );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenAppearanceOptions music") );
}
+2 -2
View File
@@ -290,7 +290,7 @@ void ScreenEz2SelectMusic::HandleScreenMessage( const ScreenMessage SM )
void ScreenEz2SelectMusic::MenuRight( PlayerNumber pn, const InputEventType type )
{
m_Menu.m_MenuTimer.StallTimer();
m_Menu.m_MenuTimer.Stall();
m_MusicBannerWheel.BannersRight();
MusicChanged();
}
@@ -317,7 +317,7 @@ void ScreenEz2SelectMusic::TweenOffScreen()
void ScreenEz2SelectMusic::MenuLeft( PlayerNumber pn, const InputEventType type )
{
m_Menu.m_MenuTimer.StallTimer();
m_Menu.m_MenuTimer.Stall();
m_MusicBannerWheel.BannersLeft();
MusicChanged();
}
+4 -5
View File
@@ -33,7 +33,7 @@ Andrew Livy
#define HELP_TEXT THEME->GetMetric("ScreenEz2SelectPlayer","HelpText")
#define TIMER_SECONDS THEME->GetMetricI("ScreenEz2SelectPlayer","TimerSeconds")
#define NEXT_SCREEN THEME->GetMetric("ScreenEz2SelectPlayer","NextScreen")
#define SILENT_WAIT THEME->GetMetricI("ScreenEz2SelectPlayer","SilentWait")
#define SILENT_WAIT THEME->GetMetricB("ScreenEz2SelectPlayer","SilentWait")
#define BOUNCE_JOIN_MESSAGE THEME->GetMetricB("ScreenEz2SelectPlayer","BounceJoinMessage")
#define FOLD_ON_JOIN THEME->GetMetricB("ScreenEz2SelectPlayer","FoldOnJoin")
@@ -161,7 +161,6 @@ void ScreenEz2SelectPlayer::HandleScreenMessage( const ScreenMessage SM )
if( GAMESTATE->GetNumSidesJoined() == 0 )
{
MenuStart(PLAYER_1);
m_Menu.m_MenuTimer.StopTimer();
}
TweenOffScreen();
@@ -238,9 +237,9 @@ void ScreenEz2SelectPlayer::MenuStart( PlayerNumber pn )
else
{
// give the other player a little time to join
m_Menu.m_MenuTimer.SetTimer( 1 );
m_Menu.m_MenuTimer.StartTimer();
m_Menu.m_MenuTimer.StealthTimer( SILENT_WAIT ); // do we wanna make the timer 'quiet' ?
m_Menu.m_MenuTimer.SetSeconds( 1 );
m_Menu.m_MenuTimer.Start();
m_Menu.m_MenuTimer.EnableStealth( SILENT_WAIT ); // do we wanna make the timer 'quiet' ?
}
}
+7 -4
View File
@@ -393,10 +393,6 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration )
}
m_textDebug.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_textDebug.SetXY( DEBUG_X, DEBUG_Y );
m_textDebug.SetDiffuse( RageColor(1,1,1,1) );
this->AddChild( &m_textDebug );
//this->AddChild( &m_textLyrics ); -- THIS IS NOT DONE YET!! (Miryokuteki)
@@ -456,6 +452,13 @@ ScreenGameplay::ScreenGameplay( bool bDemonstration )
}
// Debug is drawn on top of all these things
m_textDebug.LoadFromFont( THEME->GetPathTo("Fonts","normal") );
m_textDebug.SetXY( DEBUG_X, DEBUG_Y );
m_textDebug.SetDiffuse( RageColor(1,1,1,1) );
this->AddChild( &m_textDebug );
/* LoadNextSong first, since that positions some elements which need to be
* positioned before we TweenOnScreen. */
LoadNextSong();
+1 -1
View File
@@ -68,7 +68,7 @@ ScreenGameplayOptions::ScreenGameplayOptions() :
g_GameplayOptionsLines,
NUM_GAMEPLAY_OPTIONS_LINES,
false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenMachineOptions music") );
}
+1 -1
View File
@@ -76,7 +76,7 @@ ScreenGraphicOptions::ScreenGraphicOptions() :
g_GraphicOptionsLines,
NUM_GRAPHIC_OPTIONS_LINES,
false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenGraphicOptions music") );
}
+1 -1
View File
@@ -63,7 +63,7 @@ ScreenInputOptions::ScreenInputOptions() :
g_InputOptionsLines,
NUM_INPUT_OPTIONS_LINES,
false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenInputOptions music") );
}
+1 -1
View File
@@ -70,7 +70,7 @@ ScreenMachineOptions::ScreenMachineOptions() :
g_MachineOptionsLines,
NUM_MACHINE_OPTIONS_LINES,
false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenMachineOptions music") );
}
+2 -6
View File
@@ -231,13 +231,9 @@ ScreenNameEntry::ScreenNameEntry()
if( !PREFSMAN->m_bMenuTimer )
{
m_Timer.SetTimer( 99 );
m_Timer.Update( 0 );
m_Timer.StopTimer();
}
m_Timer.Disable();
else
m_Timer.SetTimer(TIMER_SECONDS);
m_Timer.SetSeconds(TIMER_SECONDS);
m_Timer.SetXY( TIMER_X, TIMER_Y );
this->AddChild( &m_Timer );
+1 -2
View File
@@ -67,8 +67,7 @@ ScreenOptionsMenu::ScreenOptionsMenu() :
g_OptionsMenuLines,
NUM_OPTIONS_MENU_LINES,
false );
m_Menu.m_MenuTimer.SetTimer( 99 );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenOptionsMenu music") );
}
+1
View File
@@ -145,6 +145,7 @@ void ScreenSelectDifficulty::HandleScreenMessage( const ScreenMessage SM )
case SM_BeginFadingOut:
TweenOffScreen();
SCREENMAN->SendMessageToTopScreen( SM_AllDoneChoosing, SLEEP_AFTER_TWEEN_OFF_SECONDS ); // nofify parent that we're finished
m_Menu.m_MenuTimer.Stop();
break;
}
}
+1 -1
View File
@@ -66,7 +66,7 @@ ScreenSelectGame::ScreenSelectGame() :
g_SelectGameLines,
NUM_SELECT_GAME_LINES,
false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenSelectGame music") );
}
+1
View File
@@ -255,6 +255,7 @@ void ScreenSelectGroup::MenuDown( PlayerNumber pn )
void ScreenSelectGroup::MenuStart( PlayerNumber pn )
{
m_soundSelect.PlayRandom();
m_Menu.m_MenuTimer.Stop();
m_bChosen = true;
GAMESTATE->m_pCurSong = NULL;
+3 -3
View File
@@ -610,12 +610,12 @@ void ScreenSelectMusic::HandleScreenMessage( const ScreenMessage SM )
if( m_MusicWheel.IsRouletting() )
{
MenuStart(PLAYER_INVALID);
m_Menu.m_MenuTimer.SetTimer( 15 );
m_Menu.m_MenuTimer.SetSeconds( 15 );
}
else if( m_MusicWheel.GetSelectedType() != TYPE_SONG )
{
m_MusicWheel.StartRoulette();
m_Menu.m_MenuTimer.SetTimer( 15 );
m_Menu.m_MenuTimer.SetSeconds( 15 );
}
else
{
@@ -811,7 +811,7 @@ void ScreenSelectMusic::AfterNotesChange( PlayerNumber pn )
void ScreenSelectMusic::AfterMusicChange()
{
m_Menu.m_MenuTimer.StallTimer();
m_Menu.m_MenuTimer.Stall();
Song* pSong = m_MusicWheel.GetSelectedSong();
GAMESTATE->m_pCurSong = pSong;
+1 -1
View File
@@ -47,7 +47,7 @@ ScreenSoundOptions::ScreenSoundOptions() :
}
Init( INPUTMODE_BOTH, g_SoundOptionsLines, NUM_SOUND_OPTIONS_LINES, false );
m_Menu.m_MenuTimer.StopTimer();
m_Menu.m_MenuTimer.Disable();
SOUNDMAN->PlayMusic( THEME->GetPathTo("Sounds","ScreenSoundOptions music") );
}