From b6bc1bf8ec18f612b701b841196212e893e87611 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 14 Mar 2004 06:39:39 +0000 Subject: [PATCH] add ScreenSetTime --- stepmania/Themes/default/metrics.ini | 13 +- stepmania/src/Makefile.am | 1 + stepmania/src/Screen.cpp | 2 + stepmania/src/ScreenSetTime.cpp | 162 ++++++++++++++++++ stepmania/src/ScreenSetTime.h | 48 ++++++ stepmania/src/StepMania.dsp | 23 ++- stepmania/src/StepMania.vcproj | 6 + stepmania/src/arch/ArchHooks/ArchHooks.h | 2 + .../src/arch/ArchHooks/ArchHooks_Win32.cpp | 14 ++ .../src/arch/ArchHooks/ArchHooks_Win32.h | 1 + 10 files changed, 267 insertions(+), 5 deletions(-) create mode 100644 stepmania/src/ScreenSetTime.cpp create mode 100644 stepmania/src/ScreenSetTime.h diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 920201240c..fdc394f49f 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3788,7 +3788,7 @@ PrevScreen=ScreenTitleMenu # when using entries that change the screen; otherwise, the only way to # exit the screen when in arcade mode is "exit". -LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16 +LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17 OptionMenuFlags=together;forceallplayers;smnavigation # This NextScreen is only used for the "exit" choice. Line1=list,Appearance Options @@ -3807,6 +3807,7 @@ Line13=list,Profile Options Line14=list,Other Options Line15=list,Reload Songs/Courses Line16=list,Test Input +Line17=list,Set Machine Time [TextBanner] TitleX=-90 @@ -4234,7 +4235,7 @@ Background OptionsDefault= Background Options,1=screen,ScreenBackgroundOptions;name,BackgroundOptions Bookkeeping=1,together BookkeepingDefault= -Bookkeeping,1=screen,ScreenBookkeeping;name,Bookkeeping +Bookkeeping,1=screen,ScreenSetTime;name,Bookkeeping Center Image=1,together Center ImageDefault= Center Image,1=screen,ScreenCenterImage;name,CenterImage @@ -4271,6 +4272,9 @@ Reload Songs/Courses,1=screen,ScreenReloadSongs;name,ReloadSongs Test Input=1,together Test InputDefault= Test Input,1=screen,ScreenTestInput;name,TestInput +Set Machine Time=1,together +Set Machine TimeDefault= +Set Machine Time,1=screen,ScreenSetTime;name,SetMachineTime [DancingCharacters] #2D Character X/Y positions in relation to the center @@ -4321,4 +4325,7 @@ EmptyName=STEP [ScreenDownloadMachineStats] NextScreen=ScreenOptionsMenu - +[ScreenSetTime] +StyleIcon=0 +MemoryCardIcons=0 +TimerSeconds=0 diff --git a/stepmania/src/Makefile.am b/stepmania/src/Makefile.am index 543627e327..9f43af7bf1 100644 --- a/stepmania/src/Makefile.am +++ b/stepmania/src/Makefile.am @@ -54,6 +54,7 @@ ScreenSelectCharacter.cpp ScreenSelectCharacter.h ScreenSelectCourse.cpp ScreenS ScreenSelectDifficulty.cpp ScreenSelectDifficulty.h ScreenSelectDifficultyEX.cpp ScreenSelectDifficultyEX.h \ ScreenSelectGroup.cpp ScreenSelectGroup.h ScreenSelectMaster.cpp ScreenSelectMaster.h \ ScreenSelectMode.cpp ScreenSelectMode.h ScreenSelectMusic.cpp ScreenSelectMusic.h ScreenSelectStyle.cpp ScreenSelectStyle.h \ +ScreenSetTime.cpp ScreenSetTime.h \ ScreenSongOptions.cpp ScreenSongOptions.h ScreenStage.cpp ScreenStage.h \ ScreenStyleSplash.cpp ScreenStyleSplash.h ScreenTest.cpp ScreenTest.h ScreenTestFonts.cpp ScreenTestFonts.h \ ScreenTestInput.h ScreenTestInput.cpp ScreenTestSound.cpp ScreenTestSound.h ScreenTextEntry.cpp ScreenTextEntry.h ScreenTitleMenu.cpp ScreenTitleMenu.h \ diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index d23e34d2e8..8557d4dc72 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -293,6 +293,7 @@ void Screen::ClearMessageQueue( const ScreenMessage SM ) #include "ScreenEnding.h" #include "ScreenAward.h" #include "ScreenDownloadMachineStats.h" +#include "ScreenSetTime.h" Screen* Screen::Create( CString sClassName ) { @@ -357,6 +358,7 @@ Screen* Screen::Create( CString sClassName ) IF_RETURN( ScreenEnding ); IF_RETURN( ScreenAward ); IF_RETURN( ScreenDownloadMachineStats ); + IF_RETURN( ScreenSetTime ); RageException::Throw( "Invalid Screen class name '%s'", sClassName.c_str() ); } diff --git a/stepmania/src/ScreenSetTime.cpp b/stepmania/src/ScreenSetTime.cpp new file mode 100644 index 0000000000..fc61555bdb --- /dev/null +++ b/stepmania/src/ScreenSetTime.cpp @@ -0,0 +1,162 @@ +#include "global.h" +/* +----------------------------------------------------------------------------- + Class: ScreenSetTime + + Desc: Where the player maps device input to pad input. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "ScreenSetTime.h" +#include "PrefsManager.h" +#include "ScreenManager.h" +#include "GameConstantsAndTypes.h" +#include "PrefsManager.h" +#include "RageLog.h" +#include "InputMapper.h" +#include "GameManager.h" +#include "GameState.h" +#include "RageSounds.h" +#include "ThemeManager.h" +#include "RageDisplay.h" +#include "Bookkeeper.h" +#include "arch/ArchHooks/ArchHooks.h" + +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] ); + + 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); + } + } + + m_Selection = (Selection)0; + ChangeSelection( 0 ); + + m_Menu.Load( m_sName ); + this->AddChild( &m_Menu ); + + SOUND->PlayMusic( THEME->GetPathS(m_sName,"music") ); +} + +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) ); +} + +void ScreenSetTime::DrawPrimitives() +{ + m_Menu.DrawBottomLayer(); + Screen::DrawPrimitives(); + m_Menu.DrawTopLayer(); +} + +void ScreenSetTime::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ + if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT ) + return; // ignore + + if( m_Menu.IsTransitioning() ) + return; + + Screen::Input( DeviceI, type, GameI, MenuI, StyleI ); // default handler +} + +void ScreenSetTime::HandleScreenMessage( const ScreenMessage SM ) +{ + switch( SM ) + { + case SM_GoToNextScreen: + case SM_GoToPrevScreen: + SCREENMAN->SetNewScreen( "ScreenOptionsMenu" ); + break; + } +} + +void ScreenSetTime::ChangeValue( int iDirection ) +{ + tm now = GetLocalTime(); + switch( m_Selection ) + { + case hour: now.tm_hour += iDirection; break; + case minute: now.tm_min += iDirection; break; + case second: now.tm_sec += iDirection; break; + case year: now.tm_year += iDirection; break; + case month: now.tm_mon += iDirection; break; + case day: now.tm_mday += iDirection; break; + default: ASSERT(0); + } + + HOOKS->SetTime( now ); +} + +void ScreenSetTime::ChangeSelection( int iDirection ) +{ + // turn off old effect + m_text[m_Selection].SetEffectNone(); + + // set new value of m_Selection + ((int&)m_Selection) += iDirection; + CLAMP( (int&)m_Selection, 0, NUM_SELECTIONS-1 ); + + m_text[m_Selection].SetEffectDiffuseShift(); +} + +void ScreenSetTime::MenuUp( PlayerNumber pn ) +{ + ChangeSelection( -1 ); +} + +void ScreenSetTime::MenuDown( PlayerNumber pn ) +{ + ChangeSelection( +1 ); +} + +void ScreenSetTime::MenuLeft( PlayerNumber pn ) +{ + ChangeValue( -1 ); +} + +void ScreenSetTime::MenuRight( PlayerNumber pn ) +{ + ChangeValue( +1 ); +} + +void ScreenSetTime::MenuStart( PlayerNumber pn ) +{ + m_Menu.StartTransitioning( SM_GoToNextScreen ); +} + +void ScreenSetTime::MenuBack( PlayerNumber pn ) +{ + m_Menu.StartTransitioning( SM_GoToPrevScreen ); +} + diff --git a/stepmania/src/ScreenSetTime.h b/stepmania/src/ScreenSetTime.h new file mode 100644 index 0000000000..59ef9aeaac --- /dev/null +++ b/stepmania/src/ScreenSetTime.h @@ -0,0 +1,48 @@ +/* +----------------------------------------------------------------------------- + Class: ScreenSetTime + + Desc: Show coin drop stats. + + Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford +----------------------------------------------------------------------------- +*/ + +#include "Screen.h" +#include "Sprite.h" +#include "BitmapText.h" +#include "PrefsManager.h" +#include "InputMapper.h" +#include "MenuElements.h" +#include "RageInputDevice.h" + + +class ScreenSetTime : public Screen +{ +public: + ScreenSetTime( CString sName ); + + virtual void Update( float fDelta ); + virtual void DrawPrimitives(); + virtual void Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); + virtual void HandleScreenMessage( const ScreenMessage SM ); + + virtual void MenuUp( PlayerNumber pn ); + virtual void MenuDown( PlayerNumber pn ); + virtual void MenuLeft( PlayerNumber pn ); + virtual void MenuRight( PlayerNumber pn ); + virtual void MenuStart( PlayerNumber pn ); + virtual void MenuBack( PlayerNumber pn ); + +private: + enum Selection { hour, minute, second, year, month, day, NUM_SELECTIONS } m_Selection; + void ChangeSelection( int iDirection ); + void ChangeValue( int iDirection ); + + BitmapText m_text[NUM_SELECTIONS]; + BitmapText m_textDayOfWeek; + + MenuElements m_Menu; +}; + diff --git a/stepmania/src/StepMania.dsp b/stepmania/src/StepMania.dsp index 4e1bccade9..e49cd5dd33 100644 --- a/stepmania/src/StepMania.dsp +++ b/stepmania/src/StepMania.dsp @@ -65,7 +65,7 @@ IntDir=.\../Debug6 TargetDir=\stepmania\stepmania\Program TargetName=StepMania-debug SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -142,7 +142,7 @@ IntDir=.\../Release6 TargetDir=\stepmania\stepmania\Program TargetName=StepMania SOURCE="$(InputPath)" -PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ +PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\ PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi # End Special Build Tool @@ -5663,6 +5663,25 @@ SOURCE=.\ScreenSelectStyle.h # End Source File # Begin Source File +SOURCE=.\ScreenSetTime.cpp + +!IF "$(CFG)" == "StepMania - Win32 Debug" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Debug" + +!ELSEIF "$(CFG)" == "StepMania - Win32 Release" + +!ELSEIF "$(CFG)" == "StepMania - Xbox Release" + +!ENDIF + +# End Source File +# Begin Source File + +SOURCE=.\ScreenSetTime.h +# End Source File +# Begin Source File + SOURCE=.\ScreenSongOptions.cpp !IF "$(CFG)" == "StepMania - Win32 Debug" diff --git a/stepmania/src/StepMania.vcproj b/stepmania/src/StepMania.vcproj index 1c711ad965..9c3f4033f4 100644 --- a/stepmania/src/StepMania.vcproj +++ b/stepmania/src/StepMania.vcproj @@ -472,6 +472,12 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\ + + + + diff --git a/stepmania/src/arch/ArchHooks/ArchHooks.h b/stepmania/src/arch/ArchHooks/ArchHooks.h index e13cc2460b..7f1f98a0ed 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks.h @@ -48,6 +48,8 @@ public: virtual void EnterTimeCriticalSection() { } virtual void ExitTimeCriticalSection() { } + virtual void SetTime( tm newtime ) { } + protected: virtual void MessageBoxErrorPrivate( CString sMessage, CString ID ) { printf("Error: %s\n", sMessage.c_str()); } virtual void MessageBoxOKPrivate( CString sMessage, CString ID ) {} diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp index 6e8e4eeb67..55fedbaf69 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.cpp @@ -202,6 +202,20 @@ void ArchHooks_Win32::ExitTimeCriticalSection() TimeCritMutex->Unlock(); } +void ArchHooks_Win32::SetTime( tm newtime ) +{ + SYSTEMTIME st; + ZERO( st ); + st.wYear = newtime.tm_year+1900; + st.wMonth = newtime.tm_mon+1; + st.wDay = newtime.tm_mday; + st.wHour = newtime.tm_hour; + st.wMinute = newtime.tm_min; + st.wSecond = newtime.tm_sec; + st.wMilliseconds = 0; + BOOL b = SetLocalTime( &st ); + DWORD dw = GetLastError(); +} /* * Copyright (c) 2002-2004 by the person(s) listed below. All rights reserved. diff --git a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h index 9fa927b4a1..42d53f9cd3 100644 --- a/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h +++ b/stepmania/src/arch/ArchHooks/ArchHooks_Win32.h @@ -20,6 +20,7 @@ public: RageMutex *TimeCritMutex; void EnterTimeCriticalSection(); void ExitTimeCriticalSection(); + void SetTime( tm newtime ); }; #undef ARCH_HOOKS