diff --git a/stepmania/src/LightsManager.cpp b/stepmania/src/LightsManager.cpp index b057ad3322..b7702ff887 100644 --- a/stepmania/src/LightsManager.cpp +++ b/stepmania/src/LightsManager.cpp @@ -41,12 +41,15 @@ LightsManager* LIGHTSMAN = NULL; // global and accessable from anywhere in our p LightsManager::LightsManager(CString sDriver) { - m_LightsMode = LIGHTSMODE_JOINING; - m_pDriver = MakeLightsDriver(sDriver); - m_fCurrentCurrentTestLightIndex = 0; - ZERO( m_fSecsLeftInCabinetLightBlink ); ZERO( m_fSecsLeftInGameButtonBlink ); + + m_LightsMode = LIGHTSMODE_JOINING; + m_pDriver = MakeLightsDriver(sDriver); + m_fTestAutoCycleCurrentIndex = 0; + m_clTestManualCycleCurrent = LIGHT_INVALID; + m_gcTestManualCycleCurrent = GAME_CONTROLLER_INVALID; + m_gbTestManualCycleCurrent = GAME_BUTTON_INVALID; } LightsManager::~LightsManager() @@ -78,8 +81,8 @@ void LightsManager::Update( float fDeltaTime ) if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE ) { - m_fCurrentCurrentTestLightIndex += fDeltaTime; - m_fCurrentCurrentTestLightIndex = fmodf( m_fCurrentCurrentTestLightIndex, NUM_CABINET_LIGHTS*100 ); + m_fTestAutoCycleCurrentIndex += fDeltaTime; + m_fTestAutoCycleCurrentIndex = fmodf( m_fTestAutoCycleCurrentIndex, NUM_CABINET_LIGHTS*100 ); } switch( m_LightsMode ) @@ -160,9 +163,8 @@ void LightsManager::Update( float fDeltaTime ) } break; case LIGHTSMODE_TEST_AUTO_CYCLE: - case LIGHTSMODE_TEST_MANUAL_CYCLE: { - int iSec = GetCurrentTestLightIndex(); + int iSec = GetTestAutoCycleCurrentIndex(); FOREACH_CabinetLight( cl ) { bool bOn = (iSec%NUM_CABINET_LIGHTS) == cl; @@ -170,6 +172,15 @@ void LightsManager::Update( float fDeltaTime ) } } break; + case LIGHTSMODE_TEST_MANUAL_CYCLE: + { + FOREACH_CabinetLight( cl ) + { + bool bOn = cl == m_clTestManualCycleCurrent; + m_LightsState.m_bCabinetLights[cl] = bOn; + } + } + break; default: ASSERT(0); } @@ -253,17 +264,25 @@ void LightsManager::Update( float fDeltaTime ) } break; case LIGHTSMODE_TEST_AUTO_CYCLE: + { + int index = GetTestAutoCycleCurrentIndex(); + int iNumGameButtonsToShow = GAMESTATE->GetCurrentGame()->GetNumGameplayButtons(); + wrap( index, MAX_GAME_CONTROLLERS*iNumGameButtonsToShow ); + + ZERO( m_LightsState.m_bGameButtonLights ); + + GameController gc = (GameController)(index / iNumGameButtonsToShow); + GameButton gb = (GameButton)(index % iNumGameButtonsToShow); + m_LightsState.m_bGameButtonLights[gc][gb] = true; + } + break; case LIGHTSMODE_TEST_MANUAL_CYCLE: { - int iSec = GetCurrentTestLightIndex(); - - int iNumGameButtonsToShow = GAMESTATE->GetCurrentGame()->GetNumGameplayButtons(); - FOREACH_GameController( gc ) { FOREACH_GameButton( gb ) { - bool bOn = gb==(iSec%iNumGameButtonsToShow); + bool bOn = gc==m_gcTestManualCycleCurrent && gb==m_gbTestManualCycleCurrent; m_LightsState.m_bGameButtonLights[gc][gb] = bOn; } } @@ -297,32 +316,58 @@ LightsMode LightsManager::GetLightsMode() return m_LightsMode; } -void LightsManager::PrevTestLight() +void LightsManager::ChangeTestCabinetLight( int iDir ) { - m_fCurrentCurrentTestLightIndex -= 1; - m_fCurrentCurrentTestLightIndex = Quantize( m_fCurrentCurrentTestLightIndex, 1.0f ); - fmodf( m_fCurrentCurrentTestLightIndex, NUM_CABINET_LIGHTS*100 ); + m_gcTestManualCycleCurrent = GAME_CONTROLLER_INVALID; + m_gbTestManualCycleCurrent = GAME_BUTTON_INVALID; + + m_clTestManualCycleCurrent = (CabinetLight)(m_clTestManualCycleCurrent+iDir); + wrap( (int&)m_clTestManualCycleCurrent, NUM_CABINET_LIGHTS ); } -void LightsManager::NextTestLight() +void LightsManager::ChangeTestGameButtonLight( int iDir ) { - m_fCurrentCurrentTestLightIndex += 1; - m_fCurrentCurrentTestLightIndex = Quantize( m_fCurrentCurrentTestLightIndex, 1.0f ); - fmodf( m_fCurrentCurrentTestLightIndex, NUM_CABINET_LIGHTS*100 ); -} - - -CabinetLight LightsManager::GetCurrentTestCabinetLight() -{ - return (CabinetLight)(GetCurrentTestLightIndex()%NUM_CABINET_LIGHTS); -} - -int LightsManager::GetCurrentTestGameplayLight() -{ + m_clTestManualCycleCurrent = LIGHT_INVALID; + int iNumGameButtonsToShow = GAMESTATE->GetCurrentGame()->GetNumGameplayButtons(); - return GetCurrentTestLightIndex()%iNumGameButtonsToShow; + int index = m_gcTestManualCycleCurrent * iNumGameButtonsToShow + m_gbTestManualCycleCurrent; + + index += iDir; + wrap( index, MAX_GAME_CONTROLLERS * iNumGameButtonsToShow ); + + m_gcTestManualCycleCurrent = (GameController)(index / iNumGameButtonsToShow); + m_gbTestManualCycleCurrent = (GameButton)(index % iNumGameButtonsToShow); } +CabinetLight LightsManager::GetFirstLitCabinetLight() +{ + FOREACH_CabinetLight( cl ) + { + if( m_LightsState.m_bCabinetLights[cl] ) + return cl; + } + return LIGHT_INVALID; +} + +void LightsManager::GetFirstLitGameButtonLight( GameController &gcOut, GameButton &gbOut ) +{ + FOREACH_GameController( gc ) + { + FOREACH_GameButton( gb ) + { + if( m_LightsState.m_bGameButtonLights[gc][gb] ) + { + gcOut = gc; + gbOut = gb; + return; + } + } + } + gcOut = GAME_CONTROLLER_INVALID; + gbOut = GAME_BUTTON_INVALID; +} + + /* * (c) 2003-2004 Chris Danford * All rights reserved. diff --git a/stepmania/src/LightsManager.h b/stepmania/src/LightsManager.h index 9cc0b64b70..03b19f579d 100644 --- a/stepmania/src/LightsManager.h +++ b/stepmania/src/LightsManager.h @@ -19,7 +19,8 @@ enum CabinetLight LIGHT_BUTTONS_RIGHT, LIGHT_BASS_LEFT, LIGHT_BASS_RIGHT, - NUM_CABINET_LIGHTS + NUM_CABINET_LIGHTS, + LIGHT_INVALID }; #define FOREACH_CabinetLight( i ) FOREACH_ENUM( CabinetLight, NUM_CABINET_LIGHTS, i ) const CString& CabinetLightToString( CabinetLight cl ); @@ -62,13 +63,18 @@ public: void SetLightsMode( LightsMode lm ); LightsMode GetLightsMode(); - void PrevTestLight(); - void NextTestLight(); + void PrevTestCabinetLight() { ChangeTestCabinetLight(-1); } + void NextTestCabinetLight() { ChangeTestCabinetLight(+1); } + void PrevTestGameButtonLight() { ChangeTestGameButtonLight(-1); } + void NextTestGameButtonLight() { ChangeTestGameButtonLight(+1); } - CabinetLight GetCurrentTestCabinetLight(); - int GetCurrentTestGameplayLight(); + CabinetLight GetFirstLitCabinetLight(); + void GetFirstLitGameButtonLight( GameController &gcOut, GameButton &gbOut ); private: + void ChangeTestCabinetLight( int iDir ); + void ChangeTestGameButtonLight( int iDir ); + float m_fSecsLeftInCabinetLightBlink[NUM_CABINET_LIGHTS]; float m_fSecsLeftInGameButtonBlink[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS]; @@ -76,8 +82,12 @@ private: LightsMode m_LightsMode; LightsState m_LightsState; - int GetCurrentTestLightIndex() { return (int)m_fCurrentCurrentTestLightIndex; } - float m_fCurrentCurrentTestLightIndex; + int GetTestAutoCycleCurrentIndex() { return (int)m_fTestAutoCycleCurrentIndex; } + + float m_fTestAutoCycleCurrentIndex; + CabinetLight m_clTestManualCycleCurrent; + GameController m_gcTestManualCycleCurrent; + GameButton m_gbTestManualCycleCurrent; }; diff --git a/stepmania/src/ScreenTestLights.cpp b/stepmania/src/ScreenTestLights.cpp index dee6666adb..d6826fa11b 100644 --- a/stepmania/src/ScreenTestLights.cpp +++ b/stepmania/src/ScreenTestLights.cpp @@ -25,8 +25,8 @@ void ScreenTestLights::Init() m_textInputs.LoadFromFont( THEME->GetPathF("Common","normal") ); m_textInputs.SetText( "" ); - m_textInputs.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); - m_textInputs.SetDiffuse( RageColor(1,1,1,1) ); + m_textInputs.SetXY( SCREEN_CENTER_X - 200, SCREEN_CENTER_Y ); + m_textInputs.SetHorizAlign( Actor::align_left ); m_textInputs.SetZoom( 0.8f ); this->AddChild( &m_textInputs ); @@ -53,15 +53,39 @@ void ScreenTestLights::Update( float fDeltaTime ) } - CabinetLight cl = LIGHTSMAN->GetCurrentTestCabinetLight(); - GameButton gb = (GameButton)(LIGHTSMAN->GetCurrentTestGameplayLight()); - CString sCabLight = CabinetLightToString(cl); - CString sGameButton = GAMESTATE->GetCurrentGame()->m_szButtonNames[gb]; + CabinetLight cl = LIGHTSMAN->GetFirstLitCabinetLight(); + GameController gc; + GameButton gb; + LIGHTSMAN->GetFirstLitGameButtonLight( gc, gb ); CString s; - s += ssprintf("cabinet light %d: %s\n", cl, sCabLight.c_str()); - FOREACH_GameController( gc ) - s += ssprintf("controller %d light %d: %s\n", gc+1, gb, sGameButton.c_str()); + + switch( LIGHTSMAN->GetLightsMode() ) + { + case LIGHTSMODE_TEST_AUTO_CYCLE: + s += "Auto Cycle\n"; + break; + case LIGHTSMODE_TEST_MANUAL_CYCLE: + s += "Manual Cycle\n"; + break; + default: + ASSERT(0); + } + + if( cl == LIGHT_INVALID ) + s += "cabinet light: -----\n"; + else + s += ssprintf( "cabinet light: %d %s\n", cl, CabinetLightToString(cl).c_str() ); + + if( gc == GAME_CONTROLLER_INVALID ) + { + s += ssprintf( "controller light: -----\n" ); + } + else + { + CString sGameButton = GAMESTATE->GetCurrentGame()->m_szButtonNames[gb]; + s += ssprintf( "controller light: P%d %d %s\n", gc+1, gb, sGameButton.c_str() ); + } m_textInputs.SetText( s ); } @@ -95,14 +119,20 @@ void ScreenTestLights::HandleScreenMessage( const ScreenMessage SM ) void ScreenTestLights::MenuLeft( PlayerNumber pn ) { LIGHTSMAN->SetLightsMode( LIGHTSMODE_TEST_MANUAL_CYCLE ); - LIGHTSMAN->PrevTestLight(); + if( pn == PLAYER_1 ) + LIGHTSMAN->PrevTestCabinetLight(); + else + LIGHTSMAN->PrevTestGameButtonLight(); m_timerBackToAutoCycle.Touch(); } void ScreenTestLights::MenuRight( PlayerNumber pn ) { LIGHTSMAN->SetLightsMode( LIGHTSMODE_TEST_MANUAL_CYCLE ); - LIGHTSMAN->NextTestLight(); + if( pn == PLAYER_1 ) + LIGHTSMAN->NextTestCabinetLight(); + else + LIGHTSMAN->NextTestGameButtonLight(); m_timerBackToAutoCycle.Touch(); }