InputScheme
This commit is contained in:
@@ -97,7 +97,6 @@ bool CodeItem::Load( RString sButtonsNames )
|
||||
{
|
||||
buttons.clear();
|
||||
|
||||
const Game* pGame = GAMESTATE->GetCurrentGame();
|
||||
vector<RString> 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() );
|
||||
|
||||
+12
-12
@@ -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; i<pGame->m_iButtonsPerController; i++ )
|
||||
for( int i=0; i<pInputs->m_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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -48,7 +48,7 @@ void ScreenMapControllers::Init()
|
||||
if( sButtons.empty() )
|
||||
{
|
||||
/* Map all buttons for this game. */
|
||||
for( int b=0; b<GAMESTATE->GetCurrentGame()->m_iButtonsPerController; b++ )
|
||||
for( int b=0; b<INPUTMAPPER->GetInputScheme()->m_iButtonsPerController; b++ )
|
||||
{
|
||||
KeyToMap k;
|
||||
k.m_GameButton = (GameButton) b;
|
||||
@@ -63,7 +63,7 @@ void ScreenMapControllers::Init()
|
||||
for( unsigned i=0; i<asBits.size(); ++i )
|
||||
{
|
||||
KeyToMap k;
|
||||
k.m_GameButton = StringToGameButton( GAMESTATE->GetCurrentGame(), 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 );
|
||||
|
||||
@@ -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 )
|
||||
|
||||
@@ -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() );
|
||||
}
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user