add option to blink the GameButton lights on note instead of step

This commit is contained in:
Chris Danford
2004-04-22 05:25:58 +00:00
parent 6486f449ff
commit 4dfcee7eb0
5 changed files with 107 additions and 30 deletions
+38 -20
View File
@@ -19,6 +19,7 @@
#include "GameInput.h" // for GameController
#include "InputMapper.h"
#include "GameDef.h"
#include "PrefsManager.h"
static const CString CabinetLightNames[NUM_CABINET_LIGHTS] = {
@@ -54,7 +55,8 @@ LightsManager::LightsManager(CString sDriver)
m_pDriver = MakeLightsDriver(sDriver);
ZERO( m_fSecsLeftInBlink );
ZERO( m_fSecsLeftInCabinetLightBlink );
ZERO( m_fSecsLeftInGameButtonBlink );
}
LightsManager::~LightsManager()
@@ -67,15 +69,18 @@ void LightsManager::Update( float fDeltaTime )
// update lights falloff
{
FOREACH_CabinetLight( cl )
m_fSecsLeftInBlink[cl] = max( 0, m_fSecsLeftInBlink[cl] - fDeltaTime );
fapproach( m_fSecsLeftInCabinetLightBlink[cl], 0, fDeltaTime );
FOREACH_GameController( gc )
FOREACH_GameButton( gb )
fapproach( m_fSecsLeftInGameButtonBlink[gc][gb], 0, fDeltaTime );
}
//
// Set new lights state cabinet lights
//
{
FOREACH_CabinetLight( cl )
m_LightsState.m_bCabinetLights[cl] = false;
ZERO( m_LightsState.m_bCabinetLights );
ZERO( m_LightsState.m_bGameButtonLights );
}
switch( m_LightsMode )
@@ -147,12 +152,7 @@ void LightsManager::Update( float fDeltaTime )
case LIGHTSMODE_GAMEPLAY:
{
FOREACH_CabinetLight( cl )
m_LightsState.m_bCabinetLights[cl] = false;
{
FOREACH_CabinetLight( cl )
m_LightsState.m_bCabinetLights[cl] = m_fSecsLeftInBlink[cl] > 0 ;
}
m_LightsState.m_bCabinetLights[cl] = m_fSecsLeftInCabinetLightBlink[cl] > 0 ;
}
break;
case LIGHTSMODE_STAGE:
@@ -221,16 +221,29 @@ void LightsManager::Update( float fDeltaTime )
break;
case LIGHTSMODE_GAMEPLAY:
{
FOREACH_GameController( gc )
if( PREFSMAN->m_bBlinkGameplayButtonLightsOnNote )
{
// don't blink unjoined sides
if( !GAMESTATE->m_bSideIsJoined[gc] )
continue;
FOREACH_GameButton( gb )
FOREACH_GameController( gc )
{
bool bOn = INPUTMAPPER->IsButtonDown( GameInput(gc,gb) );
m_LightsState.m_bGameButtonLights[gc][gb] = bOn;
FOREACH_GameButton( gb )
{
m_LightsState.m_bGameButtonLights[gc][gb] = m_fSecsLeftInGameButtonBlink[gc][gb] > 0 ;
}
}
}
else
{
FOREACH_GameController( gc )
{
// don't blink unjoined sides
if( !GAMESTATE->m_bSideIsJoined[gc] )
continue;
FOREACH_GameButton( gb )
{
bool bOn = INPUTMAPPER->IsButtonDown( GameInput(gc,gb) );
m_LightsState.m_bGameButtonLights[gc][gb] = bOn;
}
}
}
}
@@ -259,9 +272,14 @@ void LightsManager::Update( float fDeltaTime )
m_pDriver->Set( &m_LightsState );
}
void LightsManager::GameplayBlinkLight( CabinetLight cl )
void LightsManager::BlinkCabinetLight( CabinetLight cl )
{
m_fSecsLeftInBlink[cl] = LIGHTS_FALLOFF_SECONDS;
m_fSecsLeftInCabinetLightBlink[cl] = LIGHTS_FALLOFF_SECONDS;
}
void LightsManager::BlinkGameButton( GameInput gi )
{
m_fSecsLeftInGameButtonBlink[gi.controller][gi.button] = LIGHTS_FALLOFF_SECONDS;
}
void LightsManager::SetLightsMode( LightsMode lm )
+4 -2
View File
@@ -62,13 +62,15 @@ public:
void Update( float fDeltaTime );
void GameplayBlinkLight( CabinetLight cl );
void BlinkCabinetLight( CabinetLight cl );
void BlinkGameButton( GameInput gi );
void SetLightsMode( LightsMode lm );
LightsMode GetLightsMode();
private:
float m_fSecsLeftInBlink[NUM_CABINET_LIGHTS];
float m_fSecsLeftInCabinetLightBlink[NUM_CABINET_LIGHTS];
float m_fSecsLeftInGameButtonBlink[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS];
LightsDriver* m_pDriver;
LightsMode m_LightsMode;
+3
View File
@@ -254,6 +254,7 @@ PrefsManager::PrefsManager()
m_sLightsDriver = DEFAULT_LIGHTS_DRIVER;
m_bBlinkGameplayButtonLightsOnNote = false;
m_bAllowUnacceleratedRenderer = false;
m_bThreadedInput = true;
m_bThreadedMovieDecode = true;
@@ -435,6 +436,7 @@ void PrefsManager::ReadGlobalPrefsFromDisk()
ini.GetValue( "Options", "LongVerSeconds", m_fLongVerSongSeconds );
ini.GetValue( "Options", "MarathonVerSeconds", m_fMarathonVerSongSeconds );
ini.GetValue( "Options", "ShowSongOptions", (int&)m_ShowSongOptions );
ini.GetValue( "Options", "BlinkGameplayButtonLightsOnNote", m_bBlinkGameplayButtonLightsOnNote );
ini.GetValue( "Options", "AllowUnacceleratedRenderer", m_bAllowUnacceleratedRenderer );
ini.GetValue( "Options", "ThreadedInput", m_bThreadedInput );
ini.GetValue( "Options", "ThreadedMovieDecode", m_bThreadedMovieDecode );
@@ -656,6 +658,7 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
ini.SetValue( "Options", "LongVerSeconds", m_fLongVerSongSeconds );
ini.SetValue( "Options", "MarathonVerSeconds", m_fMarathonVerSongSeconds );
ini.SetValue( "Options", "ShowSongOptions", m_ShowSongOptions );
ini.SetValue( "Options", "BlinkGameplayButtonLightsOnNote", m_bBlinkGameplayButtonLightsOnNote );
ini.SetValue( "Options", "AllowUnacceleratedRenderer", m_bAllowUnacceleratedRenderer );
ini.SetValue( "Options", "ThreadedInput", m_bThreadedInput );
ini.SetValue( "Options", "ThreadedMovieDecode", m_bThreadedMovieDecode );
+1
View File
@@ -234,6 +234,7 @@ public:
int m_iSoundResampleQuality;
CString m_sMovieDrivers;
CString m_sLightsDriver;
bool m_bBlinkGameplayButtonLightsOnNote;
bool m_bAllowUnacceleratedRenderer;
bool m_bThreadedInput;
bool m_bThreadedMovieDecode;
+61 -8
View File
@@ -1051,7 +1051,7 @@ void ScreenGameplay::LoadNextSong()
//
// Load lights data
// Load cabinet lights data
//
{
m_CabinetLightsNoteData.Init();
@@ -1400,12 +1400,14 @@ void ScreenGameplay::Update( float fDeltaTime )
//
// update lights
//
bool bBlink[NUM_CABINET_LIGHTS];
ZERO( bBlink );
const StyleDef* pStyleDef = GAMESTATE->GetCurrentStyleDef();
bool bBlinkCabinetLight[NUM_CABINET_LIGHTS];
bool bBlinkGameButton[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS];
ZERO( bBlinkCabinetLight );
ZERO( bBlinkGameButton );
bool bCrossedABeat = false;
{
float fPositionSeconds = GAMESTATE->m_fMusicSeconds - LIGHTS_FALLOFF_SECONDS/2; // trigger the light a tiny bit early
fPositionSeconds += (SOUND->GetPlayLatency()) * GAMESTATE->m_SongOptions.m_fMusicRate;
float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds );
int iRowNow = BeatToNoteRowNotRounded( fSongBeat );
@@ -1417,21 +1419,72 @@ void ScreenGameplay::Update( float fDeltaTime )
bCrossedABeat = fBeatLast != fBeatNow;
const int iSongRow = BeatToNoteRow( fSongBeat );
for( int r=iRowLastCrossed+1; r<=iRowNow; r++ ) // for each index we crossed since the last update
{
FOREACH_CabinetLight( cl )
bBlink[cl] |= (m_CabinetLightsNoteData.GetTapNote( cl, r ) != TAP_EMPTY);
{
bool bBlink = (m_CabinetLightsNoteData.GetTapNote( cl, r ) != TAP_EMPTY);
bBlinkCabinetLight[cl] |= bBlink;
}
FOREACH_EnabledPlayer( pn )
{
for( int t=0; t<m_Player[pn].GetNumTracks(); t++ )
{
bool bBlink = (m_Player[pn].GetTapNote(t,r) != TAP_EMPTY);
if( bBlink )
{
StyleInput si( pn, t );
GameInput gi = pStyleDef->StyleInputToGameInput( si );
bBlinkGameButton[gi.controller][gi.button] |= bBlink;
}
}
}
}
iRowLastCrossed = iRowNow;
}
bool bOverrideBlink = (GAMESTATE->m_fSongBeat < GAMESTATE->m_pCurSong->m_fFirstBeat) && bCrossedABeat;
{
// check for active HoldNotes
float fPositionSeconds = GAMESTATE->m_fMusicSeconds - LIGHTS_FALLOFF_SECONDS/2; // trigger the light a tiny bit early
float fSongBeat = GAMESTATE->m_pCurSong->GetBeatFromElapsedTime( fPositionSeconds );
const int iSongRow = BeatToNoteRow( fSongBeat );
FOREACH_EnabledPlayer( pn )
{
// check if a hold should be active
for( int i=0; i < m_Player[pn].GetNumHoldNotes(); i++ ) // for each HoldNote
{
const HoldNote &hn = m_Player[pn].GetHoldNote(i);
if( hn.iStartRow <= iSongRow && iSongRow <= hn.iEndRow )
{
StyleInput si( pn, hn.iTrack );
GameInput gi = pStyleDef->StyleInputToGameInput( si );
bBlinkGameButton[gi.controller][gi.button] |= true;
}
}
}
}
// send blink data
bool bOverrideCabinetBlink = (GAMESTATE->m_fSongBeat < GAMESTATE->m_pCurSong->m_fFirstBeat) && bCrossedABeat;
FOREACH_CabinetLight( cl )
{
if( bOverrideBlink || bBlink[cl] )
LIGHTSMAN->GameplayBlinkLight( cl );
if( bOverrideCabinetBlink || bBlinkCabinetLight[cl] )
LIGHTSMAN->BlinkCabinetLight( cl );
}
FOREACH_GameController( gc )
{
FOREACH_GameButton( gb )
{
if( bBlinkGameButton[gc][gb] )
LIGHTSMAN->BlinkGameButton( GameInput(gc,gb) );
}
}
//