Mini-rewrite of input mapping, theme support, and added KSF reader.
This commit is contained in:
@@ -26,14 +26,15 @@ InputQueue::InputQueue()
|
||||
m_aQueue[p].SetSize( MAX_INPUT_QUEUE_LENGTH );
|
||||
}
|
||||
|
||||
void InputQueue::HandleInput( const PlayerNumber p, const MenuButton b )
|
||||
void InputQueue::RememberInput( const GameInput GameI )
|
||||
{
|
||||
if( m_aQueue[p].GetSize() >= MAX_INPUT_QUEUE_LENGTH ) // full
|
||||
m_aQueue[p].RemoveAt( 0, m_aQueue[p].GetSize()-MAX_INPUT_QUEUE_LENGTH+1 );
|
||||
m_aQueue[p].Add( MenuButtonAndTime(b,TIMER->GetTimeSinceStart()) );
|
||||
int c = GameI.controller;
|
||||
if( m_aQueue[c].GetSize() >= MAX_INPUT_QUEUE_LENGTH ) // full
|
||||
m_aQueue[c].RemoveAt( 0, m_aQueue[c].GetSize()-MAX_INPUT_QUEUE_LENGTH+1 );
|
||||
m_aQueue[c].Add( GameButtonAndTime(GameI.button,TIMER->GetTimeSinceStart()) );
|
||||
};
|
||||
|
||||
bool InputQueue::MatchesPattern( const PlayerNumber p, const MenuButton* button_sequence, const int iNumButtons, float fMaxSecondsBack )
|
||||
bool InputQueue::MatchesPattern( const GameController c, const GameButton* button_sequence, const int iNumButtons, float fMaxSecondsBack )
|
||||
{
|
||||
if( fMaxSecondsBack == -1 )
|
||||
fMaxSecondsBack = 0.4f + iNumButtons*0.15f;
|
||||
@@ -41,9 +42,9 @@ bool InputQueue::MatchesPattern( const PlayerNumber p, const MenuButton* button_
|
||||
float fOldestTimeAllowed = TIMER->GetTimeSinceStart() - fMaxSecondsBack;
|
||||
|
||||
int sequence_index = iNumButtons-1; // count down
|
||||
for( int queue_index=m_aQueue[p].GetSize()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest
|
||||
for( int queue_index=m_aQueue[c].GetSize()-1; queue_index>=0; queue_index-- ) // iterate newest to oldest
|
||||
{
|
||||
MenuButtonAndTime BandT = m_aQueue[p][queue_index];
|
||||
GameButtonAndTime BandT = m_aQueue[c][queue_index];
|
||||
if( BandT.button != button_sequence[sequence_index] ||
|
||||
BandT.fTime < fOldestTimeAllowed )
|
||||
{
|
||||
@@ -51,7 +52,7 @@ bool InputQueue::MatchesPattern( const PlayerNumber p, const MenuButton* button_
|
||||
}
|
||||
if( sequence_index == 0 ) // we matched the whole pattern
|
||||
{
|
||||
m_aQueue[p].RemoveAll(); // empty the queue so we don't match on it again
|
||||
m_aQueue[c].RemoveAll(); // empty the queue so we don't match on it again
|
||||
return true;
|
||||
}
|
||||
sequence_index--;
|
||||
|
||||
Reference in New Issue
Block a user