move item theming from ScreenOptionsMaster to OptionRow so MiniMenu and other options screens can be themed
This commit is contained in:
@@ -76,6 +76,12 @@ public:
|
||||
ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW;
|
||||
const set<CourseDifficulty>& 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 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
|
||||
@@ -19,6 +19,8 @@ extern ThemeMetric<int> MAX_STEPS_LOADED_FROM_PROFILE;
|
||||
extern ThemeMetric<int> MAX_COURSE_ENTRIES_BEFORE_VARIOUS;
|
||||
extern ThemeMetric<float> TICK_EARLY_SECONDS;
|
||||
|
||||
CString THEME_OPTION_ITEM( CString s, bool bOptional );
|
||||
|
||||
namespace CommonMetrics
|
||||
{
|
||||
const set<Difficulty>& GetDifficultiesToShow();
|
||||
|
||||
+12
-13
@@ -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; c<m_RowDef.choices.size(); c++ )
|
||||
{
|
||||
CString sText = m_RowDef.choices[c];
|
||||
if( CAPITALIZE_ALL_OPTION_NAMES )
|
||||
sText.MakeUpper();
|
||||
PREPARE_ITEM_TEXT( sText );
|
||||
fX += ITEMS_ZOOM * pFont->GetLineWidthInSourcePixels( 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 );
|
||||
|
||||
@@ -200,6 +200,7 @@ protected:
|
||||
ThemeMetric<bool> CAPITALIZE_ALL_OPTION_NAMES;
|
||||
ThemeMetric<bool> SHOW_UNDERLINES;
|
||||
ThemeMetric<float> TWEEN_SECONDS;
|
||||
ThemeMetric<bool> THEME_ITEMS;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -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<Steps*> 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
|
||||
{
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
struct ConfOption;
|
||||
|
||||
#define ENTRY_NAME(s) THEME->GetMetric ("OptionNames", s)
|
||||
|
||||
class OptionRowHandler
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user