diff --git a/stepmania/src/ScreenSetTime.cpp b/stepmania/src/ScreenSetTime.cpp index fc61555bdb..fe06ea2967 100644 --- a/stepmania/src/ScreenSetTime.cpp +++ b/stepmania/src/ScreenSetTime.cpp @@ -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; iGetPathToF("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 ) diff --git a/stepmania/src/ScreenSetTime.h b/stepmania/src/ScreenSetTime.h index 59ef9aeaac..5ca5f3073a 100644 --- a/stepmania/src/ScreenSetTime.h +++ b/stepmania/src/ScreenSetTime.h @@ -17,6 +17,16 @@ #include "MenuElements.h" #include "RageInputDevice.h" +enum SetTimeSelection +{ + year, + month, + day, + hour, + minute, + second, + NUM_SET_TIME_SELECTIONS +}; class ScreenSetTime : public Screen { @@ -36,11 +46,12 @@ public: virtual void MenuBack( PlayerNumber pn ); private: - enum Selection { hour, minute, second, year, month, day, NUM_SELECTIONS } m_Selection; + SetTimeSelection m_Selection; void ChangeSelection( 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; MenuElements m_Menu;