From 2b9bb0ec4457d022acf5730681c8f4437204e6b1 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 17 Jan 2006 21:23:26 +0000 Subject: [PATCH] use OptionRowHandler::m_Def --- stepmania/src/ScreenOptionsEditCourse.cpp | 60 +++++---- .../src/ScreenOptionsEditCourseEntry.cpp | 118 +++++++++++------- stepmania/src/ScreenOptionsEditProfile.cpp | 18 +-- stepmania/src/ScreenOptionsMemoryCard.cpp | 11 +- stepmania/src/ScreenSMOnlineLogin.cpp | 39 +++--- 5 files changed, 140 insertions(+), 106 deletions(-) diff --git a/stepmania/src/ScreenOptionsEditCourse.cpp b/stepmania/src/ScreenOptionsEditCourse.cpp index 80a61151b0..3975d7eec8 100644 --- a/stepmania/src/ScreenOptionsEditCourse.cpp +++ b/stepmania/src/ScreenOptionsEditCourse.cpp @@ -11,6 +11,7 @@ #include "ScreenPrompt.h" #include "CourseUtil.h" #include "LocalizedString.h" +#include "OptionRowHandler.h" enum EditCourseRow { @@ -59,42 +60,49 @@ void ScreenOptionsEditCourse::BeginScreen() vector vDefs; vector vHands; - OptionRowDefinition def; - def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.m_bExportOnChange = true; - - - def.m_sName = "Type"; - def.m_vsChoices.clear(); + OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Type"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); FOREACH_CourseType( i ) - def.m_vsChoices.push_back( CourseTypeToLocalizedString(i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( CourseTypeToLocalizedString(i) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Meter"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "Auto" ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Meter"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + pHand->m_Def.m_vsChoices.push_back( "Auto" ); for( int i=MIN_METER; i<=MAX_METER; i++ ) - def.m_vsChoices.push_back( ssprintf("%d",i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( ssprintf("%d",i) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); FOREACH_CONST( CourseEntry, pCourse->m_vEntries, ce ) { + pHand = OptionRowHandlerUtil::MakeNull(); int iEntryIndex = ce - pCourse->m_vEntries.begin(); - def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 ); - def.m_vsChoices.clear(); + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_sName = ssprintf( "Entry %d", iEntryIndex+1 ); + pHand->m_Def.m_vsChoices.clear(); FOREACH_CONST( Song*, m_vpDisplayedSongs, s ) - def.m_vsChoices.push_back( (*s)->GetTranslitFullTitle() ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( (*s)->GetTranslitFullTitle() ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); } - def.m_sName = ""; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "Insert Entry" ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = ""; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + pHand->m_Def.m_vsChoices.push_back( "Insert Entry" ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); ScreenOptions::InitMenu( vDefs, vHands ); diff --git a/stepmania/src/ScreenOptionsEditCourseEntry.cpp b/stepmania/src/ScreenOptionsEditCourseEntry.cpp index e6d0e2fcbd..fcdd51a892 100644 --- a/stepmania/src/ScreenOptionsEditCourseEntry.cpp +++ b/stepmania/src/ScreenOptionsEditCourseEntry.cpp @@ -8,6 +8,7 @@ #include "GameManager.h" #include "song.h" #include "Steps.h" +#include "OptionRowHandler.h" enum EditCourseEntryRow { @@ -63,70 +64,91 @@ void ScreenOptionsEditCourseEntry::BeginScreen() vector vDefs; vector vHands; - OptionRowDefinition def; - def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.m_bExportOnChange = true; - - def.m_sName = "Song Group"; - def.m_vsChoices.clear(); + OptionRowHandler *pHand = OptionRowHandlerUtil::MakeNull(); + vHands.push_back( OptionRowHandlerUtil::MakeNull() ); + pHand->m_Def.m_sName = "Song Group"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); vector vsSongGroups; SONGMAN->GetSongGroupNames( vsSongGroups ); - def.m_vsChoices.push_back( "(any)" ); + pHand->m_Def.m_vsChoices.push_back( "(any)" ); FOREACH_CONST( CString, vsSongGroups, song ) - def.m_vsChoices.push_back( *song ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( *song ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Song"; - def.m_vsChoices.clear(); - FillSongsAndChoices( ce.sSongGroup, m_vpDisplayedSongs, def.m_vsChoices ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Song"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + FillSongsAndChoices( ce.sSongGroup, m_vpDisplayedSongs, pHand->m_Def.m_vsChoices ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Base Difficulty"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "(any)" ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Base Difficulty"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + pHand->m_Def.m_vsChoices.push_back( "(any)" ); FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), dc ) - def.m_vsChoices.push_back( DifficultyToLocalizedString(*dc) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( DifficultyToLocalizedString(*dc) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Low Meter"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "(any)" ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Low Meter"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + pHand->m_Def.m_vsChoices.push_back( "(any)" ); for( int i=MIN_METER; i<=MAX_METER; i++ ) - def.m_vsChoices.push_back( ssprintf("%i",i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( ssprintf("%i",i) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "High Meter"; - def.m_vsChoices.clear(); - def.m_vsChoices.push_back( "(any)" ); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "High Meter"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); + pHand->m_Def.m_vsChoices.push_back( "(any)" ); for( int i=MIN_METER; i<=MAX_METER; i++ ) - def.m_vsChoices.push_back( ssprintf("%i",i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( ssprintf("%i",i) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Sort"; - def.m_vsChoices.clear(); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Sort"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); FOREACH_SongSort( i ) - def.m_vsChoices.push_back( SongSortToLocalizedString(i) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( SongSortToLocalizedString(i) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Choose"; - def.m_vsChoices.clear(); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Choose"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); for( int i=0; i<20; i++ ) - def.m_vsChoices.push_back( FormatNumberAndSuffix(i+1) ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( FormatNumberAndSuffix(i+1) ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); - def.m_sName = "Set Mods"; - def.m_vsChoices.clear(); + pHand = OptionRowHandlerUtil::MakeNull(); + pHand->m_Def.m_sName = "Set Mods"; + pHand->m_Def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + pHand->m_Def.m_bExportOnChange = true; + pHand->m_Def.m_vsChoices.clear(); CString s = ssprintf( "%d mod changes", ce.GetNumModChanges() ); - def.m_vsChoices.push_back( s ); - vDefs.push_back( def ); - vHands.push_back( NULL ); + pHand->m_Def.m_vsChoices.push_back( s ); + vDefs.push_back( pHand->m_Def ); + vHands.push_back( pHand ); ScreenOptions::InitMenu( vDefs, vHands ); diff --git a/stepmania/src/ScreenOptionsEditProfile.cpp b/stepmania/src/ScreenOptionsEditProfile.cpp index 2e022b5083..e4c05856fa 100644 --- a/stepmania/src/ScreenOptionsEditProfile.cpp +++ b/stepmania/src/ScreenOptionsEditProfile.cpp @@ -10,6 +10,7 @@ #include "Profile.h" #include "Character.h" #include "CharacterManager.h" +#include "OptionRowHandler.h" enum EditProfileRow { @@ -30,18 +31,18 @@ void ScreenOptionsEditProfile::BeginScreen() vector vDefs; vector vHands; - OptionRowDefinition def; - def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; - def.m_bOneChoiceForAllPlayers = true; - def.m_bAllowThemeItems = false; - def.m_bAllowThemeTitle = false; - def.m_bAllowExplanation = false; - def.m_bExportOnChange = true; - Profile *pProfile = PROFILEMAN->GetLocalProfile( GAMESTATE->m_sEditLocalProfileID ); ASSERT( pProfile ); { + vHands.push_back( OptionRowHandlerUtil::MakeNull() ); + OptionRowDefinition &def = vHands.back()->m_Def; + def.m_layoutType = LAYOUT_SHOW_ONE_IN_ROW; + def.m_bOneChoiceForAllPlayers = true; + def.m_bAllowThemeItems = false; + def.m_bAllowThemeTitle = false; + def.m_bAllowExplanation = false; + def.m_bExportOnChange = true; def.m_sName = "Character"; def.m_vsChoices.clear(); vector vpCharacters; @@ -49,7 +50,6 @@ void ScreenOptionsEditProfile::BeginScreen() FOREACH_CONST( Character*, vpCharacters, c ) def.m_vsChoices.push_back( (*c)->GetDisplayName() ); vDefs.push_back( def ); - vHands.push_back( NULL ); } InitMenu( vDefs, vHands ); diff --git a/stepmania/src/ScreenOptionsMemoryCard.cpp b/stepmania/src/ScreenOptionsMemoryCard.cpp index 3a39cb889f..731caa57dd 100644 --- a/stepmania/src/ScreenOptionsMemoryCard.cpp +++ b/stepmania/src/ScreenOptionsMemoryCard.cpp @@ -7,6 +7,7 @@ #include "ScreenManager.h" #include "ScreenPrompt.h" #include "LocalizedString.h" +#include "OptionRowHandler.h" REGISTER_SCREEN_CLASS( ScreenOptionsMemoryCard ); @@ -15,6 +16,8 @@ void ScreenOptionsMemoryCard::Init() { ScreenOptions::Init(); + vector vHands; + FOREACH_CONST( UsbStorageDevice, MEMCARDMAN->GetStorageDevices(), iter ) { // TODO: Make these string themable @@ -33,8 +36,12 @@ void ScreenOptionsMemoryCard::Init() else vs.push_back( ssprintf("%dMB",iter->iVolumeSizeMB) ); + vHands.push_back( OptionRowHandlerUtil::MakeNull() ); + + OptionRowDefinition &def = vHands.back()->m_Def; CString sDescription = join(", ", vs); - OptionRowDefinition def( sDescription, true, "" ); + def.m_sName = sDescription; + def.m_vsChoices.push_back( "" ); def.m_sExplanationName = "Memory Card"; def.m_bAllowThemeTitle = false; def.m_bOneChoiceForAllPlayers = true; @@ -47,8 +54,6 @@ void ScreenOptionsMemoryCard::Init() m_vDefs.push_back( def ); } - vector vHands( m_vDefs.size(), NULL ); - InitMenu( m_vDefs, vHands ); } diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index c3d0e4b033..d7d121fc08 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -14,44 +14,43 @@ #include "ScreenTextEntry.h" #include "Profile.h" #include "LocalizedString.h" +#include "OptionRowHandler.h" REGISTER_SCREEN_CLASS(ScreenSMOnlineLogin); AutoScreenMessage( SM_SMOnlinePack ) AutoScreenMessage( SM_PasswordDone ) -OptionRowDefinition g_ProfileLine[1] = { - OptionRowDefinition("Profile",false) -}; - static LocalizedString DEFINE_A_PROFILE( "ScreenSMOnlineLogin", "You must define a Profile." ); void ScreenSMOnlineLogin::Init() { ScreenOptions::Init(); m_iPlayer = 0; - g_ProfileLine[0].m_vsChoices.clear(); - PROFILEMAN->GetLocalProfileDisplayNames( g_ProfileLine[0].m_vsChoices ); - - if( g_ProfileLine[0].m_vsChoices.empty() ) + vector vDefs; + vector vHands; + vHands.push_back( OptionRowHandlerUtil::MakeNull() ); + OptionRowDefinition &def = vHands.back()->m_Def; + def.m_sName = "Profile"; + def.m_bOneChoiceForAllPlayers = false; + def.m_bAllowThemeItems = false; + def.m_vEnabledForPlayers.clear(); + FOREACH_PlayerNumber( pn ) + def.m_vEnabledForPlayers.insert( pn ); + def.m_vsChoices.clear(); + PROFILEMAN->GetLocalProfileDisplayNames( def.m_vsChoices ); + if( def.m_vsChoices.empty() ) { SCREENMAN->SystemMessage( DEFINE_A_PROFILE ); SCREENMAN->SetNewScreen("ScreenProfileOptions"); } - else - { - FOREACH_PlayerNumber( pn ) - g_ProfileLine[0].m_vEnabledForPlayers.insert( pn ); - g_ProfileLine[0].m_bAllowThemeItems = false; - vector vDefs( &g_ProfileLine[0], &g_ProfileLine[ARRAYSIZE(g_ProfileLine)] ); - vector vHands( vDefs.size(), NULL ); + vDefs.push_back( def ); - InitMenu( vDefs, vHands ); - SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music")); - OptionRow &row = *m_pRows.back(); - row.SetExitText("Login"); - } + InitMenu( vDefs, vHands ); + SOUND->PlayMusic( THEME->GetPathS("ScreenMachineOptions", "music")); + OptionRow &row = *m_pRows.back(); + row.SetExitText("Login"); } void ScreenSMOnlineLogin::ImportOptions( int iRow, const vector &vpns )