From 3f315b0464a7ff850b105bd6625068577227d5d0 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sat, 30 Sep 2006 08:24:05 +0000 Subject: [PATCH] InputScheme --- stepmania/src/CodeDetector.cpp | 3 +-- stepmania/src/GameInput.cpp | 24 +++++++++---------- stepmania/src/GameInput.h | 12 +++++----- stepmania/src/ScreenMapControllers.cpp | 6 ++--- stepmania/src/ScreenTestInput.cpp | 2 +- stepmania/src/ScreenTestLights.cpp | 2 +- .../Lights/LightsDriver_SystemMessage.cpp | 5 ++-- 7 files changed, 26 insertions(+), 28 deletions(-) diff --git a/stepmania/src/CodeDetector.cpp b/stepmania/src/CodeDetector.cpp index 960de10a8c..28fcfc10ba 100644 --- a/stepmania/src/CodeDetector.cpp +++ b/stepmania/src/CodeDetector.cpp @@ -97,7 +97,6 @@ bool CodeItem::Load( RString sButtonsNames ) { buttons.clear(); - const Game* pGame = GAMESTATE->GetCurrentGame(); vector asButtonNames; bool bHasAPlus = sButtonsNames.find( '+' ) != string::npos; @@ -131,7 +130,7 @@ bool CodeItem::Load( RString sButtonsNames ) const RString sButtonName = asButtonNames[i]; // Search for the corresponding GameButton - const GameButton gb = pGame->ButtonNameToIndex( sButtonName ); + const GameButton gb = INPUTMAPPER->GetInputScheme()->ButtonNameToIndex( sButtonName ); if( gb == GameButton_Invalid ) { LOG->Trace( "The code '%s' contains an unrecognized button '%s'.", sButtonsNames.c_str(), sButtonName.c_str() ); diff --git a/stepmania/src/GameInput.cpp b/stepmania/src/GameInput.cpp index 9b348a090d..739cf6f3f5 100644 --- a/stepmania/src/GameInput.cpp +++ b/stepmania/src/GameInput.cpp @@ -2,7 +2,7 @@ #include "GameInput.h" #include "RageLog.h" #include "RageUtil.h" -#include "Game.h" +#include "InputMapper.h" #include "ThemeManager.h" @@ -14,33 +14,33 @@ XToString( GameController, NUM_GameController ); StringToX( GameController ); -RString GameButtonToString( const Game* pGame, GameButton i ) +RString GameButtonToString( const InputScheme* pInputs, GameButton i ) { - return pGame->m_szButtonNames[i]; + return pInputs->m_szButtonNames[i]; } -RString GameButtonToLocalizedString( const Game* pGame, GameButton i ) +RString GameButtonToLocalizedString( const InputScheme* pInputs, GameButton i ) { - return THEME->GetString( "GameButton", GameButtonToString(pGame,i) ); + return THEME->GetString( "GameButton", GameButtonToString(pInputs,i) ); } -GameButton StringToGameButton( const Game* pGame, const RString& s ) +GameButton StringToGameButton( const InputScheme* pInputs, const RString& s ) { - for( int i=0; im_iButtonsPerController; i++ ) + for( int i=0; im_iButtonsPerController; i++ ) { - if( s == GameButtonToString(pGame,(GameButton)i) ) + if( s == GameButtonToString(pInputs,(GameButton)i) ) return (GameButton)i; } return GameButton_Invalid; } -RString GameInput::ToString( const Game* pGame ) const +RString GameInput::ToString( const InputScheme* pInputs ) const { - return GameControllerToString(controller) + RString("_") + GameButtonToString(pGame,button); + return GameControllerToString(controller) + RString("_") + GameButtonToString(pInputs,button); } -bool GameInput::FromString( const Game* pGame, const RString &s ) +bool GameInput::FromString( const InputScheme* pInputs, const RString &s ) { char szController[32] = ""; char szButton[32] = ""; @@ -52,7 +52,7 @@ bool GameInput::FromString( const Game* pGame, const RString &s ) } controller = StringToGameController( szController ); - button = StringToGameButton( pGame, szButton ); + button = StringToGameButton( pInputs, szButton ); return true; }; diff --git a/stepmania/src/GameInput.h b/stepmania/src/GameInput.h index fa379bf2a4..4c9841c6e2 100644 --- a/stepmania/src/GameInput.h +++ b/stepmania/src/GameInput.h @@ -5,7 +5,7 @@ #include "EnumHelper.h" -class Game; +class InputScheme; enum GameController { @@ -17,9 +17,9 @@ enum GameController #define FOREACH_GameController( gc ) FOREACH_ENUM2( GameController, gc ) typedef int GameButton; -RString GameButtonToString( const Game* pGame, GameButton i ); -RString GameButtonToLocalizedString( const Game* pGame, GameButton i ); -GameButton StringToGameButton( const Game* pGame, const RString& s ); +RString GameButtonToString( const InputScheme* pInputs, GameButton i ); +RString GameButtonToLocalizedString( const InputScheme* pInputs, GameButton i ); +GameButton StringToGameButton( const InputScheme* pInputs, const RString& s ); const GameButton NUM_GameButton = 20; const GameButton GameButton_Invalid = NUM_GameButton+1; @@ -260,8 +260,8 @@ struct GameInput inline bool IsValid() const { return controller != GameController_Invalid; }; inline void MakeInvalid() { controller = GameController_Invalid; button = GameButton_Invalid; }; - RString ToString( const Game* pGame ) const; - bool FromString( const Game* pGame, const RString &s ); + RString ToString( const InputScheme* pInputs ) const; + bool FromString( const InputScheme* pInputs, const RString &s ); }; #endif diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index 2adc17a202..526e7cad3c 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -48,7 +48,7 @@ void ScreenMapControllers::Init() if( sButtons.empty() ) { /* Map all buttons for this game. */ - for( int b=0; bGetCurrentGame()->m_iButtonsPerController; b++ ) + for( int b=0; bGetInputScheme()->m_iButtonsPerController; b++ ) { KeyToMap k; k.m_GameButton = (GameButton) b; @@ -63,7 +63,7 @@ void ScreenMapControllers::Init() for( unsigned i=0; iGetCurrentGame(), asBits[i] ); + k.m_GameButton = StringToGameButton( INPUTMAPPER->GetInputScheme(), asBits[i] ); m_KeysToMap.push_back( k ); } } @@ -97,7 +97,7 @@ void ScreenMapControllers::Init() BitmapText *pName = new BitmapText; pName->SetName( "Primary" ); pName->LoadFromFont( THEME->GetPathF("Common","title") ); - RString sText = GameButtonToLocalizedString( GAMESTATE->GetCurrentGame(), pKey->m_GameButton ); + RString sText = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), pKey->m_GameButton ); pName->SetText( sText ); ActorUtil::LoadAllCommands( *pName, m_sName ); m_Line[iRow].AddChild( pName ); diff --git a/stepmania/src/ScreenTestInput.cpp b/stepmania/src/ScreenTestInput.cpp index 7268873338..956b69d304 100644 --- a/stepmania/src/ScreenTestInput.cpp +++ b/stepmania/src/ScreenTestInput.cpp @@ -57,7 +57,7 @@ class InputList: public BitmapText GameInput gi; if( INPUTMAPPER->DeviceToGame(*di,gi) ) { - RString sName = GameButtonToLocalizedString( GAMESTATE->GetCurrentGame(), gi.button ); + RString sName = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), gi.button ); sTemp += ssprintf(" - "+CONTROLLER.GetValue()+" %d %s", gi.controller+1, sName.c_str() ); if( !PREFSMAN->m_bOnlyDedicatedMenuButtons ) diff --git a/stepmania/src/ScreenTestLights.cpp b/stepmania/src/ScreenTestLights.cpp index a1af527b4f..b46914e21a 100644 --- a/stepmania/src/ScreenTestLights.cpp +++ b/stepmania/src/ScreenTestLights.cpp @@ -79,7 +79,7 @@ void ScreenTestLights::Update( float fDeltaTime ) } else { - RString sGameButton = GameButtonToLocalizedString( GAMESTATE->GetCurrentGame(), gb ); + RString sGameButton = GameButtonToLocalizedString( INPUTMAPPER->GetInputScheme(), gb ); PlayerNumber pn = (PlayerNumber)(gc+1); s += ssprintf( CONTROLLER_LIGHT.GetValue()+": %s %d %s\n", PlayerNumberToString(pn).c_str(), gb, sGameButton.c_str() ); } diff --git a/stepmania/src/arch/Lights/LightsDriver_SystemMessage.cpp b/stepmania/src/arch/Lights/LightsDriver_SystemMessage.cpp index 254204415e..abed3d7ba8 100644 --- a/stepmania/src/arch/Lights/LightsDriver_SystemMessage.cpp +++ b/stepmania/src/arch/Lights/LightsDriver_SystemMessage.cpp @@ -1,8 +1,7 @@ #include "global.h" #include "LightsDriver_SystemMessage.h" #include "ScreenManager.h" -#include "GameState.h" -#include "Game.h" +#include "InputMapper.h" #include "PrefsManager.h" @@ -30,7 +29,7 @@ void LightsDriver_SystemMessage::Set( const LightsState *ls ) } s += "\n"; - int iNumGameButtonsToShow = GAMESTATE->m_pCurGame->GetNumGameplayButtons(); + int iNumGameButtonsToShow = INPUTMAPPER->GetInputScheme()->GetNumGameplayButtons(); FOREACH_GameController( gc ) {