set time cleanup

This commit is contained in:
Chris Danford
2004-04-18 21:32:36 +00:00
parent 795e39f239
commit 299ae15e6f
2 changed files with 79 additions and 28 deletions
+65 -25
View File
@@ -25,32 +25,56 @@
#include "Bookkeeper.h" #include "Bookkeeper.h"
#include "arch/ArchHooks/ArchHooks.h" #include "arch/ArchHooks/ArchHooks.h"
static const CString SetTimeSelectionNames[NUM_SET_TIME_SELECTIONS] = {
"Year",
"Month",
"Day",
"Hour",
"Minute",
"Second",
};
XToString( SetTimeSelection );
#define FOREACH_SetTimeSelection( s ) FOREACH_ENUM( SetTimeSelection, NUM_SET_TIME_SELECTIONS, s )
const int g_X[NUM_SET_TIME_SELECTIONS] =
{
320, 320, 320, 320, 320, 320
};
const int g_Y[NUM_SET_TIME_SELECTIONS] =
{
140, 180, 220, 260, 300, 340
};
static float GetTitleX( SetTimeSelection s ) { return g_X[s] - 80; }
static float GetTitleY( SetTimeSelection s ) { return g_Y[s]; }
static float GetValueX( SetTimeSelection s ) { return g_X[s] + 80; }
static float GetValueY( SetTimeSelection s ) { return g_Y[s]; }
ScreenSetTime::ScreenSetTime( CString sClassName ) : Screen( sClassName ) ScreenSetTime::ScreenSetTime( CString sClassName ) : Screen( sClassName )
{ {
LOG->Trace( "ScreenSetTime::ScreenSetTime()" ); LOG->Trace( "ScreenSetTime::ScreenSetTime()" );
m_Selection = hour; m_Selection = hour;
FOREACH_SetTimeSelection( s )
for( int i=0; i<NUM_SELECTIONS; i++ )
{ {
m_text[i].LoadFromFont( THEME->GetPathToF("Common title") ); BitmapText &title = m_textTitle[s];
m_text[i].SetDiffuse( RageColor(1,1,1,1) ); BitmapText &value = m_textValue[s];
this->AddChild( &m_text[i] );
switch( i ) title.LoadFromFont( THEME->GetPathToF("Common title") );
{ title.SetDiffuse( RageColor(1,1,1,1) );
case hour: m_text[i].SetXY( 220, 200 ); break; title.SetText( SetTimeSelectionToString(s) );
case minute: m_text[i].SetXY( 320, 200 ); break; title.SetXY( GetTitleX(s), GetTitleY(s) );
case second: m_text[i].SetXY( 420, 200 ); break; this->AddChild( &title );
case year: m_text[i].SetXY( 220, 280 ); break;
case month: m_text[i].SetXY( 320, 280 ); break; value.LoadFromFont( THEME->GetPathToF("Common normal") );
case day: m_text[i].SetXY( 420, 280 ); break; value.SetDiffuse( RageColor(1,1,1,1) );
default: ASSERT(0); value.SetXY( GetValueX(s), GetValueY(s) );
} this->AddChild( &value );
} }
m_Selection = (Selection)0; m_Selection = (SetTimeSelection)0;
ChangeSelection( 0 ); ChangeSelection( 0 );
m_Menu.Load( m_sName ); m_Menu.Load( m_sName );
@@ -64,12 +88,12 @@ void ScreenSetTime::Update( float fDelta )
Screen::Update( fDelta ); Screen::Update( fDelta );
tm now = GetLocalTime(); tm now = GetLocalTime();
m_text[hour].SetText( ssprintf("%02d",now.tm_hour) ); m_textValue[hour].SetText( ssprintf("%02d",now.tm_hour) );
m_text[minute].SetText( ssprintf("%02d",now.tm_min) ); m_textValue[minute].SetText( ssprintf("%02d",now.tm_min) );
m_text[second].SetText( ssprintf("%02d",now.tm_sec) ); m_textValue[second].SetText( ssprintf("%02d",now.tm_sec) );
m_text[year].SetText( ssprintf("%02d",now.tm_year+1900) ); m_textValue[year].SetText( ssprintf("%02d",now.tm_year+1900) );
m_text[month].SetText( ssprintf("%02d",now.tm_mon) ); m_textValue[month].SetText( ssprintf("%02d",now.tm_mon) );
m_text[day].SetText( ssprintf("%02d",now.tm_mday) ); m_textValue[day].SetText( ssprintf("%02d",now.tm_mday) );
} }
void ScreenSetTime::DrawPrimitives() void ScreenSetTime::DrawPrimitives()
@@ -116,18 +140,22 @@ void ScreenSetTime::ChangeValue( int iDirection )
} }
HOOKS->SetTime( now ); HOOKS->SetTime( now );
SOUND->PlayOnce( THEME->GetPathS("ScreenSetTime","ChangeValue") );
} }
void ScreenSetTime::ChangeSelection( int iDirection ) void ScreenSetTime::ChangeSelection( int iDirection )
{ {
// turn off old effect // turn off old effect
m_text[m_Selection].SetEffectNone(); m_textValue[m_Selection].SetEffectNone();
// set new value of m_Selection // set new value of m_Selection
((int&)m_Selection) += iDirection; ((int&)m_Selection) += iDirection;
CLAMP( (int&)m_Selection, 0, NUM_SELECTIONS-1 ); CLAMP( (int&)m_Selection, 0, NUM_SET_TIME_SELECTIONS-1 );
m_text[m_Selection].SetEffectDiffuseShift(); m_textValue[m_Selection].SetEffectDiffuseShift();
SOUND->PlayOnce( THEME->GetPathS("ScreenSetTime","ChangeSelection") );
} }
void ScreenSetTime::MenuUp( PlayerNumber pn ) void ScreenSetTime::MenuUp( PlayerNumber pn )
@@ -152,8 +180,20 @@ void ScreenSetTime::MenuRight( PlayerNumber pn )
void ScreenSetTime::MenuStart( PlayerNumber pn ) void ScreenSetTime::MenuStart( PlayerNumber pn )
{ {
bool bHoldingLeftAndRight =
INPUTMAPPER->IsButtonDown( MenuInput(pn, MENU_BUTTON_RIGHT) ) &&
INPUTMAPPER->IsButtonDown( MenuInput(pn, MENU_BUTTON_LEFT) );
if( bHoldingLeftAndRight )
ChangeSelection( -1 );
else if( m_Selection == NUM_SET_TIME_SELECTIONS -1 ) // last row
{
SOUND->PlayOnce( THEME->GetPathS("Common","start") );
m_Menu.StartTransitioning( SM_GoToNextScreen ); m_Menu.StartTransitioning( SM_GoToNextScreen );
} }
else
ChangeSelection( +1 );
}
void ScreenSetTime::MenuBack( PlayerNumber pn ) void ScreenSetTime::MenuBack( PlayerNumber pn )
{ {
+13 -2
View File
@@ -17,6 +17,16 @@
#include "MenuElements.h" #include "MenuElements.h"
#include "RageInputDevice.h" #include "RageInputDevice.h"
enum SetTimeSelection
{
year,
month,
day,
hour,
minute,
second,
NUM_SET_TIME_SELECTIONS
};
class ScreenSetTime : public Screen class ScreenSetTime : public Screen
{ {
@@ -36,11 +46,12 @@ public:
virtual void MenuBack( PlayerNumber pn ); virtual void MenuBack( PlayerNumber pn );
private: private:
enum Selection { hour, minute, second, year, month, day, NUM_SELECTIONS } m_Selection; SetTimeSelection m_Selection;
void ChangeSelection( int iDirection ); void ChangeSelection( int iDirection );
void ChangeValue( int iDirection ); void ChangeValue( int iDirection );
BitmapText m_text[NUM_SELECTIONS]; BitmapText m_textTitle[NUM_SET_TIME_SELECTIONS];
BitmapText m_textValue[NUM_SET_TIME_SELECTIONS];
BitmapText m_textDayOfWeek; BitmapText m_textDayOfWeek;
MenuElements m_Menu; MenuElements m_Menu;