add OptionRowHandlerGameCommand to cut out unnecessary level of indirection in metrics

This commit is contained in:
Chris Danford
2005-12-06 04:25:52 +00:00
parent 1c0dc2aad8
commit 00b346939d
9 changed files with 238 additions and 264 deletions
@@ -0,0 +1 @@
_Arial 14 shadow
@@ -0,0 +1 @@
_blank
+57 -126
View File
@@ -2114,7 +2114,7 @@ MeterX=SCREEN_CENTER_X+170
MeterY=SCREEN_CENTER_Y-20
SourceMeterX=SCREEN_CENTER_X+170
SourceMeterY=SCREEN_CENTER_Y+60
RowLabelsX=SCREEN_LEFT+40
RowTitleX=SCREEN_LEFT+40
RowLabelOnCommand=zoom,0.7
RowValue1X=SCREEN_CENTER_X
RowValue2X=SCREEN_CENTER_X+60
@@ -2435,9 +2435,6 @@ RowInitCommand=
RowOnCommand=
RowOffCommand=
RowPositionTransformFunction=function(self,positionIndex,itemIndex,numItems) self:y(SCREEN_CENTER_Y-152+34*positionIndex) end
RowOffScreenTopTransformFunction=function(self,positionIndex,itemIndex,numItems) self:y(SCREEN_CENTER_Y-152+34*(-0.5)) end
RowOffScreenCenterTransformFunction=function(self,positionIndex,itemIndex,numItems) self:y(SCREEN_CENTER_Y-152+34*(4.5)) end
RowOffScreenBottomTransformFunction=function(self,positionIndex,itemIndex,numItems) self:y(SCREEN_CENTER_Y-152+34*(9.5)) end
ExplanationP1X=SCREEN_CENTER_X-250
ExplanationP1Y=SCREEN_CENTER_Y+172
ExplanationP2X=SCREEN_CENTER_X+250
@@ -2493,10 +2490,10 @@ IconsP1X=SCREEN_CENTER_X-280
IconsP2X=SCREEN_CENTER_X+280
BulletX=SCREEN_CENTER_X-232
BulletOnCommand=
LabelsX=SCREEN_CENTER_X-180
LabelsOnCommand=zoom,0.7;horizalign,right;ShadowLength,0
LabelGainFocusCommand=
LabelLoseFocusCommand=
TitleX=SCREEN_CENTER_X-180
TitleOnCommand=zoom,0.7;horizalign,right;ShadowLength,0
TitleGainFocusCommand=
TitleLoseFocusCommand=
ItemsStartX=SCREEN_CENTER_X-160
ItemsEndX=SCREEN_CENTER_X+280
ItemsGapX=14
@@ -3595,7 +3592,7 @@ CourseBannerX=SCREEN_CENTER_X+170
CourseBannerY=SCREEN_CENTER_Y-170
CourseBannerWidth=130
CourseBannerHeight=40
RowLabelsX=SCREEN_CENTER_X-300
RowTitleX=SCREEN_CENTER_X-300
RowValue1X=SCREEN_CENTER_X+0
RowValue2X=SCREEN_CENTER_X+60
RowValue3X=SCREEN_CENTER_X+60
@@ -3616,9 +3613,16 @@ Row8Y=SCREEN_CENTER_Y+120
[EditCoursesSongMenu]
Fallback=EditCoursesMenu
[ScreenOptionsSimple]
Fallback=ScreenOptionsMaster
TitleX=SCREEN_CENTER_X-180
TitleOnCommand=zoom,0.5;horizalign,left;ShadowLength,0
TitleGainFocusCommand=diffuseshift;EffectColor1,1.3,1.3,1.3,1;EffectColor2,0.3,0.3,0.3,1
TitleLoseFocusCommand=stopeffect
[ScreenOptionsService]
Class=ScreenOptionsMaster
Fallback=ScreenOptions
Fallback=ScreenOptionsSimple
NextScreen=@ScreenTitleBranch()
PrevScreen=@ScreenTitleBranch()
# "Rows" sets the number of rows; this field is required.
@@ -3637,34 +3641,38 @@ PrevScreen=@ScreenTitleBranch()
IconsOnCommand=x,-30
Fallback=ScreenOptionsMaster
TimerOnCommand=hidden,1
StyleIcon=0
TimerSeconds=0
AllowOperatorMenuButton=0
LineNames=1,2,3,4,5,6,7,8,9,10,12,13,14,15,16,17
LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
OptionMenuFlags=together;forceallplayers;smnavigation
# This NextScreen is only used for the "exit" choice.
Line1=list,Appearance Options
Line2=list,Background Options
Line3=list,Bookkeeping
Line4=list,Center Image
Line5=list,Coin Options
Line6=list,Config Key/Joy Mappings
Line7=list,Input Options
Line8=list,Gameplay Options
Line9=list,Graphic Options
Line10=list,Machine Options
Line12=list,Sound Options
Line13=list,Profiles
Line14=list,Other Options
Line15=list,Network Options
Line16=list,Reload Songs/Courses
Line17=list,Test Input
Line1=gamecommand;screen,ScreenAppearanceOptions;name,Appearance Options
Line2=gamecommand;screen,ScreenBackgroundOptions;name,Background Options
Line3=gamecommand;screen,ScreenCenterImage;name,Center Image
Line4=gamecommand;screen,ScreenCoinOptions;name,Coin Options
Line5=gamecommand;screen,ScreenMapControllers;name,Key Joy Mappings
Line6=gamecommand;screen,ScreenInputOptions;name,Input Options
Line7=gamecommand;screen,ScreenGameplayOptions;name,Gameplay Options
Line8=gamecommand;screen,ScreenGraphicOptions;name,Graphic Options
Line9=gamecommand;screen,ScreenMachineOptions;name,Machine Options
Line10=gamecommand;screen,ScreenSoundOptions;name,Sound Options
Line11=gamecommand;screen,ScreenOptionsManageProfiles;name,Profiles
Line12=gamecommand;screen,ScreenOtherOptions;name,Other Options
Line13=gamecommand;screen,ScreenNetworkOptions;name,Network Options
Line14=gamecommand;screen,ScreenReloadSongs;name,Reload Songs
Line15=gamecommand;screen,ScreenTestInput;name,Test Input
[ScreenOptionsServiceChild]
Fallback=ScreenOptionsService
Fallback=ScreenOptionsMaster
IconsOnCommand=x,-30
TimerOnCommand=hidden,1
StyleIcon=0
TimerSeconds=0
AllowOperatorMenuButton=0
OptionMenuFlags=together;forceallplayers;smnavigation
PrevScreen=ScreenOptionsService
NextScreen=ScreenOptionsService
@@ -3865,6 +3873,7 @@ HelperY=SCREEN_CENTER_Y+80
[ScreenOptionsMaster]
Fallback=ScreenOptions
Class=ScreenOptionsMaster
# Player options
Speed=12
@@ -4023,98 +4032,23 @@ SaveScoresDefault=
SaveScores,1=mod,no savescore;name,Off
SaveScores,2=mod,savescore;name,On
# ScreenOptionsService
Appearance Options=1;together;SelectNone
Appearance OptionsDefault=
Appearance Options,1=screen,ScreenAppearanceOptions;name,Appearance Options
Other Options=1;together;SelectNone
Other OptionsDefault=
Other Options,1=screen,ScreenOtherOptions;name,Other Options
Background Options=1;together;SelectNone
Background OptionsDefault=
Background Options,1=screen,ScreenBackgroundOptions;name,Background Options
Bookkeeping=1;together;SelectNone
BookkeepingDefault=
Bookkeeping,1=screen,ScreenBookkeeping;name,Bookkeeping
Clear Bookkeeping Data=1;together;SelectNone
Clear Bookkeeping DataDefault=
Clear Bookkeeping Data,1=ClearBookkeepingData;name,Clear Bookkeeping Data
Center Image=1;together;SelectNone
Center ImageDefault=
Center Image,1=screen,ScreenCenterImage;name,Center Image
Coin Options=1;together;SelectNone
Coin OptionsDefault=
Coin Options,1=screen,ScreenCoinOptions;name,Coin Options
Config Key/Joy Mappings=1;together;SelectNone
Config Key/Joy MappingsDefault=
Config Key/Joy Mappings,1=screen,ScreenMapControllers;name,Key Joy Mappings
Clear Machine Stats=1;together;SelectNone
Clear Machine StatsDefault=
Clear Machine Stats,1=ClearMachineStats;screen,ScreenOptionsService;name,Clear Machine Stats
Clear Machine Edits=1;together;SelectNone
Clear Machine EditsDefault=
Clear Machine Edits,1=ClearMachineEdits;screen,ScreenOptionsService;name,Clear Machine Edits
Fill Machine Stats=1;together;SelectNone
Fill Machine StatsDefault=
Fill Machine Stats,1=screen,ScreenOptionsService;FillMachineStats;name,Fill Machine Stats
Input Options=1;together;SelectNone
Input OptionsDefault=
Input Options,1=screen,ScreenInputOptions;name,Input Options
Insert Credit=1;together;SelectNone
Insert CreditDefault=
Insert Credit,1=screen,ScreenOptionsService;InsertCredit;name,Insert Credit
Gameplay Options=1;together;SelectNone
Gameplay OptionsDefault=
Gameplay Options,1=screen,ScreenGameplayOptions;name,Gameplay Options
Graphic Options=1;together;SelectNone
Graphic OptionsDefault=
Graphic Options,1=screen,ScreenGraphicOptions;name,Graphic Options
Machine Options=1;together;SelectNone
Machine OptionsDefault=
Machine Options,1=screen,ScreenMachineOptions;name,Machine Options
Sound Options=1;together;SelectNone
Sound OptionsDefault=
Sound Options,1=screen,ScreenSoundOptions;name,Sound Options
Profiles=1;together;SelectNone
ProfilesDefault=
Profiles,1=screen,ScreenOptionsManageProfiles;name,Profiles
Reload Songs/Courses=1;together;SelectNone
Reload Songs/CoursesDefault=
Reload Songs/Courses,1=screen,ScreenReloadSongs;name,Reload Songs
Reset To Defaults=1;together;SelectNone
Reset To DefaultsDefault=
Reset To Defaults,1=ResetToFactoryDefaults;screen,ScreenOptionsService;name,Reset To Defaults
Test Input=1;together;SelectNone
Test InputDefault=
Test Input,1=screen,ScreenTestInput;name,Test Input
Test Lights=1;together;SelectNone
Test LightsDefault=
Test Lights,1=screen,ScreenTestLights;name,Test Lights
Transfer Stats From Machine=1;together;SelectNone
Transfer Stats From MachineDefault=
Transfer Stats From Machine,1=TransferStatsFromMachine;screen,ScreenOptionsService;name,Transfer Stats From Machine
Transfer Stats To Machine=1;together;SelectNone
Transfer Stats To MachineDefault=
Transfer Stats To Machine,1=TransferStatsToMachine;screen,ScreenOptionsService;name,Transfer Stats To Machine
Copy Edits To Machine=1;together;SelectNone
Copy Edits To MachineDefault=
Copy Edits To Machine,1=CopyEditsToMachine;screen,ScreenOptionsService;name,Copy Edits To Machine
Copy Edits From Machine=1;together;SelectNone
Copy Edits From MachineDefault=
Copy Edits From Machine,1=CopyEditsFromMachine;screen,ScreenOptionsService;name,Copy Edits From Machine
Set Machine Time=1;together;SelectNone
Set Machine TimeDefault=
Set Machine Time,1=screen,ScreenSetTime;name,Set Machine Time
Network Options=1;together;SelectNone
Network OptionsDefault=
Network Options,1=screen,ScreenNetworkOptions;name,Network Options
#ScreenJukeboxMenu
RandomModifiers=2;together
RandomModifiersDefault=mod,clear
RandomModifiers,1=name,Off
RandomModifiers,2=mod,random;name,Random
# ScreenOptionsEditMode
Edit Steps=1;together;SelectNone
Edit StepsDefault=
Edit Steps,1=screen,ScreenOptionsManageEditSteps;name,Transfer To USB Drive
Transfer To USB Drive=1;together;SelectNone
Transfer To USB DriveDefault=
Transfer To USB Drive,1=screen,ScreenOptionsManageEditSteps;name,Transfer To USB Drive
Transfer From USB Drive=1;together;SelectNone
Transfer From USB DriveDefault=
Transfer From USB Drive,1=screen,ScreenOptionsManageEditSteps;name,Transfer From USB Drive
[ScreenReloadSongs]
Class=ScreenReloadSongs
Fallback=Screen
@@ -4317,8 +4251,8 @@ IconsP1X=SCREEN_CENTER_X-280
IconsP2X=SCREEN_CENTER_X+280
IconsOnCommand=x,-30
BulletX=SCREEN_CENTER_X-232
LabelsX=SCREEN_CENTER_X-150
LabelsOnCommand=zoom,0.5;horizalign,left;ShadowLength,2
TitleX=SCREEN_CENTER_X-150
TitleOnCommand=zoom,0.5;horizalign,left;ShadowLength,2
ItemsStartX=SCREEN_CENTER_X-160
ItemsEndX=SCREEN_CENTER_X+280
ItemsGapX=14
@@ -4339,7 +4273,7 @@ ColorDisabled=1,1,1,1
[ScreenMiniMenuMainMenu]
Fallback=ScreenMiniMenu
LabelsX=SCREEN_CENTER_X-80
TitleX=SCREEN_CENTER_X-80
[ScreenMiniMenuAreaMenu]
Fallback=ScreenMiniMenu
@@ -4445,11 +4379,11 @@ Fallback=ScreenMiniMenu
NumRowsShown=10
RowPositionTransformFunction=function(self,positionIndex,itemIndex,numItems) self:y(24*(positionIndex-(numItems-1)/2)) end
ItemsLongRowSharedX=0
LabelsX=0
LabelsX=-54
LabelsOnCommand=zoom,0.7;horizalign,left;ShadowLength,2
LabelGainFocusCommand=diffuseshift;EffectColor1,0.3,0.3,0.3,1;EffectColor2,1.3,1.3,1.3,1
LabelLoseFocusCommand=stopeffect
TitleX=0
TitleX=-54
TitleOnCommand=zoom,0.7;horizalign,left;ShadowLength,2
TitleGainFocusCommand=diffuseshift;EffectColor1,0.3,0.3,0.3,1;EffectColor2,1.3,1.3,1.3,1
TitleLoseFocusCommand=stopeffect
ItemsStartX=0
LineHighlightX=0
HelpText=
@@ -4460,9 +4394,6 @@ Fallback=ScreenGameplay DifficultyMeterP1
[ScreenJukebox DifficultyMeterP2]
Fallback=ScreenGameplay DifficultyMeterP2
[ScreenOptionsSimple]
Fallback=ScreenOptions
[ScreenOptionsManageCourses]
Class=ScreenOptionsManageCourses
Fallback=ScreenOptionsSimple
+9
View File
@@ -4,6 +4,7 @@
#include "RageLog.h"
#include "arch/Dialog/Dialog.h"
#include "LuaManager.h"
#include "Foreach.h"
void IncorrectNumberArgsWarning( const Command &command, int iMaxIndexAccessed )
@@ -115,6 +116,14 @@ static void SplitWithQuotes( const CString sSource, const char Delimitor, vector
} while( startpos <= sSource.size() );
}
CString Commands::GetOriginalCommandString() const
{
CString s;
FOREACH_CONST( Command, v, c )
s += c->GetOriginalCommandString();
return s;
}
void ParseCommands( const CString &sCommands, Commands &vCommandsOut )
{
CStringArray vsCommands;
+2
View File
@@ -33,6 +33,8 @@ class Commands
{
public:
vector<Command> v;
CString GetOriginalCommandString() const; // used when reporting an error in number of args
};
// Take a command list string and return pointers to each of the tokens in the
+143 -84
View File
@@ -19,6 +19,7 @@
#include "GameSoundManager.h"
#include "CommonMetrics.h"
#include "CharacterManager.h"
#include "ScreenManager.h"
#define ENTRY(s) THEME->GetMetric ("ScreenOptionsMaster",s)
#define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1)))
@@ -71,8 +72,12 @@ public:
m_bUseModNameForIcon = false;
m_vsBroadcastOnExport.clear();
}
virtual void Load( OptionRowDefinition &defOut, CString sParam )
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() == 1 );
const Command &command = cmds.v[0];
CString sParam = command.GetArg(1);
ASSERT( command.m_vsArgs.size() == 2 );
ASSERT( sParam.size() );
if( sParam.CompareNoCase("NoteSkins")==0 ) { FillNoteSkins( defOut, sParam ); return; }
@@ -93,70 +98,72 @@ public:
Default.Load( -1, ParseCommands(ENTRY_DEFAULT(sParam)) );
/* Parse the basic configuration metric. */
Commands cmds = ParseCommands( ENTRY(sParam) );
if( cmds.v.size() < 1 )
RageException::Throw( "Parse error in ScreenOptionsMaster::%s", sParam.c_str() );
defOut.m_bOneChoiceForAllPlayers = false;
const int NumCols = atoi( cmds.v[0].m_vsArgs[0] );
for( unsigned i=1; i<cmds.v.size(); i++ )
{
const Command &cmd = cmds.v[i];
CString sName = cmd.GetName();
/* Parse the basic configuration metric. */
Commands cmds = ParseCommands( ENTRY(sParam) );
if( cmds.v.size() < 1 )
RageException::Throw( "Parse error in ScreenOptionsMaster::%s", sParam.c_str() );
if( sName == "together" ) defOut.m_bOneChoiceForAllPlayers = true;
else if( sName == "selectmultiple" ) defOut.m_selectType = SELECT_MULTIPLE;
else if( sName == "selectone" ) defOut.m_selectType = SELECT_ONE;
else if( sName == "selectnone" ) defOut.m_selectType = SELECT_NONE;
else if( sName == "showoneinrow" ) defOut.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
else if( sName == "reloadrowmessages" )
defOut.m_bOneChoiceForAllPlayers = false;
const int NumCols = atoi( cmds.v[0].m_vsArgs[0] );
for( unsigned i=1; i<cmds.v.size(); i++ )
{
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
m_vsReloadRowMessages.push_back( cmd.m_vsArgs[a] );
}
else if( sName == "enabledforplayers" )
{
defOut.m_vEnabledForPlayers.clear();
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
const Command &cmd = cmds.v[i];
CString sName = cmd.GetName();
if( sName == "together" ) defOut.m_bOneChoiceForAllPlayers = true;
else if( sName == "selectmultiple" ) defOut.m_selectType = SELECT_MULTIPLE;
else if( sName == "selectone" ) defOut.m_selectType = SELECT_ONE;
else if( sName == "selectnone" ) defOut.m_selectType = SELECT_NONE;
else if( sName == "showoneinrow" ) defOut.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
else if( sName == "reloadrowmessages" )
{
CString sArg = cmd.m_vsArgs[a];
PlayerNumber pn = (PlayerNumber)(atoi(sArg)-1);
ASSERT( pn >= 0 && pn < NUM_PLAYERS );
defOut.m_vEnabledForPlayers.insert( pn );
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
m_vsReloadRowMessages.push_back( cmd.m_vsArgs[a] );
}
else if( sName == "enabledforplayers" )
{
defOut.m_vEnabledForPlayers.clear();
for( unsigned a=1; a<cmd.m_vsArgs.size(); a++ )
{
CString sArg = cmd.m_vsArgs[a];
PlayerNumber pn = (PlayerNumber)(atoi(sArg)-1);
ASSERT( pn >= 0 && pn < NUM_PLAYERS );
defOut.m_vEnabledForPlayers.insert( pn );
}
}
else if( sName == "exportonchange" ) defOut.m_bExportOnChange = true;
else if( sName == "broadcastonexport" )
{
for( unsigned i=1; i<cmd.m_vsArgs.size(); i++ )
m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[i] );
}
else RageException::Throw( "Unkown row flag \"%s\"", sName.c_str() );
}
else if( sName == "exportonchange" ) defOut.m_bExportOnChange = true;
else if( sName == "broadcastonexport" )
for( int col = 0; col < NumCols; ++col )
{
for( unsigned i=1; i<cmd.m_vsArgs.size(); i++ )
m_vsBroadcastOnExport.push_back( cmd.m_vsArgs[i] );
GameCommand mc;
mc.Load( 0, ParseCommands(ENTRY_MODE(sParam, col)) );
/* If the row has just one entry, use the name of the row as the name of the
* entry. If it has more than one, each one must be specified explicitly. */
if( mc.m_sName == "" && NumCols == 1 )
mc.m_sName = sParam;
if( mc.m_sName == "" )
RageException::Throw( "List \"%s\", col %i has no name", sParam.c_str(), col );
if( !mc.IsPlayable() )
{
LOG->Trace( "\"%s\" is not playable.", sParam.c_str() );
continue;
}
ListEntries.push_back( mc );
CString sName = mc.m_sName;
CString sChoice = mc.m_sName;
defOut.m_vsChoices.push_back( sChoice );
}
else RageException::Throw( "Unkown row flag \"%s\"", sName.c_str() );
}
for( int col = 0; col < NumCols; ++col )
{
GameCommand mc;
mc.Load( 0, ParseCommands(ENTRY_MODE(sParam, col)) );
/* If the row has just one entry, use the name of the row as the name of the
* entry. If it has more than one, each one must be specified explicitly. */
if( mc.m_sName == "" && NumCols == 1 )
mc.m_sName = sParam;
if( mc.m_sName == "" )
RageException::Throw( "List \"%s\", col %i has no name", sParam.c_str(), col );
if( !mc.IsPlayable() )
{
LOG->Trace( "\"%s\" is not playable.", sParam.c_str() );
continue;
}
ListEntries.push_back( mc );
CString sName = mc.m_sName;
CString sChoice = mc.m_sName;
defOut.m_vsChoices.push_back( sChoice );
}
}
void ImportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
@@ -213,7 +220,7 @@ public:
{
if( iFallbackOption == -1 )
{
CString s = ssprintf("No options in row \"%s\" were selected, and no fallback row found; selected entry 0", m_sName.c_str());
CString s = ssprintf("No options in row \"%s\" were selected, and no fallback row found; selected entry 0", m_cmds.v[0].GetName().c_str());
LOG->Warn( s );
CHECKPOINT_M( s );
iFallbackOption = 0;
@@ -265,7 +272,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_sName = "NoteSkins";
defOut.m_bOneChoiceForAllPlayers = false;
@@ -290,7 +296,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_sName = "Steps";
defOut.m_bOneChoiceForAllPlayers = bLockedTogether;
@@ -352,7 +357,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = false;
defOut.m_bAllowThemeItems = false;
@@ -387,7 +391,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_sName = "Style";
@@ -413,7 +416,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_bAllowThemeItems = false; // we theme the text ourself
@@ -446,7 +448,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_sName = "Difficulty";
@@ -477,7 +478,6 @@ public:
defOut.Init();
ASSERT( sParam.size() );
m_sName = sParam;
vector<Song*> vpSongs;
SONGMAN->GetSongs( vpSongs, GAMESTATE->m_sPreferredSongGroup );
@@ -512,14 +512,17 @@ public:
OptionRowHandler::Init();
m_pLuaTable->Unset();
}
virtual void Load( OptionRowDefinition &defOut, CString sLuaFunction )
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() == 1 );
const Command &command = cmds.v[0];
ASSERT( command.m_vsArgs.size() == 2 );
CString sLuaFunction = command.m_vsArgs[1];
ASSERT( sLuaFunction.size() );
Init();
defOut.Init();
m_sName = sLuaFunction;
defOut.m_bAllowThemeItems = false; // Lua options are always dynamic and can theme themselves.
Lua *L = LUA->Get();
@@ -660,15 +663,17 @@ public:
LUA->Release(L);
}
virtual void Reload( OptionRowDefinition &defOut )
virtual void ReLoadInternal( OptionRowDefinition &defOut )
{
Lua *L = LUA->Get();
/* Run the Lua expression. It should return a table. */
m_pLuaTable->SetFromExpression( m_sName );
const Command &command = m_cmds.v[0];
CString sName = command.m_vsArgs[0];
m_pLuaTable->SetFromExpression( sName );
if( m_pLuaTable->GetLuaType() != LUA_TTABLE )
RageException::Throw( "Result of \"%s\" is not a table", m_sName.c_str() );
RageException::Throw( "Result of \"%s\" is not a table", sName.c_str() );
m_pLuaTable->PushSelf( L );
@@ -679,7 +684,7 @@ public:
if( !lua_isnil( L, -1 ) )
{
if( !lua_istable( L, -1 ) )
RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", m_sName.c_str() );
RageException::Throw( "\"%s\" \"EnabledForPlayers\" is not a table", sName.c_str() );
defOut.m_vEnabledForPlayers.clear(); // and fill in with supplied PlayerNumbers below
@@ -825,8 +830,12 @@ public:
OptionRowHandler::Init();
opt = NULL;
}
virtual void Load( OptionRowDefinition &defOut, CString sParam )
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() == 1 );
const Command &command = cmds.v[0];
CString sParam = command.GetArg(1);
ASSERT( command.m_vsArgs.size() == 2 );
ASSERT( sParam.size() );
Init();
@@ -902,8 +911,12 @@ public:
m_vStepsTypesToShow.clear();
}
virtual void Load( OptionRowDefinition &defOut, CString sParam )
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() == 1 );
const Command &command = cmds.v[0];
CString sParam = command.GetArg(1);
ASSERT( command.m_vsArgs.size() == 2 );
ASSERT( sParam.size() );
Init();
@@ -926,7 +939,6 @@ public:
RageException::Throw( "invalid StepsType param \"%s\"", sParam.c_str() );
}
m_sName = sParam;
defOut.m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
@@ -1001,8 +1013,12 @@ public:
m_vDifficulties.clear();
}
virtual void Load( OptionRowDefinition &defOut, CString sParam )
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() == 1 );
const Command &command = cmds.v[0];
CString sParam = command.GetArg(1);
ASSERT( command.m_vsArgs.size() == 2 );
ASSERT( sParam.size() );
Init();
@@ -1028,7 +1044,6 @@ public:
RageException::Throw( "invalid StepsType param \"%s\"", sParam.c_str() );
}
m_sName = sParam;
defOut.m_sName = sParam;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
@@ -1049,7 +1064,7 @@ public:
GAMESTATE->m_pCurSong->GetSteps( m_vSteps, *m_pst, DIFFICULTY_EDIT );
m_vDifficulties.resize( m_vSteps.size(), DIFFICULTY_EDIT );
if( m_sName == "EditSteps" )
if( sParam == "EditSteps" )
{
m_vSteps.push_back( NULL );
m_vDifficulties.push_back( DIFFICULTY_EDIT );
@@ -1142,25 +1157,69 @@ public:
}
};
class OptionRowHandlerGameCommand : public OptionRowHandler
{
public:
GameCommand m_gc;
OptionRowHandlerGameCommand::OptionRowHandlerGameCommand() { Init(); }
void Init()
{
m_gc.Init();
}
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds )
{
ASSERT( cmds.v.size() > 1 );
Init();
defOut.Init();
Commands temp = cmds;
temp.v.erase( temp.v.begin() );
m_gc.Load( 0, temp );
ASSERT( !m_gc.m_sName.empty() );
defOut.m_sName = m_gc.m_sName;
defOut.m_bOneChoiceForAllPlayers = true;
defOut.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW;
defOut.m_selectType = SELECT_NONE;
defOut.m_vsChoices.push_back( "" );
}
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{
}
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{
if( vbSelected[PLAYER_1][0] )
m_gc.ApplyToAllPlayers();
return 0;
}
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
sIconTextOut = "";
gcOut = m_gc;
}
virtual bool HasScreen( int iChoice ) const
{
return !m_gc.m_sScreen.empty();
}
};
///////////////////////////////////////////////////////////////////////////////////
OptionRowHandler* OptionRowHandlerUtil::Make( const Command &command, OptionRowDefinition &defOut )
OptionRowHandler* OptionRowHandlerUtil::Make( const Commands &cmds, OptionRowDefinition &defOut )
{
OptionRowHandler* pHand = NULL;
BeginHandleArgs;
const CString &name = cmds.v[0].GetName();
const CString &name = command.GetName();
#define MAKE( type ) { type *p = new type; p->Load( defOut, sArg(1) ); pHand = p; }
#define MAKE( type ) { type *p = new type; p->Load( defOut, cmds ); pHand = p; }
if( name == "list" ) MAKE( OptionRowHandlerList )
else if( name == "lua" ) MAKE( OptionRowHandlerLua )
else if( name == "conf" ) MAKE( OptionRowHandlerConfig )
else if( name == "stepstype" ) MAKE( OptionRowHandlerStepsType )
else if( name == "steps" ) MAKE( OptionRowHandlerSteps )
EndHandleArgs;
else if( name == "gamecommand" ) MAKE( OptionRowHandlerGameCommand )
return pHand;
}
+10 -5
View File
@@ -13,18 +13,23 @@ struct ConfOption;
class OptionRowHandler
{
public:
CString m_sName;
Commands m_cmds;
vector<CString> m_vsReloadRowMessages; // refresh this row on on these messages
OptionRowHandler::OptionRowHandler() { Init(); }
virtual ~OptionRowHandler() { }
virtual void Init()
{
m_sName = "";
m_cmds.v.clear();
m_vsReloadRowMessages.clear();
}
virtual void Load( OptionRowDefinition &defOut, CString sParam ) = 0;
virtual void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_sName); }
virtual void Load( OptionRowDefinition &defOut, const Commands &cmds )
{
m_cmds = cmds;
this->LoadInternal( defOut, cmds );
}
virtual void LoadInternal( OptionRowDefinition &defOut, const Commands &cmds ) = 0;
virtual void Reload( OptionRowDefinition &defOut ) { this->Load(defOut,m_cmds); }
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const = 0;
/* Returns an OPT mask. */
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const = 0;
@@ -35,7 +40,7 @@ public:
namespace OptionRowHandlerUtil
{
OptionRowHandler* Make( const Command &cmd, OptionRowDefinition &defOut );
OptionRowHandler* Make( const Commands &cmds, OptionRowDefinition &defOut );
}
inline void VerifySelected( SelectType st, const vector<bool> &vbSelected, const CString &sName )
+11 -42
View File
@@ -72,34 +72,6 @@ static bool ValidateLocalProfileName( const CString &sAnswer, CString &sErrorOut
return true;
}
class OptionRowHandlerSimple : public OptionRowHandler
{
public:
GameCommand m_gc;
virtual void Load( OptionRowDefinition &defOut, CString sParam )
{
}
virtual void ImportOption( const OptionRowDefinition &row, const vector<PlayerNumber> &vpns, vector<bool> vbSelectedOut[NUM_PLAYERS] ) const
{
}
virtual int ExportOption( const OptionRowDefinition &def, const vector<PlayerNumber> &vpns, const vector<bool> vbSelected[NUM_PLAYERS] ) const
{
if( vbSelected[PLAYER_1][0] )
m_gc.ApplyToAllPlayers();
return 0;
}
virtual void GetIconTextAndGameCommand( const OptionRowDefinition &def, int iFirstSelection, CString &sIconTextOut, GameCommand &gcOut ) const
{
sIconTextOut = "";
gcOut = m_gc;
}
};
REGISTER_SCREEN_CLASS( ScreenOptionsManageProfiles );
ScreenOptionsManageProfiles::ScreenOptionsManageProfiles( CString sName ) : ScreenOptions( sName )
{
@@ -144,15 +116,13 @@ void ScreenOptionsManageProfiles::BeginScreen()
if( SHOW_CREATE_NEW )
{
def.m_vsChoices.clear();
def.m_vsChoices.push_back( "Create New" );
OptionRowDefinition def;
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands("gamecommand;screen,ScreenOptionsEditProfile;name,Create New"), def );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "screen,ScreenOptionsEditProfile";
gc.Load( iIndex++, ParseCommands(sCommand) );
// FIXME
// gc.Load( iIndex++, );
}
PROFILEMAN->GetLocalProfileIDs( m_vsLocalProfileID );
@@ -162,16 +132,15 @@ void ScreenOptionsManageProfiles::BeginScreen()
Profile *pProfile = PROFILEMAN->GetLocalProfile( *s );
ASSERT( pProfile );
OptionRowDefinition def;
CString sCommand = ssprintf( "gamecommand;screen,ScreenOptionsEditProfile;profileid,%s;name,%s", s->c_str(), pProfile->m_sDisplayName.c_str() );
OptionRowHandler *pHand = OptionRowHandlerUtil::Make( ParseCommands(sCommand), def );
def.m_sName = ssprintf( "%d", iIndex );
def.m_vsChoices.clear();
def.m_vsChoices.push_back( pProfile->m_sDisplayName );
vDefs.push_back( def );
OptionRowHandlerSimple *pHand = new OptionRowHandlerSimple;
m_OptionRowHandlers.push_back( pHand );
GameCommand &gc = pHand->m_gc;
CString sCommand = "screen,ScreenOptionsEditProfile;profileid,"+*s;
gc.Load( iIndex++, ParseCommands(sCommand) );
// FIXME
// gc.Load( iIndex++, );
}
ScreenOptions::InitMenu( vDefs, m_OptionRowHandlers );
+4 -7
View File
@@ -82,15 +82,12 @@ void ScreenOptionsMaster::Init()
OptionRowHandler* &pHand = m_OptionRowHandlers[i];
pHand = NULL;
Commands vCommands;
ParseCommands( sRowCommands, vCommands );
if( vCommands.v.size() != 1 )
RageException::Throw( "Parse error in %s::Line%i", m_sName.c_str(), i+1 );
Commands cmds;
ParseCommands( sRowCommands, cmds );
Command& command = vCommands.v[0];
pHand = OptionRowHandlerUtil::Make( command, def );
pHand = OptionRowHandlerUtil::Make( cmds, def );
if( pHand == NULL )
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%i", command.GetOriginalCommandString().c_str(), m_sName.c_str(), i );
RageException::Throw( "Invalid OptionRowHandler '%s' in %s::Line%i", cmds.GetOriginalCommandString().c_str(), m_sName.c_str(), i );
}
ASSERT( m_OptionRowHandlers.size() == asLineNames.size() );