set time cleanup
This commit is contained in:
@@ -25,32 +25,56 @@
|
||||
#include "Bookkeeper.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 )
|
||||
{
|
||||
LOG->Trace( "ScreenSetTime::ScreenSetTime()" );
|
||||
|
||||
m_Selection = hour;
|
||||
|
||||
|
||||
for( int i=0; i<NUM_SELECTIONS; i++ )
|
||||
FOREACH_SetTimeSelection( s )
|
||||
{
|
||||
m_text[i].LoadFromFont( THEME->GetPathToF("Common title") );
|
||||
m_text[i].SetDiffuse( RageColor(1,1,1,1) );
|
||||
this->AddChild( &m_text[i] );
|
||||
BitmapText &title = m_textTitle[s];
|
||||
BitmapText &value = m_textValue[s];
|
||||
|
||||
switch( i )
|
||||
{
|
||||
case hour: m_text[i].SetXY( 220, 200 ); break;
|
||||
case minute: m_text[i].SetXY( 320, 200 ); break;
|
||||
case second: m_text[i].SetXY( 420, 200 ); break;
|
||||
case year: m_text[i].SetXY( 220, 280 ); break;
|
||||
case month: m_text[i].SetXY( 320, 280 ); break;
|
||||
case day: m_text[i].SetXY( 420, 280 ); break;
|
||||
default: ASSERT(0);
|
||||
}
|
||||
title.LoadFromFont( THEME->GetPathToF("Common title") );
|
||||
title.SetDiffuse( RageColor(1,1,1,1) );
|
||||
title.SetText( SetTimeSelectionToString(s) );
|
||||
title.SetXY( GetTitleX(s), GetTitleY(s) );
|
||||
this->AddChild( &title );
|
||||
|
||||
value.LoadFromFont( THEME->GetPathToF("Common normal") );
|
||||
value.SetDiffuse( RageColor(1,1,1,1) );
|
||||
value.SetXY( GetValueX(s), GetValueY(s) );
|
||||
this->AddChild( &value );
|
||||
}
|
||||
|
||||
m_Selection = (Selection)0;
|
||||
m_Selection = (SetTimeSelection)0;
|
||||
ChangeSelection( 0 );
|
||||
|
||||
m_Menu.Load( m_sName );
|
||||
@@ -64,12 +88,12 @@ void ScreenSetTime::Update( float fDelta )
|
||||
Screen::Update( fDelta );
|
||||
|
||||
tm now = GetLocalTime();
|
||||
m_text[hour].SetText( ssprintf("%02d",now.tm_hour) );
|
||||
m_text[minute].SetText( ssprintf("%02d",now.tm_min) );
|
||||
m_text[second].SetText( ssprintf("%02d",now.tm_sec) );
|
||||
m_text[year].SetText( ssprintf("%02d",now.tm_year+1900) );
|
||||
m_text[month].SetText( ssprintf("%02d",now.tm_mon) );
|
||||
m_text[day].SetText( ssprintf("%02d",now.tm_mday) );
|
||||
m_textValue[hour].SetText( ssprintf("%02d",now.tm_hour) );
|
||||
m_textValue[minute].SetText( ssprintf("%02d",now.tm_min) );
|
||||
m_textValue[second].SetText( ssprintf("%02d",now.tm_sec) );
|
||||
m_textValue[year].SetText( ssprintf("%02d",now.tm_year+1900) );
|
||||
m_textValue[month].SetText( ssprintf("%02d",now.tm_mon) );
|
||||
m_textValue[day].SetText( ssprintf("%02d",now.tm_mday) );
|
||||
}
|
||||
|
||||
void ScreenSetTime::DrawPrimitives()
|
||||
@@ -116,18 +140,22 @@ void ScreenSetTime::ChangeValue( int iDirection )
|
||||
}
|
||||
|
||||
HOOKS->SetTime( now );
|
||||
|
||||
SOUND->PlayOnce( THEME->GetPathS("ScreenSetTime","ChangeValue") );
|
||||
}
|
||||
|
||||
void ScreenSetTime::ChangeSelection( int iDirection )
|
||||
{
|
||||
// turn off old effect
|
||||
m_text[m_Selection].SetEffectNone();
|
||||
m_textValue[m_Selection].SetEffectNone();
|
||||
|
||||
// set new value of m_Selection
|
||||
((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 )
|
||||
@@ -152,7 +180,19 @@ void ScreenSetTime::MenuRight( PlayerNumber pn )
|
||||
|
||||
void ScreenSetTime::MenuStart( PlayerNumber pn )
|
||||
{
|
||||
m_Menu.StartTransitioning( SM_GoToNextScreen );
|
||||
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 );
|
||||
}
|
||||
else
|
||||
ChangeSelection( +1 );
|
||||
}
|
||||
|
||||
void ScreenSetTime::MenuBack( PlayerNumber pn )
|
||||
|
||||
Reference in New Issue
Block a user