adding CustomDifficulty stuff (themable difficulty /StepsType combinations). Doesn't compile - fixing

This commit is contained in:
Chris Danford
2008-11-28 22:02:28 +00:00
parent 261df9636e
commit f18ba1614d
12 changed files with 66 additions and 111 deletions
+6 -11
View File
@@ -35,17 +35,12 @@ The following packages were exported to your Desktop:=The following packages wer
[CatalogXml] [CatalogXml]
Saving %s ...=Saving %s ... Saving %s ...=Saving %s ...
[DifficultyDisplayType] [CustomDifficulty]
Single_Beginner=Beginner Beginner=Novice
Single_Easy=Easy Easy=Easy
Single_Medium=Medium Medium=Medium
Single_Hard=Hard Hard=Hard
Single_Challenge=Expert Challenge=Expert
Double_Beginner=Beginner
Double_Easy=Easy
Double_Medium=Medium
Double_Hard=Hard
Double_Challenge=Expert
Edit=Edit Edit=Edit
Couple=Couple Couple=Couple
Routine=Routine Routine=Routine
+11 -16
View File
@@ -10,20 +10,15 @@ function PlayerScoreColor( pn )
return color("1,1,1,1") return color("1,1,1,1")
end end
local DifficultyDisplayTypeColors = { local CustomDifficultyColors = {
DifficultyDisplayType_Single_Beginner = color("#ff32f8"), "Beginner" = color("#ff32f8"),
DifficultyDisplayType_Single_Easy = color("#2cff00"), "Easy" = color("#2cff00"),
DifficultyDisplayType_Single_Medium = color("#fee600"), "Medium" = color("#fee600"),
DifficultyDisplayType_Single_Hard = color("#ff2f39"), "Hard" = color("#ff2f39"),
DifficultyDisplayType_Single_Challenge = color("#1cd8ff"), "Challenge" = color("#1cd8ff"),
DifficultyDisplayType_Double_Beginner = color("0.0,0.9,1.0,1"), -- light blue "Edit" = color("0.8,0.8,0.8,1"), -- gray
DifficultyDisplayType_Double_Easy = color("0.9,0.9,0.0,1"), -- yellow "Couple" = color("#ff9a00"), -- orange
DifficultyDisplayType_Double_Medium = color("1.0,0.1,0.1,1"), -- light red "Routine" = color("#ff9a00"), -- orange
DifficultyDisplayType_Double_Hard = color("0.2,1.0,0.2,1"), -- light green
DifficultyDisplayType_Double_Challenge = color("0.2,0.6,1.0,1"), -- blue
Difficulty_Edit = color("0.8,0.8,0.8,1"), -- gray
Difficulty_Couple = color("#ff9a00"), -- orange
Difficulty_Routine = color("#ff9a00"), -- orange
}; };
local CourseDifficultyColors = { local CourseDifficultyColors = {
@@ -34,8 +29,8 @@ local CourseDifficultyColors = {
Difficulty_Challenge = color("0.2,0.6,1.0,1"), -- blue Difficulty_Challenge = color("0.2,0.6,1.0,1"), -- blue
}; };
function DifficultyDisplayTypeToColor( ddt ) function CustomDifficultyToColor( sCustomDifficulty )
local c = DifficultyDisplayTypeColors[ddt] local c = CustomDifficultyColors[sCustomDifficulty]
if c then return c end if c then return c end
return color("#000000"); return color("#000000");
end end
+1 -2
View File
@@ -280,8 +280,7 @@ void CatalogXml::Save( LoadingWindow *loading_window )
FOREACH_CONST( Difficulty, vDifficultiesToShow, iter ) FOREACH_CONST( Difficulty, vDifficultiesToShow, iter )
{ {
XNode* pNode3 = pNode2->AppendChild( "Difficulty", DifficultyToString(*iter) ); XNode* pNode3 = pNode2->AppendChild( "Difficulty", DifficultyToString(*iter) );
DifficultyDisplayType ddt = MakeDifficultyDisplayType( *iter, StepsTypeCategory_Single ); // TODO: Fix use of Single pNode3->AppendAttr( "DisplayAs", GetLocalizedCustomDifficulty( *iter, StepsTypeCategory_Single ) ); // TODO: Fix use of Single
pNode3->AppendAttr( "DisplayAs", DifficultyDisplayTypeToLocalizedString(ddt) );
} }
} }
+28 -29
View File
@@ -5,7 +5,6 @@
#include "LuaManager.h" #include "LuaManager.h"
#include "LocalizedString.h" #include "LocalizedString.h"
static const char *DifficultyNames[] = { static const char *DifficultyNames[] = {
"Beginner", "Beginner",
"Easy", "Easy",
@@ -18,26 +17,6 @@ XToString( Difficulty );
StringToX( Difficulty ); StringToX( Difficulty );
LuaXType( Difficulty ); LuaXType( Difficulty );
static const char *DifficultyDisplayTypeNames[] = {
"Single_Beginner",
"Single_Easy",
"Single_Medium",
"Single_Hard",
"Single_Challenge",
"Double_Beginner",
"Double_Easy",
"Double_Medium",
"Double_Hard",
"Double_Challenge",
"Edit",
"Couple",
"Routine",
};
XToString( DifficultyDisplayType );
XToLocalizedString( DifficultyDisplayType );
LuaXType( DifficultyDisplayType );
LuaFunction( DifficultyDisplayTypeToLocalizedString, DifficultyDisplayTypeToLocalizedString( Enum::Check<DifficultyDisplayType>(L, 1)) );
/* We prefer the above names; recognize a number of others, too. (They'll /* We prefer the above names; recognize a number of others, too. (They'll
* get normalized when written to SMs, etc.) */ * get normalized when written to SMs, etc.) */
/* TODO: Format specific hacks should be moved into the file loader for /* TODO: Format specific hacks should be moved into the file loader for
@@ -95,26 +74,46 @@ CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd )
return Difficulty_Invalid; return Difficulty_Invalid;
} }
DifficultyDisplayType MakeDifficultyDisplayType( Difficulty dc, StepsTypeCategory stc ) static ThemeMetric<RString> NAMES("CustomDifficulty","Names");
RString GetCustomDifficulty( Difficulty dc, StepsTypeCategory stc )
{ {
RString s;
switch( stc ) switch( stc )
{ {
DEFAULT_FAIL(stc); DEFAULT_FAIL(stc);
case StepsTypeCategory_Single: case StepsTypeCategory_Single:
if( dc == Difficulty_Edit )
return DifficultyDisplayType_Edit;
return (DifficultyDisplayType)(DifficultyDisplayType_Single_Beginner + dc);
case StepsTypeCategory_Double: case StepsTypeCategory_Double:
if( dc == Difficulty_Edit ) if( dc == Difficulty_Edit )
return DifficultyDisplayType_Edit; return "Edit";
return (DifficultyDisplayType)(DifficultyDisplayType_Double_Beginner + dc); else
{
/*
// OPTIMIZATION OPPORTUNITY: cache these metrics.
vector<RString> vsNames;
split( NAMES, ",", vsNames );
FOREACH( RString, vsNames, s )
{
if( STEPS_TYPE
}
*/
return DifficultyToString( dc );
}
case StepsTypeCategory_Couple: case StepsTypeCategory_Couple:
return DifficultyDisplayType_Couple; return "Couple";
case StepsTypeCategory_Routine: case StepsTypeCategory_Routine:
return DifficultyDisplayType_Routine; return "Routine";
} }
} }
const RString& GetLocalizedCustomDifficulty( RString &sCustomDifficulty )
{
return THEME:GetString( "CustomDifficulty", sCustomDifficultyString );
}
/* /*
* (c) 2001-2004 Chris Danford * (c) 2001-2004 Chris Danford
* All rights reserved. * All rights reserved.
+6 -23
View File
@@ -33,31 +33,14 @@ const RString& CourseDifficultyToLocalizedString( Difficulty dc );
Difficulty GetNextShownCourseDifficulty( Difficulty pn ); Difficulty GetNextShownCourseDifficulty( Difficulty pn );
// CustomDifficulty is a themeable difficulty name based on Difficulty, string matching on StepsType, and bCourse.
// It is used to look up localized strings and look up colors.
const RString& GetCustomDifficulty( Difficulty dc, StepsTypeCategory stc );
const RString& GetLocalizedCustomDifficulty( const RString &sCustomDifficultyString );
RString GetLocalizedCustomDifficulty( Difficulty dc, StepsTypeCategory stc ) { return GetLocalizedCustomDifficulty( GetCustomDifficulty( dc, stc ) ); }
enum DifficultyDisplayType // ID for coloring and localized strings in StepsDisplay
{
DifficultyDisplayType_Single_Beginner,
DifficultyDisplayType_Single_Easy,
DifficultyDisplayType_Single_Medium,
DifficultyDisplayType_Single_Hard,
DifficultyDisplayType_Single_Challenge,
DifficultyDisplayType_Double_Beginner,
DifficultyDisplayType_Double_Easy,
DifficultyDisplayType_Double_Medium,
DifficultyDisplayType_Double_Hard,
DifficultyDisplayType_Double_Challenge,
DifficultyDisplayType_Edit,
DifficultyDisplayType_Couple, // color this specially (don't color by difficulty) because there isn't usually more than one per song
DifficultyDisplayType_Routine, // color this specially (don't color by difficulty) because there isn't usually more than one per song
NUM_DifficultyDisplayType,
DifficultyDisplayType_Invalid
};
const RString& DifficultyDisplayTypeToString( DifficultyDisplayType dc );
const RString& DifficultyDisplayTypeToLocalizedString( DifficultyDisplayType dc );
DifficultyDisplayType StringToDifficultyDisplayType( const RString& s );
LuaDeclareType( DifficultyDisplayType );
DifficultyDisplayType MakeDifficultyDisplayType( Difficulty dc, StepsTypeCategory stc );
#endif #endif
+2 -4
View File
@@ -476,8 +476,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
// fall through // fall through
case ROW_STEPS: case ROW_STEPS:
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( GetSelectedDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedStepsType()).m_StepsTypeCategory ); RString s = GetLocalizedCustomDifficulty( GetSelectedDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedStepsType()).m_StepsTypeCategory );
RString s = DifficultyDisplayTypeToLocalizedString( ddt );
m_textValue[ROW_STEPS].SetText( s ); m_textValue[ROW_STEPS].SetText( s );
} }
@@ -526,8 +525,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row )
} }
else else
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( GetSelectedSourceDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedSourceStepsType()).m_StepsTypeCategory ); s = GetLocalizedCustomDifficulty( GetSelectedSourceDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedSourceStepsType()).m_StepsTypeCategory );
s = DifficultyDisplayTypeToLocalizedString( ddt );
} }
m_textValue[ROW_SOURCE_STEPS].SetText( s ); m_textValue[ROW_SOURCE_STEPS].SetText( s );
} }
+1 -2
View File
@@ -2288,8 +2288,7 @@ public:
for( unsigned i=0; i<vpStepsToShow.size(); i++ ) for( unsigned i=0; i<vpStepsToShow.size(); i++ )
{ {
const Steps* pSteps = vpStepsToShow[i]; const Steps* pSteps = vpStepsToShow[i];
DifficultyDisplayType ddt = MakeDifficultyDisplayType( pSteps->GetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory ); RString sDifficulty = GetLocalizedCustomDifficulty( pSteps->GetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory );
RString sDifficulty = DifficultyDisplayTypeToLocalizedString( ddt );
lua_pushstring( L, sDifficulty ); lua_pushstring( L, sDifficulty );
lua_pushstring( L, pSteps->GetDescription() ); lua_pushstring( L, pSteps->GetDescription() );
+2 -4
View File
@@ -444,11 +444,10 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList
} }
else else
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( pSteps->GetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory );
if( ddt == DifficultyDisplayType_Edit ) if( ddt == DifficultyDisplayType_Edit )
s = pSteps->GetDescription(); s = pSteps->GetDescription();
else else
s = DifficultyDisplayTypeToLocalizedString( ddt ); s = GetLocalizedCustomDifficulty( pSteps->GetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory ) );
} }
s += ssprintf( " %d", pSteps->GetMeter() ); s += ssprintf( " %d", pSteps->GetMeter() );
m_Def.m_vsChoices.push_back( s ); m_Def.m_vsChoices.push_back( s );
@@ -561,8 +560,7 @@ public:
} }
else else
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ); s = DifficultyDisplayTypeToLocalizedString( GetLocalizedCustomDifficulty( dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ) );
s = DifficultyDisplayTypeToLocalizedString( ddt );
} }
m_Def.m_vsChoices.push_back( s ); m_Def.m_vsChoices.push_back( s );
} }
+1 -2
View File
@@ -2889,8 +2889,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector<int> &iAns
g_StepsInformation.rows[difficulty].choices.clear(); g_StepsInformation.rows[difficulty].choices.clear();
FOREACH_ENUM( Difficulty, dc ) FOREACH_ENUM( Difficulty, dc )
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( dc, GameManager::GetStepsTypeInfo( pSteps->m_StepsType ).m_StepsTypeCategory ); g_StepsInformation.rows[difficulty].choices.push_back( "|" + GetLocalizedCustomDifficulty( dc, GameManager::GetStepsTypeInfo( pSteps->m_StepsType ).m_StepsTypeCategory ) );
g_StepsInformation.rows[difficulty].choices.push_back( "|" + DifficultyDisplayTypeToString(ddt) );
} }
g_StepsInformation.rows[difficulty].iDefaultChoice = pSteps->GetDifficulty(); g_StepsInformation.rows[difficulty].iDefaultChoice = pSteps->GetDifficulty();
g_StepsInformation.rows[difficulty].bEnabled = (EDIT_MODE.GetValue() >= EditMode_Full); g_StepsInformation.rows[difficulty].bEnabled = (EDIT_MODE.GetValue() >= EditMode_Full);
@@ -127,8 +127,7 @@ void ScreenOptionsEditCourseEntry::Init()
pHand->m_Def.m_vsChoices.push_back( "(any)" ); pHand->m_Def.m_vsChoices.push_back( "(any)" );
FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), dc ) FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), dc )
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( *dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ); pHand->m_Def.m_vsChoices.push_back( GetLocalizedCustomDifficulty( *dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ) );
pHand->m_Def.m_vsChoices.push_back( DifficultyDisplayTypeToLocalizedString(ddt) );
} }
vHands.push_back( pHand ); vHands.push_back( pHand );
+6 -14
View File
@@ -181,9 +181,9 @@ void StepsDisplay::SetFromStepsTypeAndMeterAndCourseDifficulty( StepsType st, in
void StepsDisplay::SetInternal( const SetParams &params ) void StepsDisplay::SetInternal( const SetParams &params )
{ {
DifficultyDisplayType ddt = DifficultyDisplayType_Invalid; RString sCustomDifficulty ;
if( params.st != StepsType_Invalid ) if( params.st != StepsType_Invalid )
ddt = MakeDifficultyDisplayType( params.dc, GameManager::GetStepsTypeInfo(params.st).m_StepsTypeCategory ); sCustomDifficulty = GetCustomDifficulty( params.dc, GameManager::GetStepsTypeInfo(params.st).m_StepsTypeCategory );
Message msg( "Set" ); Message msg( "Set" );
if( params.pSteps ) if( params.pSteps )
@@ -195,7 +195,7 @@ void StepsDisplay::SetInternal( const SetParams &params )
msg.SetParam( "Difficulty", params.dc ); msg.SetParam( "Difficulty", params.dc );
msg.SetParam( "IsCourseDifficulty", params.bIsCourseDifficulty ); msg.SetParam( "IsCourseDifficulty", params.bIsCourseDifficulty );
msg.SetParam( "Description", params.sDescription ); msg.SetParam( "Description", params.sDescription );
msg.SetParam( "DifficultyDisplayType", ddt ); msg.SetParam( "CustomDifficulty", sCustomDifficulty );
m_sprFrame->HandleMessage( msg ); m_sprFrame->HandleMessage( msg );
@@ -234,18 +234,10 @@ void StepsDisplay::SetInternal( const SetParams &params )
} }
else else
{ {
switch( ddt ) if( pSteps && pSteps->IsAnEdit() )
{
case DifficultyDisplayType_Invalid:
// empty string
break;
case DifficultyDisplayType_Edit:
s = params.sDescription; s = params.sDescription;
break; else
default: s = GetLocalizedCustomDifficulty( sCustomDifficulty );
s = DifficultyDisplayTypeToLocalizedString( ddt );
break;
}
} }
m_textDescription.SetText( s ); m_textDescription.SetText( s );
+1 -2
View File
@@ -360,8 +360,7 @@ RString UnlockEntry::GetDescription() const
return pSong ? pSong->GetDisplayFullTitle() : ""; return pSong ? pSong->GetDisplayFullTitle() : "";
case UnlockRewardType_Steps: case UnlockRewardType_Steps:
{ {
DifficultyDisplayType ddt = MakeDifficultyDisplayType( m_dc, StepsTypeCategory_Single ); // TODO: Is using "Single" the best thing we can do here? return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + GetLocalizedCustomDifficulty( m_dc, StepsTypeCategory_Single ); // TODO: Is using "Single" the best thing we can do here?
return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + DifficultyDisplayTypeToLocalizedString( ddt );
} }
case UnlockRewardType_Course: case UnlockRewardType_Course:
return m_Course.IsValid() ? m_Course.ToCourse()->GetDisplayFullTitle() : ""; return m_Course.IsValid() ? m_Course.ToCourse()->GetDisplayFullTitle() : "";