From 01979945d3f2a5e51c9001a7b91454f45c573785 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sun, 21 Dec 2008 01:27:33 +0000 Subject: [PATCH] CustomDifficulty fixup --- stepmania/Themes/default/Scripts/Colors.lua | 16 +++++----- stepmania/Themes/default/metrics.ini | 14 ++++++++- stepmania/Themes/pump/Languages/en.ini | 4 --- stepmania/src/CatalogXml.cpp | 3 +- stepmania/src/Difficulty.cpp | 29 ++++++++++++------- stepmania/src/Difficulty.h | 6 ++-- stepmania/src/EditMenu.cpp | 4 +-- stepmania/src/GameConstantsAndTypes.cpp | 9 +----- stepmania/src/GameState.cpp | 2 +- stepmania/src/OptionRowHandler.cpp | 7 +++-- stepmania/src/ScreenEdit.cpp | 2 +- .../src/ScreenOptionsEditCourseEntry.cpp | 2 +- stepmania/src/ScreenRanking.cpp | 2 +- stepmania/src/StepsDisplay.cpp | 2 +- stepmania/src/UnlockManager.cpp | 5 +++- 15 files changed, 60 insertions(+), 47 deletions(-) diff --git a/stepmania/Themes/default/Scripts/Colors.lua b/stepmania/Themes/default/Scripts/Colors.lua index e7891157d3..9215b86b00 100644 --- a/stepmania/Themes/default/Scripts/Colors.lua +++ b/stepmania/Themes/default/Scripts/Colors.lua @@ -11,14 +11,14 @@ function PlayerScoreColor( pn ) end local CustomDifficultyColors = { - "Beginner" = color("#ff32f8"), - "Easy" = color("#2cff00"), - "Medium" = color("#fee600"), - "Hard" = color("#ff2f39"), - "Challenge" = color("#1cd8ff"), - "Edit" = color("0.8,0.8,0.8,1"), -- gray - "Couple" = color("#ff9a00"), -- orange - "Routine" = color("#ff9a00"), -- orange + Beginner = color("#ff32f8"), + Easy = color("#2cff00"), + Medium = color("#fee600"), + Hard = color("#ff2f39"), + Challenge = color("#1cd8ff"), + Edit = color("0.8,0.8,0.8,1"), -- gray + Couple = color("#ff9a00"), -- orange + Routine = color("#ff9a00"), -- orange }; local CourseDifficultyColors = { diff --git a/stepmania/Themes/default/metrics.ini b/stepmania/Themes/default/metrics.ini index c84dc9e32e..c550654f67 100644 --- a/stepmania/Themes/default/metrics.ini +++ b/stepmania/Themes/default/metrics.ini @@ -4617,4 +4617,16 @@ PointsCheckpointHit=+1000 PointsCheckpointMiss=-200 PointsNone=0 PointsHoldHeld=+1000 -PointsHoldLetGo=-500 \ No newline at end of file +PointsHoldLetGo=-500 + +[CustomDifficulty] +Names="1,2,3" +1StepsType="StepsType_dance-single" +1Difficulty="Difficulty_Easy" +1String="Easy" +2StepsType="StepsType_pump-single" +2Difficulty="Difficulty_Hard" +2String="Crazy" +3StepsType="StepsType_pump-halfdouble" +3Difficulty="Difficulty_Invalid" +3String="HalfDouble" diff --git a/stepmania/Themes/pump/Languages/en.ini b/stepmania/Themes/pump/Languages/en.ini index c2589831f7..521b179810 100644 --- a/stepmania/Themes/pump/Languages/en.ini +++ b/stepmania/Themes/pump/Languages/en.ini @@ -3,7 +3,3 @@ Center=Center DownLeft=DownLeft DownRight=DownRight -[DifficultyAndStepsType] -Difficulty_Easy-StepsType_Pump_Single=Easy -Difficulty_Medium-StepsType_Pump_Single=Medium -Difficulty_Hard-StepsType_Pump_Single=Hard diff --git a/stepmania/src/CatalogXml.cpp b/stepmania/src/CatalogXml.cpp index 9012f317bb..925fa0a31f 100644 --- a/stepmania/src/CatalogXml.cpp +++ b/stepmania/src/CatalogXml.cpp @@ -280,7 +280,8 @@ void CatalogXml::Save( LoadingWindow *loading_window ) FOREACH_CONST( Difficulty, vDifficultiesToShow, iter ) { XNode* pNode3 = pNode2->AppendChild( "Difficulty", DifficultyToString(*iter) ); - pNode3->AppendAttr( "DisplayAs", GetLocalizedCustomDifficulty( *iter, StepsTypeCategory_Single ) ); // TODO: Fix use of Single + StepsType st = GameManager::GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; // TODO: Is this the best thing we can do here? + pNode3->AppendAttr( "DisplayAs", GetLocalizedCustomDifficulty( st, *iter ) ); // TODO: Fix use of Single } } diff --git a/stepmania/src/Difficulty.cpp b/stepmania/src/Difficulty.cpp index 99c5972f67..9b5c4cffb8 100644 --- a/stepmania/src/Difficulty.cpp +++ b/stepmania/src/Difficulty.cpp @@ -4,6 +4,8 @@ #include "ThemeMetric.h" #include "LuaManager.h" #include "LocalizedString.h" +#include "GameConstantsAndTypes.h" +#include "GameManager.h" static const char *DifficultyNames[] = { "Beginner", @@ -76,12 +78,13 @@ CourseDifficulty GetNextShownCourseDifficulty( CourseDifficulty cd ) static ThemeMetric NAMES("CustomDifficulty","Names"); -RString GetCustomDifficulty( Difficulty dc, StepsTypeCategory stc ) +RString GetCustomDifficulty( StepsType st, Difficulty dc ) { - RString s; - switch( stc ) + const StepsTypeInfo &sti = GameManager::GetStepsTypeInfo( st ); + + switch( sti.m_StepsTypeCategory ) { - DEFAULT_FAIL(stc); + DEFAULT_FAIL(sti.m_StepsTypeCategory); case StepsTypeCategory_Single: case StepsTypeCategory_Double: if( dc == Difficulty_Edit ) @@ -90,16 +93,22 @@ RString GetCustomDifficulty( Difficulty dc, StepsTypeCategory stc ) } else { - /* - // OPTIMIZATION OPPORTUNITY: cache these metrics. + // OPTIMIZATION OPPORTUNITY: cache these metrics and cache the splitting vector vsNames; split( NAMES, ",", vsNames ); - FOREACH( RString, vsNames, s ) + FOREACH( RString, vsNames, sName ) { - if( STEPS_TYPE - + ThemeMetric STEPS_TYPE("CustomDifficulty",(*sName)+"StepsType"); + if( STEPS_TYPE == StepsType_Invalid || st == STEPS_TYPE ) // match + { + ThemeMetric DIFFICULTY("CustomDifficulty",(*sName)+"Difficulty"); + if( DIFFICULTY == Difficulty_Invalid || dc == DIFFICULTY ) // match + { + ThemeMetric STRING("CustomDifficulty",(*sName)+"String"); + return STRING; + } + } } - */ return DifficultyToString( dc ); } case StepsTypeCategory_Couple: diff --git a/stepmania/src/Difficulty.h b/stepmania/src/Difficulty.h index 11fb4e3733..17bd83a77d 100644 --- a/stepmania/src/Difficulty.h +++ b/stepmania/src/Difficulty.h @@ -35,11 +35,9 @@ 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. -RString GetCustomDifficulty( Difficulty dc, StepsTypeCategory stc ); +RString GetCustomDifficulty( StepsType st, Difficulty dc ); RString GetLocalizedCustomDifficulty( const RString &sCustomDifficulty ); -static inline RString GetLocalizedCustomDifficulty( Difficulty dc, StepsTypeCategory stc ) { return GetLocalizedCustomDifficulty( GetCustomDifficulty( dc, stc ) ); } - - +static inline RString GetLocalizedCustomDifficulty( StepsType st, Difficulty dc ) { return GetLocalizedCustomDifficulty( GetCustomDifficulty(st,dc) ); } #endif diff --git a/stepmania/src/EditMenu.cpp b/stepmania/src/EditMenu.cpp index 0df0e64185..090fdb0437 100644 --- a/stepmania/src/EditMenu.cpp +++ b/stepmania/src/EditMenu.cpp @@ -476,7 +476,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) // fall through case ROW_STEPS: { - RString s = GetLocalizedCustomDifficulty( GetSelectedDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedStepsType()).m_StepsTypeCategory ); + RString s = GetLocalizedCustomDifficulty( GetSelectedStepsType(), GetSelectedDifficulty() ); m_textValue[ROW_STEPS].SetText( s ); } @@ -525,7 +525,7 @@ void EditMenu::OnRowValueChanged( EditMenuRow row ) } else { - s = GetLocalizedCustomDifficulty( GetSelectedSourceDifficulty(), GameManager::GetStepsTypeInfo(GetSelectedSourceStepsType()).m_StepsTypeCategory ); + s = GetLocalizedCustomDifficulty( GetSelectedSourceStepsType(), GetSelectedSourceDifficulty() ); } m_textValue[ROW_SOURCE_STEPS].SetText( s ); } diff --git a/stepmania/src/GameConstantsAndTypes.cpp b/stepmania/src/GameConstantsAndTypes.cpp index 5d7c0aec8c..9f4eaa1938 100644 --- a/stepmania/src/GameConstantsAndTypes.cpp +++ b/stepmania/src/GameConstantsAndTypes.cpp @@ -45,14 +45,7 @@ LuaXType( RadarCategory ); RString StepsTypeToString( StepsType st ) { - RString s = GameManager::GetStepsTypeInfo( st ).szName; - /* foo-bar -> Foo_Bar */ - s.Replace('-','_'); - for( size_t i = 0; i < s.size(); ++i ) - { - if( i == 0 || s[i-1] == '_' ) - s[i] = toupper( s[i] ); - } + RString s = GameManager::GetStepsTypeInfo( st ).szName; // "dance-single" return s; } namespace StringConversion { template<> RString ToString( const StepsType &value ) { return StepsTypeToString(value); } } diff --git a/stepmania/src/GameState.cpp b/stepmania/src/GameState.cpp index 908c606872..bc7f4d2e22 100644 --- a/stepmania/src/GameState.cpp +++ b/stepmania/src/GameState.cpp @@ -2288,7 +2288,7 @@ public: for( unsigned i=0; iGetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory ); + RString sDifficulty = GetLocalizedCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty() ); lua_pushstring( L, sDifficulty ); lua_pushstring( L, pSteps->GetDescription() ); diff --git a/stepmania/src/OptionRowHandler.cpp b/stepmania/src/OptionRowHandler.cpp index 24fa7624d3..f1e8c12ee5 100644 --- a/stepmania/src/OptionRowHandler.cpp +++ b/stepmania/src/OptionRowHandler.cpp @@ -447,7 +447,7 @@ class OptionRowHandlerListSteps : public OptionRowHandlerList if( pSteps->IsAnEdit() ) s = pSteps->GetDescription(); else - s = GetLocalizedCustomDifficulty( pSteps->GetDifficulty(), GameManager::GetStepsTypeInfo(pSteps->m_StepsType).m_StepsTypeCategory ); + s = GetLocalizedCustomDifficulty( pSteps->m_StepsType, pSteps->GetDifficulty() ); } s += ssprintf( " %d", pSteps->GetMeter() ); m_Def.m_vsChoices.push_back( s ); @@ -560,7 +560,7 @@ public: } else { - s = GetLocalizedCustomDifficulty( dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ); + s = GetLocalizedCustomDifficulty( GAMESTATE->m_stEdit, dc ); } m_Def.m_vsChoices.push_back( s ); } @@ -736,7 +736,8 @@ class OptionRowHandlerListDifficulties: public OptionRowHandlerList FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), d ) { - RString s = GetLocalizedCustomDifficulty( *d, StepsTypeCategory_Single ); // TODO: Fix use of Single + StepsType st = GameManager::GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; // TODO: Is this the best thing we can do here? + RString s = GetLocalizedCustomDifficulty( st, *d ); m_Def.m_vsChoices.push_back( s ); GameCommand mc; diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index 9e5e8e78ab..98448d3227 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -2889,7 +2889,7 @@ void ScreenEdit::HandleMainMenuChoice( MainMenuChoice c, const vector &iAns g_StepsInformation.rows[difficulty].choices.clear(); FOREACH_ENUM( Difficulty, dc ) { - g_StepsInformation.rows[difficulty].choices.push_back( "|" + GetLocalizedCustomDifficulty( dc, GameManager::GetStepsTypeInfo( pSteps->m_StepsType ).m_StepsTypeCategory ) ); + g_StepsInformation.rows[difficulty].choices.push_back( "|" + GetLocalizedCustomDifficulty( pSteps->m_StepsType, dc ) ); } g_StepsInformation.rows[difficulty].iDefaultChoice = pSteps->GetDifficulty(); g_StepsInformation.rows[difficulty].bEnabled = (EDIT_MODE.GetValue() >= EditMode_Full); diff --git a/stepmania/src/ScreenOptionsEditCourseEntry.cpp b/stepmania/src/ScreenOptionsEditCourseEntry.cpp index c0522d8c05..6bf9ed2432 100644 --- a/stepmania/src/ScreenOptionsEditCourseEntry.cpp +++ b/stepmania/src/ScreenOptionsEditCourseEntry.cpp @@ -127,7 +127,7 @@ void ScreenOptionsEditCourseEntry::Init() pHand->m_Def.m_vsChoices.push_back( "(any)" ); FOREACH_CONST( Difficulty, CommonMetrics::DIFFICULTIES_TO_SHOW.GetValue(), dc ) { - pHand->m_Def.m_vsChoices.push_back( GetLocalizedCustomDifficulty( *dc, GameManager::GetStepsTypeInfo( GAMESTATE->m_stEdit ).m_StepsTypeCategory ) ); + pHand->m_Def.m_vsChoices.push_back( GetLocalizedCustomDifficulty(GAMESTATE->m_stEdit, *dc) ); } vHands.push_back( pHand ); diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 1c007602fe..19e67d7297 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -64,7 +64,7 @@ void ScreenRanking::Init() POINTS_START_Y.Load( m_sName, "PointsStartY" ); TIME_START_X.Load( m_sName, "TimeStartX" ); TIME_START_Y.Load( m_sName, "TimeStartY" ); - STEPS_TYPE_COLOR.Load( m_sName,STEPS_TYPE_COLOR_NAME,5 ); + STEPS_TYPE_COLOR.Load( m_sName,STEPS_TYPE_COLOR_NAME,NUM_RANKING_LINES ); if( RANKING_TYPE == RankingType_Category ) { diff --git a/stepmania/src/StepsDisplay.cpp b/stepmania/src/StepsDisplay.cpp index cceba9e949..fdcf1d8fb8 100644 --- a/stepmania/src/StepsDisplay.cpp +++ b/stepmania/src/StepsDisplay.cpp @@ -183,7 +183,7 @@ void StepsDisplay::SetInternal( const SetParams ¶ms ) { RString sCustomDifficulty ; if( params.st != StepsType_Invalid ) - sCustomDifficulty = GetCustomDifficulty( params.dc, GameManager::GetStepsTypeInfo(params.st).m_StepsTypeCategory ); + sCustomDifficulty = GetCustomDifficulty( params.st, params.dc ); Message msg( "Set" ); if( params.pSteps ) diff --git a/stepmania/src/UnlockManager.cpp b/stepmania/src/UnlockManager.cpp index 4da898ffbb..b4967734ee 100644 --- a/stepmania/src/UnlockManager.cpp +++ b/stepmania/src/UnlockManager.cpp @@ -15,6 +15,8 @@ #include #include "CommonMetrics.h" #include "LuaManager.h" +#include "GameManager.h" +#include "Style.h" UnlockManager* UNLOCKMAN = NULL; // global and accessable from anywhere in our program @@ -360,7 +362,8 @@ RString UnlockEntry::GetDescription() const return pSong ? pSong->GetDisplayFullTitle() : ""; case UnlockRewardType_Steps: { - return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + GetLocalizedCustomDifficulty( m_dc, StepsTypeCategory_Single ); // TODO: Is using "Single" the best thing we can do here? + StepsType st = GameManager::GetHowToPlayStyleForGame( GAMESTATE->m_pCurGame )->m_StepsType; // TODO: Is this the best thing we can do here? + return (pSong ? pSong->GetDisplayFullTitle() : "") + ", " + GetLocalizedCustomDifficulty( st, m_dc ); } case UnlockRewardType_Course: return m_Course.IsValid() ? m_Course.ToCourse()->GetDisplayFullTitle() : "";