2002-05-27 08:23:27 +00:00
|
|
|
#include "stdafx.h"
|
|
|
|
|
/*
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
Class: MenuTimer
|
|
|
|
|
|
|
|
|
|
Desc: See header.
|
|
|
|
|
|
|
|
|
|
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
|
|
|
|
|
Chris Danford
|
|
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include "MenuTimer.h"
|
|
|
|
|
#include "RageUtil.h"
|
|
|
|
|
#include "GameConstantsAndTypes.h"
|
2002-07-23 01:41:40 +00:00
|
|
|
#include "PrefsManager.h"
|
2002-05-27 08:23:27 +00:00
|
|
|
#include "ScreenManager.h"
|
2002-07-11 19:02:26 +00:00
|
|
|
#include "AnnouncerManager.h"
|
2002-05-27 08:23:27 +00:00
|
|
|
|
2002-06-14 22:25:22 +00:00
|
|
|
const float TIMER_SECONDS = 99;
|
2002-05-27 08:23:27 +00:00
|
|
|
|
|
|
|
|
MenuTimer::MenuTimer()
|
|
|
|
|
{
|
|
|
|
|
m_fSecondsLeft = TIMER_SECONDS;
|
2002-07-11 19:02:26 +00:00
|
|
|
m_fStallSeconds = 0;
|
|
|
|
|
m_bTimerStopped = false;
|
2002-05-27 08:23:27 +00:00
|
|
|
|
2002-09-22 18:18:50 +00:00
|
|
|
m_textDigit1.LoadFromNumbers( THEME->GetPathTo("Numbers","menu timer numbers") );
|
|
|
|
|
m_textDigit2.LoadFromNumbers( THEME->GetPathTo("Numbers","menu timer numbers") );
|
2002-09-29 05:06:18 +00:00
|
|
|
|
|
|
|
|
m_textDigit1.TurnShadowOff();
|
2002-05-27 08:23:27 +00:00
|
|
|
m_textDigit2.TurnShadowOff();
|
2002-09-29 05:06:18 +00:00
|
|
|
|
|
|
|
|
float fCharWidth = (float)m_textDigit1.m_pFont->m_pTexture->GetSourceFrameWidth();
|
|
|
|
|
|
|
|
|
|
m_textDigit1.SetXY( -fCharWidth/2, 0 );
|
|
|
|
|
m_textDigit2.SetXY( +fCharWidth/2, 0 );
|
|
|
|
|
|
|
|
|
|
this->AddChild( &m_textDigit1 );
|
2002-09-02 21:59:58 +00:00
|
|
|
this->AddChild( &m_textDigit2 );
|
2002-05-28 20:01:22 +00:00
|
|
|
|
2002-08-13 23:26:46 +00:00
|
|
|
m_soundBeep.Load( THEME->GetPathTo("Sounds","menu timer") );
|
2002-05-27 08:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
2002-09-13 18:06:36 +00:00
|
|
|
void MenuTimer::StealthTimer( int iActive )
|
|
|
|
|
{
|
|
|
|
|
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....
|
|
|
|
|
{
|
|
|
|
|
m_soundBeep.Unload(); // unload the sound
|
|
|
|
|
}
|
|
|
|
|
// else take no action
|
|
|
|
|
}
|
2002-05-27 08:23:27 +00:00
|
|
|
|
|
|
|
|
void MenuTimer::Update( float fDeltaTime )
|
|
|
|
|
{
|
|
|
|
|
ActorFrame::Update( fDeltaTime );
|
|
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
if( m_bTimerStopped )
|
2002-07-27 19:29:51 +00:00
|
|
|
{
|
|
|
|
|
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 );
|
|
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
return;
|
2002-07-27 19:29:51 +00:00
|
|
|
}
|
|
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
|
|
|
|
|
if( m_fStallSeconds > 0 )
|
|
|
|
|
{
|
|
|
|
|
m_fStallSeconds -= fDeltaTime;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2002-05-27 08:23:27 +00:00
|
|
|
float fOldSecondsLeft = m_fSecondsLeft;
|
|
|
|
|
float fNewSecondsLeft = fOldSecondsLeft - fDeltaTime;
|
|
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
if( fOldSecondsLeft > 5.5 && fNewSecondsLeft < 5.5 ) // transition to below 5.5
|
2002-08-27 23:31:41 +00:00
|
|
|
SOUND->PlayOnceStreamedFromDir( ANNOUNCER->GetPathTo("hurry up") );
|
2002-07-11 19:02:26 +00:00
|
|
|
else if( fOldSecondsLeft > 5 && fNewSecondsLeft < 5 ) // transition to below 5
|
2002-05-27 08:23:27 +00:00
|
|
|
{
|
|
|
|
|
m_textDigit1.SetEffectGlowing( 10, D3DXCOLOR(1,0,0,0), D3DXCOLOR(1,0,0,1) );
|
|
|
|
|
m_textDigit2.SetEffectGlowing( 10, D3DXCOLOR(1,0,0,0), D3DXCOLOR(1,0,0,1) );
|
2002-05-28 20:01:22 +00:00
|
|
|
m_soundBeep.Play();
|
2002-05-27 08:23:27 +00:00
|
|
|
}
|
2002-05-28 20:01:22 +00:00
|
|
|
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();
|
2002-05-27 08:23:27 +00:00
|
|
|
else if( fOldSecondsLeft > 0 && fNewSecondsLeft < 0 ) // transition to below 0
|
|
|
|
|
SCREENMAN->SendMessageToTopScreen( SM_MenuTimer, 0 );
|
|
|
|
|
|
|
|
|
|
m_fSecondsLeft = fNewSecondsLeft;
|
|
|
|
|
m_fSecondsLeft = max( 0, m_fSecondsLeft );
|
|
|
|
|
|
2002-05-28 20:01:22 +00:00
|
|
|
m_textDigit1.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)/10) );
|
|
|
|
|
m_textDigit2.SetText( ssprintf("%d", ((int)m_fSecondsLeft+1)%10) );
|
2002-05-27 08:23:27 +00:00
|
|
|
|
|
|
|
|
// "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 < 4.5f )
|
|
|
|
|
{
|
|
|
|
|
m_textDigit1.SetZoomX( min(1, fDistFromNearestNumber*8) );
|
|
|
|
|
m_textDigit2.SetZoomX( min(1, fDistFromNearestNumber*8) );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void MenuTimer::StopTimer()
|
|
|
|
|
{
|
2002-07-11 19:02:26 +00:00
|
|
|
m_bTimerStopped = true;
|
2002-05-27 08:23:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MenuTimer::StallTimer()
|
|
|
|
|
{
|
2002-08-20 21:00:56 +00:00
|
|
|
m_fStallSeconds = 0.5f;
|
2002-07-11 19:02:26 +00:00
|
|
|
}
|
2002-05-27 08:23:27 +00:00
|
|
|
|
2002-07-11 19:02:26 +00:00
|
|
|
void MenuTimer::SetTimer( int iSeconds )
|
|
|
|
|
{
|
|
|
|
|
m_fSecondsLeft = (float)iSeconds;
|
2002-07-27 19:29:51 +00:00
|
|
|
CLAMP( m_fSecondsLeft, 0, 99 );
|
2002-08-20 21:00:56 +00:00
|
|
|
|
|
|
|
|
m_textDigit1.SetZoomX( 1 );
|
|
|
|
|
m_textDigit2.SetZoomX( 1 );
|
|
|
|
|
m_textDigit1.SetEffectNone();
|
|
|
|
|
m_textDigit2.SetEffectNone();
|
2002-05-27 08:23:27 +00:00
|
|
|
}
|
2002-08-27 23:31:41 +00:00
|
|
|
|
|
|
|
|
void MenuTimer::StartTimer()
|
|
|
|
|
{
|
|
|
|
|
m_bTimerStopped = false;
|
|
|
|
|
}
|