slightly odd, but practical: handle coin counter in LightsMan
This commit is contained in:
@@ -83,6 +83,8 @@ LightsManager::LightsManager()
|
|||||||
ZERO( m_fSecsLeftInGameButtonBlink );
|
ZERO( m_fSecsLeftInGameButtonBlink );
|
||||||
ZERO( m_fActorLights );
|
ZERO( m_fActorLights );
|
||||||
ZERO( m_fSecsLeftInActorLightBlink );
|
ZERO( m_fSecsLeftInActorLightBlink );
|
||||||
|
m_iQueuedCoinCounterPulses = 0;
|
||||||
|
m_CoinCounterTimer.SetZero();
|
||||||
|
|
||||||
m_LightsMode = LIGHTSMODE_JOINING;
|
m_LightsMode = LIGHTSMODE_JOINING;
|
||||||
RString sDriver = g_sLightsDriver.Get();
|
RString sDriver = g_sLightsDriver.Get();
|
||||||
@@ -104,6 +106,7 @@ LightsManager::~LightsManager()
|
|||||||
// XXX: make themable
|
// XXX: make themable
|
||||||
static const float g_fLightEffectRiseSeconds = 0.075f;
|
static const float g_fLightEffectRiseSeconds = 0.075f;
|
||||||
static const float g_fLightEffectFalloffSeconds = 0.35f;
|
static const float g_fLightEffectFalloffSeconds = 0.35f;
|
||||||
|
static const float g_fCoinPulseTime = 0.100f;
|
||||||
|
|
||||||
void LightsManager::BlinkActorLight( CabinetLight cl )
|
void LightsManager::BlinkActorLight( CabinetLight cl )
|
||||||
{
|
{
|
||||||
@@ -162,6 +165,23 @@ void LightsManager::Update( float fDeltaTime )
|
|||||||
ZERO( m_LightsState.m_bGameButtonLights );
|
ZERO( m_LightsState.m_bGameButtonLights );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
m_LightsState.m_bCoinCounter = false;
|
||||||
|
if( !m_CoinCounterTimer.IsZero() )
|
||||||
|
{
|
||||||
|
float fAgo = m_CoinCounterTimer.Ago();
|
||||||
|
if( fAgo < g_fCoinPulseTime )
|
||||||
|
m_LightsState.m_bCoinCounter = true;
|
||||||
|
else if( fAgo >= g_fCoinPulseTime * 2 )
|
||||||
|
m_CoinCounterTimer.SetZero();
|
||||||
|
}
|
||||||
|
else if( m_iQueuedCoinCounterPulses )
|
||||||
|
{
|
||||||
|
m_CoinCounterTimer.Touch();
|
||||||
|
--m_iQueuedCoinCounterPulses;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE )
|
if( m_LightsMode == LIGHTSMODE_TEST_AUTO_CYCLE )
|
||||||
{
|
{
|
||||||
m_fTestAutoCycleCurrentIndex += fDeltaTime;
|
m_fTestAutoCycleCurrentIndex += fDeltaTime;
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "GameInput.h"
|
#include "GameInput.h"
|
||||||
#include "EnumHelper.h"
|
#include "EnumHelper.h"
|
||||||
#include "Preference.h"
|
#include "Preference.h"
|
||||||
|
#include "RageTimer.h"
|
||||||
|
|
||||||
extern Preference<float> g_fLightsFalloffSeconds;
|
extern Preference<float> g_fLightsFalloffSeconds;
|
||||||
extern Preference<float> g_fLightsAheadSeconds;
|
extern Preference<float> g_fLightsAheadSeconds;
|
||||||
@@ -48,6 +49,9 @@ struct LightsState
|
|||||||
{
|
{
|
||||||
bool m_bCabinetLights[NUM_CabinetLight];
|
bool m_bCabinetLights[NUM_CabinetLight];
|
||||||
bool m_bGameButtonLights[NUM_GameController][NUM_GameButton];
|
bool m_bGameButtonLights[NUM_GameController][NUM_GameButton];
|
||||||
|
|
||||||
|
// This isn't actually a light, but it's typically implemented in the same way.
|
||||||
|
bool m_bCoinCounter;
|
||||||
};
|
};
|
||||||
|
|
||||||
class LightsDriver;
|
class LightsDriver;
|
||||||
@@ -64,6 +68,7 @@ public:
|
|||||||
void BlinkCabinetLight( CabinetLight cl );
|
void BlinkCabinetLight( CabinetLight cl );
|
||||||
void BlinkGameButton( GameInput gi );
|
void BlinkGameButton( GameInput gi );
|
||||||
void BlinkActorLight( CabinetLight cl );
|
void BlinkActorLight( CabinetLight cl );
|
||||||
|
void PulseCoinCounter() { ++m_iQueuedCoinCounterPulses; }
|
||||||
float GetActorLightLatencySeconds() const;
|
float GetActorLightLatencySeconds() const;
|
||||||
|
|
||||||
void SetLightsMode( LightsMode lm );
|
void SetLightsMode( LightsMode lm );
|
||||||
@@ -90,6 +95,9 @@ private:
|
|||||||
LightsMode m_LightsMode;
|
LightsMode m_LightsMode;
|
||||||
LightsState m_LightsState;
|
LightsState m_LightsState;
|
||||||
|
|
||||||
|
int m_iQueuedCoinCounterPulses;
|
||||||
|
RageTimer m_CoinCounterTimer;
|
||||||
|
|
||||||
int GetTestAutoCycleCurrentIndex() { return (int)m_fTestAutoCycleCurrentIndex; }
|
int GetTestAutoCycleCurrentIndex() { return (int)m_fTestAutoCycleCurrentIndex; }
|
||||||
|
|
||||||
float m_fTestAutoCycleCurrentIndex;
|
float m_fTestAutoCycleCurrentIndex;
|
||||||
|
|||||||
@@ -1195,6 +1195,8 @@ RString StepMania::SaveScreenshot( RString sDir, bool bSaveCompressed, bool bMak
|
|||||||
|
|
||||||
void StepMania::InsertCoin( int iNum, const RageTimer *pTime )
|
void StepMania::InsertCoin( int iNum, const RageTimer *pTime )
|
||||||
{
|
{
|
||||||
|
for( int i = 0; i < iNum; ++i )
|
||||||
|
LIGHTSMAN->PulseCoinCounter();
|
||||||
GAMESTATE->m_iCoins += iNum;
|
GAMESTATE->m_iCoins += iNum;
|
||||||
LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit.Get() );
|
LOG->Trace("%i coins inserted, %i needed to play", GAMESTATE->m_iCoins, PREFSMAN->m_iCoinsPerCredit.Get() );
|
||||||
BOOKKEEPER->CoinInserted();
|
BOOKKEEPER->CoinInserted();
|
||||||
|
|||||||
Reference in New Issue
Block a user