From d11ee0bf808868161af5a0614070e5b39ea6a7ba Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 13 Feb 2004 05:27:18 +0000 Subject: [PATCH] add row name indirection to SSOM to make it easier to add/remove rows --- stepmania/Themes/default/metrics.ini | 42 ++++++++++++++++++--------- stepmania/src/ScreenOptionsMaster.cpp | 29 +++++++++--------- 2 files changed, 44 insertions(+), 27 deletions(-) diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index 8d67487c08..9ea5ef3b49 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -3205,7 +3205,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,6;together;explanations +LineNames=1,2,3,4,5,6 +OptionMenuFlags=together;explanations Line1=conf,AutoMapOnJoyChange Line2=conf,MenuButtons Line3=conf,AutoPlay @@ -3220,7 +3221,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,4;together;explanations +LineNames=1,2,3,4 +OptionMenuFlags=together;explanations Line1=conf,CoinMode Line2=conf,SongsPerPlay Line3=conf,CoinsPerCredit @@ -3233,7 +3235,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,10;together;explanations +LineNames=1,2,3,4,5,6,7,8,9,10 +OptionMenuFlags=together;explanations Line1=conf,MenuTimer Line2=conf,ScoringType Line3=conf,JudgeDifficulty @@ -3252,7 +3255,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,12;together;explanations +LineNames=1,2,3,4,5,6,7,8,9,10,11,12 +OptionMenuFlags=together;explanations Line1=conf,DisplayMode Line2=conf,DisplayResolution Line3=conf,DisplayColor @@ -3273,7 +3277,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,7;together;explanations +LineNames=1,2,3,4,5,6,7 +OptionMenuFlags=together;explanations Line1=conf,SoloSingles Line2=conf,HiddenSongs Line3=conf,EasterEggs @@ -3289,7 +3294,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,6;together;explanations +LineNames=1,2,3,4,5,6 +OptionMenuFlags=together;explanations Line1=conf,BackgroundMode Line2=conf,Brightness Line3=conf,Danger @@ -3306,7 +3312,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,13;together;explanations +LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13 +OptionMenuFlags=together;explanations Line1=conf,Language Line2=conf,Announcer Line3=conf,Theme @@ -3328,7 +3335,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,3;together;explanations +LineNames=1,2,3 +OptionMenuFlags=together;explanations Line1=conf,AutogenSteps Line2=conf,AutogenGroupCourses Line3=conf,FastLoad @@ -3598,7 +3606,8 @@ TimerSeconds=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,4;together;explanations +LineNames=1,2,3,4 +OptionMenuFlags=together;explanations Line1=conf,PreloadSounds Line2=conf,ResamplingQuality Line3=conf,AttractSoundFrequency @@ -3777,7 +3786,8 @@ TimerSeconds=0 # when using entries that change the screen; otherwise, the only way to # exit the screen when in arcade mode is "exit". -OptionMenuFlags=together;forceallplayers;rows,15;smnavigation +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. NextScreen=ScreenTitleMenu PrevScreen=ScreenTitleMenu @@ -3854,7 +3864,8 @@ TimerSeconds=0 PrevScreen=ScreenTitleMenu NextScreen=ScreenTitleMenu -OptionMenuFlags=rows,1;together +LineNames=1 +OptionMenuFlags=together Line1=conf,Game [ScreenPlayerOptions] @@ -3878,7 +3889,8 @@ MemoryCardIcons=0 PrevScreen= NextScreen= -OptionMenuFlags=rows,15 +LineNames=1,2,3,4,5,6,7,8,9,10,11,12,13,14,15 +OptionMenuFlags= Line1=list,Speed Line2=list,Accel @@ -3903,7 +3915,8 @@ TimerSeconds=30 StyleIcon=0 MemoryCardIcons=0 -OptionMenuFlags=rows,5 +LineNames=1,2,3,4,5 +OptionMenuFlags= Line1=list,Speed Line2=list,Scroll @@ -3932,7 +3945,8 @@ MemoryCardIcons=0 PrevScreen=ScreenOptionsMenu@ScreenOptionsMaster NextScreen=ScreenOptionsMenu@ScreenOptionsMaster -OptionMenuFlags=rows,8 +LineNames=1,2,3,4,5,6,7,8 +OptionMenuFlags= Line1=list,LifeType Line2=list,BarDrain Line3=list,BatLives diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index 8219969756..07421d0829 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -21,8 +21,9 @@ #include "RageSoundManager.h" #include "ProfileManager.h" +#define LINE_NAMES THEME->GetMetric (m_sName,"LineNames") #define OPTION_MENU_FLAGS THEME->GetMetric (m_sName,"OptionMenuFlags") -#define ROW_LINE(i) THEME->GetMetric (m_sName,ssprintf("Line%i",(i+1))) +#define LINE(sLineName) THEME->GetMetric (m_sName,ssprintf("Line%s",sLineName.c_str())) #define ENTRY(s) THEME->GetMetric ("ScreenOptionsMaster",s) #define ENTRY_NAME(s) THEME->GetMetric ("OptionNames", s) @@ -217,19 +218,22 @@ ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ): if( MusicPath != "" ) SOUND->PlayMusic( MusicPath ); + CStringArray asLineNames; + split( LINE_NAMES, ",", asLineNames ); + if( asLineNames.empty() ) + RageException::Throw( "%s::LineNames is empty.", m_sName.c_str() ); + + CStringArray Flags; split( OPTION_MENU_FLAGS, ";", Flags, true ); InputMode im = INPUTMODE_INDIVIDUAL; bool Explanations = false; - int NumRows = -1; - + unsigned i; for( i = 0; i < Flags.size(); ++i ) { Flags[i].MakeLower(); - if( sscanf( Flags[i], "rows,%i", &NumRows ) == 1 ) - continue; if( Flags[i] == "together" ) im = INPUTMODE_TOGETHER; if( Flags[i] == "explanations" ) @@ -246,15 +250,14 @@ ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ): SetNavigation( NAV_FIRST_CHOICE_GOES_DOWN ); } - if( NumRows == -1 ) - RageException::Throw( "%s::OptionMenuFlags is missing \"rows\" field", m_sName.c_str() ); - - m_OptionRowAlloc = new OptionRowData[NumRows]; - for( i = 0; (int) i < NumRows; ++i ) + m_OptionRowAlloc = new OptionRowData[asLineNames.size()]; + for( i = 0; (int) i < asLineNames.size(); ++i ) { + CString sLineName = asLineNames[i]; + OptionRowData &row = m_OptionRowAlloc[i]; - CString sRowCommands = ROW_LINE(i); + CString sRowCommands = LINE(sLineName); vector vCommands; ParseCommands( sRowCommands, vCommands ); @@ -310,9 +313,9 @@ ScreenOptionsMaster::ScreenOptionsMaster( CString sClassName ): OptionRowHandlers.push_back( hand ); } - ASSERT( (int) OptionRowHandlers.size() == NumRows ); + ASSERT( OptionRowHandlers.size() == asLineNames.size() ); - Init( im, m_OptionRowAlloc, NumRows ); + Init( im, m_OptionRowAlloc, asLineNames.size() ); } ScreenOptionsMaster::~ScreenOptionsMaster()