From b73448d410df25c1bf63777d81fb6417e58b0b3a Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 20 Mar 2005 20:16:32 +0000 Subject: [PATCH] move item theming from ScreenOptionsMaster to OptionRow so MiniMenu and other options screens can be themed --- stepmania/src/CommonMetrics.cpp | 6 ++++ stepmania/src/CommonMetrics.h | 2 ++ stepmania/src/OptionRow.cpp | 25 ++++++++------- stepmania/src/OptionRow.h | 1 + stepmania/src/OptionRowHandler.cpp | 49 +++--------------------------- stepmania/src/OptionRowHandler.h | 2 -- stepmania/src/PlayerOptions.cpp | 4 +-- 7 files changed, 28 insertions(+), 61 deletions(-) diff --git a/stepmania/src/CommonMetrics.cpp b/stepmania/src/CommonMetrics.cpp index 3a93435f0e..c1dfb23758 100644 --- a/stepmania/src/CommonMetrics.cpp +++ b/stepmania/src/CommonMetrics.cpp @@ -76,6 +76,12 @@ public: ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW; const set& CommonMetrics::GetCourseDifficultiesToShow() { return COURSE_DIFFICULTIES_TO_SHOW.m_v; } +CString THEME_OPTION_ITEM( CString s, bool bOptional ) +{ + if( bOptional && !THEME->HasMetric("OptionNames",s) ) + return s; + return THEME->GetMetric( "OptionNames", s ); +} /* diff --git a/stepmania/src/CommonMetrics.h b/stepmania/src/CommonMetrics.h index ca344d5760..d861ef2782 100644 --- a/stepmania/src/CommonMetrics.h +++ b/stepmania/src/CommonMetrics.h @@ -19,6 +19,8 @@ extern ThemeMetric MAX_STEPS_LOADED_FROM_PROFILE; extern ThemeMetric MAX_COURSE_ENTRIES_BEFORE_VARIOUS; extern ThemeMetric TICK_EARLY_SECONDS; +CString THEME_OPTION_ITEM( CString s, bool bOptional ); + namespace CommonMetrics { const set& GetDifficultiesToShow(); diff --git a/stepmania/src/OptionRow.cpp b/stepmania/src/OptionRow.cpp index d7d9dfed42..1313a3d4fa 100644 --- a/stepmania/src/OptionRow.cpp +++ b/stepmania/src/OptionRow.cpp @@ -7,6 +7,7 @@ #include "OptionRowHandler.h" #include "FontManager.h" #include "Font.h" +#include "CommonMetrics.h" static const CString SelectTypeNames[NUM_SELECT_TYPES] = { "SelectOne", @@ -26,6 +27,8 @@ StringToX( LayoutType ); #define FOREACH_OptionsPlayer( pn ) \ for( PlayerNumber pn=GetNextHumanPlayer((PlayerNumber)-1); pn!=PLAYER_INVALID && (!m_RowDef.bOneChoiceForAllPlayers || pn==0); pn=GetNextHumanPlayer(pn) ) +#define PREPARE_ITEM_TEXT( s ) if( s!= "" ) { if( THEME_ITEMS ) s = THEME_OPTION_ITEM( s, false ); if( CAPITALIZE_ALL_OPTION_NAMES ) s.MakeUpper(); } + const CString NEXT_ROW_NAME = "NextRow"; @@ -102,6 +105,7 @@ void OptionRow::LoadMetrics( const CString &sType ) CAPITALIZE_ALL_OPTION_NAMES .Load(m_sType,"CapitalizeAllOptionNames"); SHOW_UNDERLINES .Load(m_sType,"ShowUnderlines"); TWEEN_SECONDS .Load(m_sType,"TweenSeconds"); + THEME_ITEMS .Load(m_sType,"ThemeItems"); FOREACH_PlayerNumber( p ) m_OptionIcons[p].Load( m_sType ); @@ -134,7 +138,7 @@ void OptionRow::LoadNormal( const OptionRowDefinition &def, OptionRowHandler *pH // TRICKY: Insert a down arrow as the first choice in the row. if( m_bFirstItemGoesDown ) { - m_RowDef.choices.insert( m_RowDef.choices.begin(), ENTRY_NAME(NEXT_ROW_NAME) ); + m_RowDef.choices.insert( m_RowDef.choices.begin(), NEXT_ROW_NAME ); FOREACH_PlayerNumber( p ) m_vbSelected[p].insert( m_vbSelected[p].begin(), false ); } @@ -197,8 +201,7 @@ void OptionRow::AfterImportOptions( for( unsigned c=0; cGetLineWidthInSourcePixels( CStringToWstring(sText) ); if( c != m_RowDef.choices.size()-1 ) @@ -231,8 +234,7 @@ void OptionRow::AfterImportOptions( bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = (iChoiceInRowWithFocus==-1) ? "" : m_RowDef.choices[iChoiceInRowWithFocus]; - if( CAPITALIZE_ALL_OPTION_NAMES ) - sText.MakeUpper(); + PREPARE_ITEM_TEXT( sText ); bt->SetText( sText ); bt->SetZoom( ITEMS_ZOOM ); bt->SetShadowLength( 0 ); @@ -272,8 +274,7 @@ void OptionRow::AfterImportOptions( m_textItems.push_back( bt ); bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); CString sText = m_RowDef.choices[c]; - if( CAPITALIZE_ALL_OPTION_NAMES ) - sText.MakeUpper(); + PREPARE_ITEM_TEXT( sText ); bt->SetText( sText ); bt->SetZoom( ITEMS_ZOOM ); bt->SetShadowLength( 0 ); @@ -340,7 +341,9 @@ void OptionRow::LoadExit() m_textItems.push_back( bt ); bt->LoadFromFont( THEME->GetPathF(m_sType,"item") ); - bt->SetText( THEME->GetMetric("OptionNames","Exit") ); + CString sText = "Exit"; + PREPARE_ITEM_TEXT( sText ); + bt->SetText( sText ); bt->SetZoom( ITEMS_ZOOM ); bt->SetShadowLength( 0 ); bt->SetX( ITEMS_LONG_ROW_SHARED_X ); @@ -427,9 +430,6 @@ void OptionRow::PositionIcons() void OptionRow::UpdateText() { - /* - CAPITALIZE_ALL_OPTION_NAMES - */ switch( m_RowDef.layoutType ) { case LAYOUT_SHOW_ONE_IN_ROW: @@ -439,8 +439,7 @@ void OptionRow::UpdateText() int iChoiceWithFocus = m_iChoiceInRowWithFocus[pn]; CString sText = m_RowDef.choices[iChoiceWithFocus]; - if( CAPITALIZE_ALL_OPTION_NAMES ) - sText.MakeUpper(); + PREPARE_ITEM_TEXT( sText ); // If player_no is 2 and there is no player 1: int index = min( pn, m_textItems.size()-1 ); diff --git a/stepmania/src/OptionRow.h b/stepmania/src/OptionRow.h index 5721d695b2..5a1dd7143a 100644 --- a/stepmania/src/OptionRow.h +++ b/stepmania/src/OptionRow.h @@ -200,6 +200,7 @@ protected: ThemeMetric CAPITALIZE_ALL_OPTION_NAMES; ThemeMetric SHOW_UNDERLINES; ThemeMetric TWEEN_SECONDS; + ThemeMetric THEME_ITEMS; }; #endif diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index 33fe4d7bad..6656b0043d 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -71,7 +71,6 @@ public: if( sParam.CompareNoCase("NoteSkins")==0 ) { FillNoteSkins( defOut, sParam ); return; } else if( sParam.CompareNoCase("Steps")==0 ) { FillSteps( defOut, sParam ); return; } - else if( sParam.CompareNoCase("EditsAndNull")==0 ) { FillEditsAndNull( defOut, sParam ); return; } else if( sParam.CompareNoCase("Characters")==0 ) { FillCharacters( defOut, sParam ); return; } else if( sParam.CompareNoCase("Styles")==0 ) { FillStyles( defOut, sParam ); return; } else if( sParam.CompareNoCase("Groups")==0 ) { FillGroups( defOut, sParam ); return; } @@ -141,7 +140,7 @@ public: ListEntries.push_back( mc ); CString sName = mc.m_sName; - CString sChoice = ENTRY_NAME(mc.m_sName); + CString sChoice = mc.m_sName; defOut.choices.push_back( sChoice ); } } @@ -322,44 +321,6 @@ public: } } - void FillEditsAndNull( OptionRowDefinition &defOut, CString sParam ) - { - Init(); - defOut.Init(); - - ASSERT( sParam.size() ); - m_sName = sParam; - - defOut.name = "EditsAndNull"; - defOut.bOneChoiceForAllPlayers = true; - defOut.layoutType = LAYOUT_SHOW_ONE_IN_ROW; - defOut.m_bExportOnChange = true; - m_vsReloadRowMessages.push_back( MessageToString(MESSAGE_CURRENT_SONG_CHANGED) ); - m_vsReloadRowMessages.push_back( MessageToString(MESSAGE_EDIT_STEPS_TYPE_CHANGED) ); - - if( GAMESTATE->m_pCurSong != NULL ) - { - vector vSteps; - GAMESTATE->m_pCurSong->GetSteps( vSteps, GAMESTATE->m_stEdit, DIFFICULTY_EDIT ); - StepsUtil::SortNotesArrayByDifficulty( vSteps ); - FOREACH_CONST( Steps*, vSteps, p ) - { - CString s = (*p)->GetDescription(); - defOut.choices.push_back( s ); - GameCommand mc; - mc.m_pSteps = *p; - ListEntries.push_back( mc ); - } - } - - // Add NULL entry for a new edit - { - defOut.choices.push_back( ENTRY_NAME("NewEdit") ); - GameCommand mc; - ListEntries.push_back( mc ); - } - } - void FillCharacters( OptionRowDefinition &defOut, CString sParam ) { Init(); @@ -373,7 +334,7 @@ public: Default.m_pCharacter = GAMESTATE->GetDefaultCharacter(); { - defOut.choices.push_back( ENTRY_NAME("Off") ); + defOut.choices.push_back( "Off" ); GameCommand mc; mc.m_pCharacter = NULL; ListEntries.push_back( mc ); @@ -437,7 +398,7 @@ public: ASSERT( vGroups.size() ); { - defOut.choices.push_back( ENTRY_NAME("AllGroups") ); + defOut.choices.push_back( "AllGroups" ); GameCommand mc; mc.m_sSongGroup = GROUP_ALL_MUSIC; ListEntries.push_back( mc ); @@ -467,7 +428,7 @@ public: Default.m_dc = DIFFICULTY_INVALID; { - defOut.choices.push_back( ENTRY_NAME("AllDifficulties") ); + defOut.choices.push_back( "AllDifficulties" ); GameCommand mc; mc.m_dc = DIFFICULTY_INVALID; ListEntries.push_back( mc ); @@ -1025,7 +986,7 @@ public: if( pSteps ) s = pSteps->GetDescription(); else - s = ENTRY_NAME("NewEdit"); + s = "NewEdit"; } else { diff --git a/stepmania/src/OptionRowHandler.h b/stepmania/src/OptionRowHandler.h index 25a8446ee1..68aeb36dd4 100644 --- a/stepmania/src/OptionRowHandler.h +++ b/stepmania/src/OptionRowHandler.h @@ -9,8 +9,6 @@ struct ConfOption; -#define ENTRY_NAME(s) THEME->GetMetric ("OptionNames", s) - class OptionRowHandler { public: diff --git a/stepmania/src/PlayerOptions.cpp b/stepmania/src/PlayerOptions.cpp index 1918169841..016ede9857 100644 --- a/stepmania/src/PlayerOptions.cpp +++ b/stepmania/src/PlayerOptions.cpp @@ -11,6 +11,7 @@ #include "ThemeManager.h" #include "Foreach.h" #include "Style.h" +#include "CommonMetrics.h" #define ONE( arr ) { for( unsigned Z = 0; Z < ARRAYSIZE(arr); ++Z ) arr[Z]=1.0f; } @@ -590,8 +591,7 @@ CString PlayerOptions::ThemeMod( CString sOneMod ) /* Theme the mod name (the last string). Allow this to not exist, since * characters might use modifiers that don't exist in the theme. */ - if( THEME->HasMetric( "OptionNames", asTokens.back() ) ) - asTokens.back() = THEME->GetMetric( "OptionNames", asTokens.back() ); + asTokens.back() = THEME_OPTION_ITEM( asTokens.back(), true ); return join( " ", asTokens ); }