move "merged input" test into InputMapper; this moves the GAMESTATE

dependency out of Game (doesn't belong in InputMapper either, working on
it ...)
This commit is contained in:
Glenn Maynard
2006-09-30 03:08:18 +00:00
parent 5e99a1c9e9
commit 261849d895
2 changed files with 16 additions and 24 deletions
+10 -24
View File
@@ -2,8 +2,6 @@
#include "Game.h" #include "Game.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Style.h"
#include "GameState.h"
#include "PrefsManager.h" #include "PrefsManager.h"
int Game::GetNumGameplayButtons() const int Game::GetNumGameplayButtons() const
@@ -47,33 +45,21 @@ void Game::MenuButtonToGameInputs( MenuButton MenuI, PlayerNumber pn, GameInput
GameIout[2].MakeInvalid(); GameIout[2].MakeInvalid();
GameIout[3].MakeInvalid(); GameIout[3].MakeInvalid();
GameController controller[2]; vector<GameController> controller;
StyleType type = TWO_PLAYERS_TWO_SIDES; if( pn == PLAYER_INVALID )
if( GAMESTATE->GetCurrentStyle() )
type = GAMESTATE->GetCurrentStyle()->m_StyleType;
int iNumSidesUsing = 1;
switch( type )
{ {
case ONE_PLAYER_ONE_SIDE: controller.push_back( GAME_CONTROLLER_1 );
case TWO_PLAYERS_TWO_SIDES: controller.push_back( GAME_CONTROLLER_2 );
case TWO_PLAYERS_SHARED_SIDES: }
controller[0] = (GameController)pn; else
iNumSidesUsing = 1; {
break; controller.push_back( (GameController)pn );
case ONE_PLAYER_TWO_SIDES: }
controller[0] = GAME_CONTROLLER_1;
controller[1] = GAME_CONTROLLER_2;
iNumSidesUsing = 2;
break;
default:
ASSERT(0); // invalid m_StyleType
};
GameButton button[2] = { m_DedicatedMenuButton[MenuI], m_SecondaryMenuButton[MenuI] }; GameButton button[2] = { m_DedicatedMenuButton[MenuI], m_SecondaryMenuButton[MenuI] };
int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2; int iNumButtonsUsing = PREFSMAN->m_bOnlyDedicatedMenuButtons ? 1 : 2;
for( int i=0; i<iNumSidesUsing; i++ ) for( size_t i=0; i<controller.size(); i++ )
{ {
for( int j=0; j<iNumButtonsUsing; j++ ) for( int j=0; j<iNumButtonsUsing; j++ )
{ {
+6
View File
@@ -777,6 +777,12 @@ MenuButton InputMapper::GameToMenu( const GameInput &GameI )
void InputMapper::MenuToGame( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] ) void InputMapper::MenuToGame( MenuButton MenuI, PlayerNumber pn, GameInput GameIout[4] )
{ {
if( GAMESTATE->GetCurrentStyle() )
{
if( GAMESTATE->GetCurrentStyle()->m_StyleType == ONE_PLAYER_TWO_SIDES )
pn = PLAYER_INVALID;
}
const Game* pGame = GAMESTATE->GetCurrentGame(); const Game* pGame = GAMESTATE->GetCurrentGame();
pGame->MenuButtonToGameInputs( MenuI, pn, GameIout ); pGame->MenuButtonToGameInputs( MenuI, pn, GameIout );
} }