From 8320afe796e29a38542c9d30ae4e87dae5369c87 Mon Sep 17 00:00:00 2001 From: dando92 Date: Fri, 14 Mar 2025 16:16:51 +0100 Subject: [PATCH] Added hide lights feature in player options --- src/LightsManager.cpp | 47 +++++++++++++++++++++++++++++++++++++++++-- src/PlayerOptions.cpp | 42 ++++++++++++++++++++++++++++++++++++++ src/PlayerOptions.h | 15 +++++++++++++- src/PrefsManager.cpp | 1 + src/PrefsManager.h | 1 + 5 files changed, 103 insertions(+), 3 deletions(-) diff --git a/src/LightsManager.cpp b/src/LightsManager.cpp index bb9d101825..c2682cfa1a 100644 --- a/src/LightsManager.cpp +++ b/src/LightsManager.cpp @@ -11,6 +11,8 @@ #include "Actor.h" #include "Preference.h" #include "GameManager.h" +#include "PlayerState.h" +#include "GameState.h" #include "CommonMetrics.h" #include "Style.h" @@ -279,9 +281,50 @@ void LightsManager::Update( float fDeltaTime ) case LIGHTSMODE_DEMONSTRATION: case LIGHTSMODE_GAMEPLAY: { - FOREACH_CabinetLight( cl ) - m_LightsState.m_bCabinetLights[cl] = m_fSecsLeftInCabinetLightBlink[cl] > 0; + FOREACH_CabinetLight(cl) + { + int currLightPlayerNumber = (cl & 1) == 1 ? 1 : 0; + bool skipLightActivation = false; + auto playerOptions = GAMESTATE->m_pPlayerState[currLightPlayerNumber]->m_PlayerOptions.GetCurrent(); + + if (cl == LIGHT_MARQUEE_UP_LEFT || + cl == LIGHT_MARQUEE_UP_RIGHT || + cl == LIGHT_MARQUEE_LR_LEFT || + cl == LIGHT_MARQUEE_LR_RIGHT) + { + if (GAMESTATE->IsHumanPlayer((PlayerNumber)currLightPlayerNumber)) + { + skipLightActivation = playerOptions.m_HideLightType == HideLightType::HideLightType_HideMarqueeLights || + playerOptions.m_HideLightType == HideLightType::HideLightType_HideAllLights; + } + } + else + { + bool lightsBassParallel = PREFSMAN->m_bLightsBassParallel; + + int otherPn = currLightPlayerNumber == 0 ? 1 : 0; + auto otherPlayerOptions = GAMESTATE->m_pPlayerState[otherPn]->m_PlayerOptions.GetCurrent(); + + if (GAMESTATE->IsHumanPlayer((PlayerNumber)currLightPlayerNumber)) + { + skipLightActivation = playerOptions.m_HideLightType == HideLightType::HideLightType_HideBassLights || + playerOptions.m_HideLightType == HideLightType::HideLightType_HideAllLights || + (lightsBassParallel && + (otherPlayerOptions.m_HideLightType == HideLightType::HideLightType_HideBassLights || + otherPlayerOptions.m_HideLightType == HideLightType::HideLightType_HideAllLights)); + } + else + { + skipLightActivation = lightsBassParallel && + (otherPlayerOptions.m_HideLightType == HideLightType::HideLightType_HideBassLights || + otherPlayerOptions.m_HideLightType == HideLightType::HideLightType_HideAllLights); + } + } + + if (!skipLightActivation) + m_LightsState.m_bCabinetLights[cl] = m_fSecsLeftInCabinetLightBlink[cl] > 0; + } break; } diff --git a/src/PlayerOptions.cpp b/src/PlayerOptions.cpp index c95044a594..3fe943613c 100644 --- a/src/PlayerOptions.cpp +++ b/src/PlayerOptions.cpp @@ -34,6 +34,16 @@ XToString( DrainType ); XToLocalizedString( DrainType ); LuaXType( DrainType ); +static const char* HideLightTypeNames[] = { + "NoHideLights", + "HideAllLights", + "HideMarqueeLights", + "HideBassLights", +}; +XToString(HideLightType); +XToLocalizedString(HideLightType); +LuaXType(HideLightType); + static const char *ModTimerTypeNames[] = { "Game", "Beat", @@ -65,6 +75,7 @@ void PlayerOptions::Init() { m_LifeType = LifeType_Bar; m_DrainType = DrainType_Normal; + m_HideLightType = HideLightType_NoHideLights; m_ModTimerType = ModTimerType_Default; m_BatteryLives = 4; m_MinTNSToHideNotes= PREFSMAN->m_MinTNSToHideNotes; @@ -127,6 +138,7 @@ void PlayerOptions::Approach( const PlayerOptions& other, float fDeltaSeconds ) DO_COPY( m_LifeType ); DO_COPY( m_DrainType ); + DO_COPY( m_HideLightType ); DO_COPY( m_ModTimerType ); DO_COPY( m_BatteryLives ); APPROACH( fModTimerMult ); @@ -245,6 +257,24 @@ void PlayerOptions::GetMods( std::vector &AddTo, bool bForceNoteSkin ) FAIL_M(ssprintf("Invalid LifeType: %i", m_LifeType)); } + switch (m_HideLightType) + { + case HideLightType_NoHideLights: + AddTo.push_back("NoHideLights"); + break; + case HideLightType_HideAllLights: + AddTo.push_back("HideAllLights"); + break; + case HideLightType_HideMarqueeLights: + AddTo.push_back("HideMarqueeLights"); + break; + case HideLightType_HideBassLights: + AddTo.push_back("HideBassLights"); + break; + default: + FAIL_M(ssprintf("Invalid HideLightType: %i", m_HideLightType)); + } + if( !m_fTimeSpacing ) { if( m_fMaxScrollBPM ) @@ -747,6 +777,13 @@ bool PlayerOptions::FromOneModString( const RString &sOneMod, RString &sErrorOut else if( sBit == "norecover" || sBit == "power-drop" ) { m_DrainType= DrainType_NoRecover; } else if( sBit == "suddendeath" || sBit == "death" ) { m_DrainType= DrainType_SuddenDeath; } else if( sBit == "normal-drain" ) { m_DrainType= DrainType_Normal; } + else if (sBit.find("lights") != sBit.npos) + { + if (sBit == "nohidelights") m_HideLightType = HideLightType_NoHideLights; + else if (sBit == "hidealllights") m_HideLightType = HideLightType_HideAllLights; + else if (sBit == "hidemarqueelights") m_HideLightType = HideLightType_HideMarqueeLights; + else if (sBit == "hidebasslights") m_HideLightType = HideLightType_HideBassLights; + } else if( sBit == "boost" ) SET_FLOAT( fAccels[ACCEL_BOOST] ) else if( sBit == "brake" || sBit == "land" ) SET_FLOAT( fAccels[ACCEL_BRAKE] ) else if( sBit.find("wave") != sBit.npos) @@ -1412,6 +1449,7 @@ bool PlayerOptions::operator==( const PlayerOptions &other ) const #define COMPARE(x) { if( x != other.x ) return false; } COMPARE(m_LifeType); COMPARE(m_DrainType); + COMPARE(m_HideLightType); COMPARE(m_ModTimerType); COMPARE(m_fModTimerMult); COMPARE(m_fModTimerOffset); @@ -1495,6 +1533,7 @@ PlayerOptions& PlayerOptions::operator=(PlayerOptions const& other) #define CPY_SPEED(x) m_ ## x = other.m_ ## x; m_Speed ## x = other.m_Speed ## x; CPY(m_LifeType); CPY(m_DrainType); + CPY(m_HideLightType); CPY(m_ModTimerType); CPY_SPEED(fModTimerMult); CPY_SPEED(fModTimerOffset); @@ -1771,6 +1810,7 @@ void PlayerOptions::ResetPrefs( ResetPrefsType type ) } CPY(m_LifeType); CPY(m_DrainType); + CPY(m_HideLightType); CPY(m_BatteryLives); CPY(m_ModTimerType); CPY(m_fModTimerMult); @@ -1830,6 +1870,7 @@ public: ENUM_INTERFACE(LifeSetting, LifeType, LifeType); ENUM_INTERFACE(DrainSetting, DrainType, DrainType); + ENUM_INTERFACE(HideLightSetting, HideLightType, HideLightType); ENUM_INTERFACE(ModTimerSetting, ModTimerType, ModTimerType) INT_INTERFACE(BatteryLives, BatteryLives); FLOAT_INTERFACE(ModTimerMult, ModTimerMult, true); @@ -2391,6 +2432,7 @@ public: ADD_METHOD(LifeSetting); ADD_METHOD(DrainSetting); + ADD_METHOD(HideLightSetting); ADD_METHOD(ModTimerSetting); ADD_METHOD(ModTimerMult); ADD_METHOD(ModTimerOffset); diff --git a/src/PlayerOptions.h b/src/PlayerOptions.h index ea3d2d4eb7..b4316019aa 100644 --- a/src/PlayerOptions.h +++ b/src/PlayerOptions.h @@ -41,6 +41,18 @@ const RString& DrainTypeToString( DrainType cat ); const RString& DrainTypeToLocalizedString( DrainType cat ); LuaDeclareType( DrainType ); +enum HideLightType { + HideLightType_NoHideLights = 0, + HideLightType_HideAllLights, + HideLightType_HideMarqueeLights, + HideLightType_HideBassLights, + NUM_HideLightType, + HideLightType_Invalid +}; +const RString& HideLightTypeToString(HideLightType cat); +const RString& HideLightTypeToLocalizedString(HideLightType cat); +LuaDeclareType(HideLightType); + enum ModTimerType { ModTimerType_Game, @@ -62,7 +74,7 @@ public: * @brief Set up the PlayerOptions with some reasonable defaults. * * This code was taken from Init() to use proper initialization. */ - PlayerOptions(): m_LifeType(LifeType_Bar), m_DrainType(DrainType_Normal), + PlayerOptions(): m_LifeType(LifeType_Bar), m_DrainType(DrainType_Normal), m_HideLightType(HideLightType_NoHideLights), m_ModTimerType(ModTimerType_Default), m_BatteryLives(4), m_bSetScrollSpeed(false), @@ -340,6 +352,7 @@ public: PlayerNumber m_pn; // Needed for fetching the style. + HideLightType m_HideLightType; LifeType m_LifeType; DrainType m_DrainType; // only used with LifeBar ModTimerType m_ModTimerType; diff --git a/src/PrefsManager.cpp b/src/PrefsManager.cpp index 8412376cd4..57b1c2864a 100644 --- a/src/PrefsManager.cpp +++ b/src/PrefsManager.cpp @@ -296,6 +296,7 @@ PrefsManager::PrefsManager() : m_iSoundPreferredSampleRate ( "SoundPreferredSampleRate", 0 ), m_sLightsStepsDifficulty ( "LightsStepsDifficulty", "hard,medium" ), m_bLightsSimplifyBass ( "LightsSimplifyBass", false), + m_bLightsBassParallel ( "LightsBassParallel", false), m_bAllowUnacceleratedRenderer ( "AllowUnacceleratedRenderer", false ), m_bThreadedInput ( "ThreadedInput", true ), m_bThreadedMovieDecode ( "ThreadedMovieDecode", true ), diff --git a/src/PrefsManager.h b/src/PrefsManager.h index 86f7cbb367..4b8e47ada5 100644 --- a/src/PrefsManager.h +++ b/src/PrefsManager.h @@ -322,6 +322,7 @@ public: Preference m_iSoundPreferredSampleRate; Preference m_sLightsStepsDifficulty; Preference m_bLightsSimplifyBass; + Preference m_bLightsBassParallel; Preference m_bAllowUnacceleratedRenderer; Preference m_bThreadedInput; Preference m_bThreadedMovieDecode;