only cycle through controller lights that are actually used

This commit is contained in:
Chris Danford
2005-06-08 04:46:31 +00:00
parent 6c1a16e61d
commit 23d7d3564b
3 changed files with 67 additions and 24 deletions
+14 -1
View File
@@ -246,7 +246,20 @@ struct GameInput
GameController controller; GameController controller;
GameButton button; GameButton button;
bool operator==( const GameInput &other ) { return controller == other.controller && button == other.button; }; bool operator==( const GameInput &other ) const { return controller == other.controller && button == other.button; };
bool operator<( const GameInput &other ) const
{
if( controller < other.controller )
return true;
else if( controller > other.controller )
return false;
if( button < other.button )
return true;
else if( button > other.button )
return false;
return false;
};
inline bool IsValid() const { return controller != GAME_CONTROLLER_INVALID; }; inline bool IsValid() const { return controller != GAME_CONTROLLER_INVALID; };
inline void MakeInvalid() { controller = GAME_CONTROLLER_INVALID; button = GAME_BUTTON_INVALID; }; inline void MakeInvalid() { controller = GAME_CONTROLLER_INVALID; button = GAME_BUTTON_INVALID; };
+52 -21
View File
@@ -11,6 +11,9 @@
#include "Actor.h" #include "Actor.h"
#include "Preference.h" #include "Preference.h"
#include "Foreach.h" #include "Foreach.h"
#include "GameManager.h"
#include "CommonMetrics.h"
#include "Style.h"
#include "arch/arch.h" #include "arch/arch.h"
@@ -44,6 +47,34 @@ static const CString LightsModeNames[] = {
}; };
XToString( LightsMode, NUM_LIGHTS_MODES ); XToString( LightsMode, NUM_LIGHTS_MODES );
static void GetUsedGameInputs( vector<GameInput> &vGameInputsOut )
{
vGameInputsOut.clear();
set<GameInput> vGIs;
vector<const Style*> vStyles;
GAMEMAN->GetStylesForGame( GAMESTATE->m_pCurGame, vStyles );
FOREACH( const Style*, vStyles, style )
{
bool bFound = find( STEPS_TYPES_TO_SHOW.GetValue().begin(), STEPS_TYPES_TO_SHOW.GetValue().end(), (*style)->m_StepsType ) != STEPS_TYPES_TO_SHOW.GetValue().end();
if( !bFound )
continue;
FOREACH_PlayerNumber( pn )
{
for( int i=0; i<(*style)->m_iColsPerPlayer; i++ )
{
StyleInput si( pn, i );
GameInput gi = (*style)->StyleInputToGameInput( si );
if( gi.IsValid() )
{
vGIs.insert( gi );
}
}
}
}
FOREACHS_CONST( GameInput, vGIs, gi )
vGameInputsOut.push_back( *gi );
}
LightsManager* LIGHTSMAN = NULL; // global and accessable from anywhere in our program LightsManager* LIGHTSMAN = NULL; // global and accessable from anywhere in our program
@@ -58,8 +89,7 @@ LightsManager::LightsManager(CString sDriver)
MakeLightsDrivers( sDriver, m_vpDrivers ); MakeLightsDrivers( sDriver, m_vpDrivers );
m_fTestAutoCycleCurrentIndex = 0; m_fTestAutoCycleCurrentIndex = 0;
m_clTestManualCycleCurrent = LIGHT_INVALID; m_clTestManualCycleCurrent = LIGHT_INVALID;
m_gcTestManualCycleCurrent = GAME_CONTROLLER_INVALID; m_iControllerTestManualCycleCurrent = -1;
m_gbTestManualCycleCurrent = GAME_BUTTON_INVALID;
} }
LightsManager::~LightsManager() LightsManager::~LightsManager()
@@ -331,25 +361,30 @@ void LightsManager::Update( float fDeltaTime )
case LIGHTSMODE_TEST_AUTO_CYCLE: case LIGHTSMODE_TEST_AUTO_CYCLE:
{ {
int index = GetTestAutoCycleCurrentIndex(); int index = GetTestAutoCycleCurrentIndex();
int iNumGameButtonsToShow = GAMESTATE->GetCurrentGame()->GetNumGameplayButtons();
wrap( index, MAX_GAME_CONTROLLERS*iNumGameButtonsToShow ); vector<GameInput> vGI;
GetUsedGameInputs( vGI );
wrap( index, vGI.size() );
ZERO( m_LightsState.m_bGameButtonLights ); ZERO( m_LightsState.m_bGameButtonLights );
GameController gc = (GameController)(index / iNumGameButtonsToShow); GameController gc = vGI[index].controller;
GameButton gb = (GameButton)(index % iNumGameButtonsToShow); GameButton gb = vGI[index].button;
m_LightsState.m_bGameButtonLights[gc][gb] = true; m_LightsState.m_bGameButtonLights[gc][gb] = true;
} }
break; break;
case LIGHTSMODE_TEST_MANUAL_CYCLE: case LIGHTSMODE_TEST_MANUAL_CYCLE:
{ {
FOREACH_GameController( gc ) ZERO( m_LightsState.m_bGameButtonLights );
vector<GameInput> vGI;
GetUsedGameInputs( vGI );
if( m_iControllerTestManualCycleCurrent != -1 )
{ {
FOREACH_GameButton( gb ) GameController gc = vGI[m_iControllerTestManualCycleCurrent].controller;
{ GameButton gb = vGI[m_iControllerTestManualCycleCurrent].button;
bool bOn = gc==m_gcTestManualCycleCurrent && gb==m_gbTestManualCycleCurrent; m_LightsState.m_bGameButtonLights[gc][gb] = true;
m_LightsState.m_bGameButtonLights[gc][gb] = bOn;
}
} }
} }
break; break;
@@ -384,8 +419,7 @@ LightsMode LightsManager::GetLightsMode()
void LightsManager::ChangeTestCabinetLight( int iDir ) void LightsManager::ChangeTestCabinetLight( int iDir )
{ {
m_gcTestManualCycleCurrent = GAME_CONTROLLER_INVALID; m_iControllerTestManualCycleCurrent = -1;
m_gbTestManualCycleCurrent = GAME_BUTTON_INVALID;
m_clTestManualCycleCurrent = (CabinetLight)(m_clTestManualCycleCurrent+iDir); m_clTestManualCycleCurrent = (CabinetLight)(m_clTestManualCycleCurrent+iDir);
wrap( (int&)m_clTestManualCycleCurrent, NUM_CABINET_LIGHTS ); wrap( (int&)m_clTestManualCycleCurrent, NUM_CABINET_LIGHTS );
@@ -395,14 +429,11 @@ void LightsManager::ChangeTestGameButtonLight( int iDir )
{ {
m_clTestManualCycleCurrent = LIGHT_INVALID; m_clTestManualCycleCurrent = LIGHT_INVALID;
int iNumGameButtonsToShow = GAMESTATE->GetCurrentGame()->GetNumGameplayButtons(); vector<GameInput> vGI;
int index = m_gcTestManualCycleCurrent * iNumGameButtonsToShow + m_gbTestManualCycleCurrent; GetUsedGameInputs( vGI );
index += iDir; m_iControllerTestManualCycleCurrent += iDir;
wrap( index, MAX_GAME_CONTROLLERS * iNumGameButtonsToShow ); wrap( m_iControllerTestManualCycleCurrent, vGI.size() );
m_gcTestManualCycleCurrent = (GameController)(index / iNumGameButtonsToShow);
m_gbTestManualCycleCurrent = (GameButton)(index % iNumGameButtonsToShow);
} }
CabinetLight LightsManager::GetFirstLitCabinetLight() CabinetLight LightsManager::GetFirstLitCabinetLight()
+1 -2
View File
@@ -93,8 +93,7 @@ private:
float m_fTestAutoCycleCurrentIndex; float m_fTestAutoCycleCurrentIndex;
CabinetLight m_clTestManualCycleCurrent; CabinetLight m_clTestManualCycleCurrent;
GameController m_gcTestManualCycleCurrent; int m_iControllerTestManualCycleCurrent;
GameButton m_gbTestManualCycleCurrent;
}; };