generalize CodeNames

This commit is contained in:
Glenn Maynard
2007-03-16 23:33:41 +00:00
parent 8857adfd8b
commit 1189f94ede
7 changed files with 40 additions and 76 deletions
+1 -1
View File
@@ -33,6 +33,7 @@ RepeatDelay=-1
PrepareScreens=
PersistScreens=
GroupedScreens=
CodeNames=""
CancelCancelCommand=
ShowCoinsAndCredits=true
@@ -1879,7 +1880,6 @@ TimerOnCommand=draworder,97;spring,0.5;addx,-SCREEN_WIDTH
TimerOffCommand=bouncebegin,0.5;addx,SCREEN_WIDTH;
TimerStealth=false
ForceTimer=false
CodeNames=""
FirstUpdateCommand=
PlayMusic=true
StopMusicOnBack=true
+35
View File
@@ -13,6 +13,8 @@
#define PREPARE_SCREENS THEME->GetMetric (m_sName,"PrepareScreens")
#define PERSIST_SCREENS THEME->GetMetric (m_sName,"PersistScreens")
#define GROUPED_SCREENS THEME->GetMetric (m_sName,"GroupedScreens")
#define CODE_NAMES THEME->GetMetric (m_sName,"CodeNames")
#define CODE( s ) THEME->GetMetric (m_sName,ssprintf("Code%s",s.c_str()))
void Screen::InitScreen( Screen *pScreen )
{
@@ -36,6 +38,28 @@ void Screen::Init()
REPEAT_RATE.Load( m_sName, "RepeatRate" );
REPEAT_DELAY.Load( m_sName, "RepeatDelay" );
//
// Load codes
//
{
split( CODE_NAMES, ",", m_asCodeNames, true );
for( unsigned c=0; c<m_asCodeNames.size(); c++ )
{
vector<RString> asBits;
split( m_asCodeNames[c], "=", asBits, true );
RString sCodeName = asBits[0];
if( asBits.size() > 1 )
m_asCodeNames[c] = asBits[1];
InputQueueCode code;
if( !code.Load(CODE(sCodeName)) )
continue;
m_aCodes.push_back( code );
}
}
SetFOV( 0 );
m_smSendOnPop = SM_None;
@@ -160,6 +184,17 @@ bool Screen::OverlayInput( const InputEventPlus &input )
void Screen::Input( const InputEventPlus &input )
{
for( unsigned i = 0; i < m_aCodes.size(); ++i )
{
if( !m_aCodes[i].EnteredCode(input.GameI.controller) )
continue;
Message msg("Code");
msg.SetParam( "PlayerNumber", input.pn );
msg.SetParam( "Name", m_asCodeNames[i] );
this->HandleMessage( msg );
}
/* Don't send release messages with the default handler. */
switch( input.type )
{
+4
View File
@@ -8,6 +8,7 @@
#include "InputFilter.h"
#include "ThemeMetric.h"
#include "PlayerNumber.h"
#include "InputQueue.h"
class InputEventPlus;
class Screen;
@@ -71,6 +72,9 @@ protected:
vector<QueuedScreenMessage> m_QueuedMessages;
static bool SortMessagesByDelayRemaining(const QueuedScreenMessage &m1, const QueuedScreenMessage &m2);
vector<InputQueueCode> m_aCodes;
vector<RString> m_asCodeNames;
ThemeMetric<bool> ALLOW_OPERATOR_MENU_BUTTON;
ThemeMetric<float> REPEAT_RATE;
ThemeMetric<float> REPEAT_DELAY;
@@ -15,9 +15,6 @@
REGISTER_SCREEN_CLASS( ScreenNameEntryTraditional );
#define CODE_NAMES THEME->GetMetric (m_sName,"CodeNames")
#define CODE( s ) THEME->GetMetric (m_sName,ssprintf("Code%s",s.c_str()))
void ScreenNameEntryTraditional::Init()
{
if( PREFSMAN->m_bScreenTestMode )
@@ -70,28 +67,6 @@ void ScreenNameEntryTraditional::Init()
}
MAX_RANKING_NAME_LENGTH.Load( m_sName, "MaxRankingNameLength" );
//
// Load codes
//
{
split( CODE_NAMES, ",", m_asCodeNames, true );
for( unsigned c=0; c<m_asCodeNames.size(); c++ )
{
vector<RString> asBits;
split( m_asCodeNames[c], "=", asBits, true );
RString sCodeName = asBits[0];
if( asBits.size() > 1 )
m_asCodeNames[c] = asBits[1];
InputQueueCode code;
if( !code.Load(CODE(sCodeName)) )
continue;
m_aCodes.push_back( code );
}
}
ScreenWithMenuElements::Init();
}
@@ -167,17 +142,6 @@ void ScreenNameEntryTraditional::Input( const InputEventPlus &input )
if( IsTransitioning() )
return;
for( unsigned i = 0; i < m_aCodes.size(); ++i )
{
if( !m_aCodes[i].EnteredCode(input.GameI.controller) )
continue;
Message msg("Code");
msg.SetParam( "PlayerNumber", input.pn );
msg.SetParam( "Name", m_asCodeNames[i] );
this->HandleMessage( msg );
}
ScreenWithMenuElements::Input( input );
}
@@ -33,8 +33,6 @@ public:
void SelectChar( PlayerNumber pn, const RString &sKey );
ThemeMetric<int> MAX_RANKING_NAME_LENGTH;
vector<InputQueueCode> m_aCodes;
vector<RString> m_asCodeNames;
wstring m_sSelection[NUM_PLAYERS];
bool m_bEnteringName[NUM_PLAYERS];
-34
View File
@@ -12,9 +12,6 @@
#define CHOICE_NAMES THEME->GetMetric (m_sName,"ChoiceNames")
#define CHOICE( s ) THEME->GetMetric (m_sName,ssprintf("Choice%s",s.c_str()))
#define CODE_NAMES THEME->GetMetric (m_sName,"CodeNames")
#define CODE( s ) THEME->GetMetric (m_sName,ssprintf("Code%s",s.c_str()))
#define CODE_ACTION( s ) THEME->GetMetric (m_sName,ssprintf("Code%sAction",s.c_str()))
#define IDLE_TIMEOUT_SCREEN THEME->GetMetric (m_sName,"IdleTimeoutScreen")
#define UPDATE_ON_MESSAGE THEME->GetMetric (m_sName,"UpdateOnMessage")
@@ -57,29 +54,6 @@ void ScreenSelect::Init()
}
}
//
// Load codes
//
{
vector<RString> vsCodeNames;
split( CODE_NAMES, ",", vsCodeNames, true );
for( unsigned c=0; c<vsCodeNames.size(); c++ )
{
RString sCodeName = vsCodeNames[c];
InputQueueCode code;
if( !code.Load( CODE(sCodeName) ) )
continue;
m_aCodes.push_back( code );
GameCommand mc;
Commands cmd = ParseCommands( CODE_ACTION(sCodeName) );
mc.Load( c, cmd );
m_aCodeChoices.push_back( mc );
}
}
if( !m_aGameCommands.size() )
RageException::Throw( "Screen \"%s\" does not set any choices.", m_sName.c_str() );
}
@@ -163,14 +137,6 @@ void ScreenSelect::Input( const InputEventPlus &input )
if( IsTransitioning() )
return;
for( unsigned i = 0; i < m_aCodes.size(); ++i )
{
if( !m_aCodes[i].EnteredCode( input.GameI.controller ) )
continue;
LOG->Trace("entered code for index %d", i);
m_aCodeChoices[i].Apply( input.pn );
}
ScreenWithMenuElements::Input( input ); // default input handler
}
-3
View File
@@ -5,7 +5,6 @@
#include "ScreenWithMenuElements.h"
#include "GameCommand.h"
#include "InputQueue.h"
#include "ThemeMetric.h"
class ScreenSelect : public ScreenWithMenuElements
@@ -28,8 +27,6 @@ protected:
vector<GameCommand> m_aGameCommands; // derived classes should look here for what choices are available
vector<InputQueueCode> m_aCodes;
vector<GameCommand> m_aCodeChoices;
vector<RString> m_asSubscribedMessages;
RageTimer m_timerIdleComment; // count up to time between idle comment announcer sounds