metrics cleaup: Remove duplicated "ToShow" and "ToHide" parsing logic

don't show hidden StepsTypes in EditMenu
This commit is contained in:
Chris Danford
2005-03-24 21:44:03 +00:00
parent e1ab8c5b77
commit 5d8456e3ea
12 changed files with 313 additions and 350 deletions
+1 -32
View File
@@ -9,6 +9,7 @@ DefaultCpuModifiers=
JoinPauseSeconds=0.8 JoinPauseSeconds=0.8
DifficultiesToShow=beginner,easy,medium,hard,challenge DifficultiesToShow=beginner,easy,medium,hard,challenge
CourseDifficultiesToShow=easy,regular,difficult CourseDifficultiesToShow=easy,regular,difficult
StepsTypesToHide=dance-couple,dance-solo,pump-halfdouble,lights-cabinet
ScreenWidth=640 ScreenWidth=640
ScreenHeight=480 ScreenHeight=480
OverlayScreens=ScreenSystemLayer OverlayScreens=ScreenSystemLayer
@@ -3323,7 +3324,6 @@ Class=ScreenRanking
Fallback=ScreenAttract Fallback=ScreenAttract
NextScreen=ScreenUnlock NextScreen=ScreenUnlock
TimerSeconds=-1 TimerSeconds=-1
StepsTypesToHide=dance-couple,dance-solo,pump-halfdouble StepsTypesToHide=dance-couple,dance-solo,pump-halfdouble
ShowCategories=1 ShowCategories=1
CoursesToShow=Courses/DDRMAX/NaokiStandard.crs,Courses/DDRMAX/ParanoiaBrothers.crs,Courses/Samples/PlayersBest1-4.crs CoursesToShow=Courses/DDRMAX/NaokiStandard.crs,Courses/DDRMAX/ParanoiaBrothers.crs,Courses/Samples/PlayersBest1-4.crs
@@ -4237,34 +4237,6 @@ ShowStyleDouble=1
ShowStyleCouple=1 ShowStyleCouple=1
ShowStyleSolo=1 ShowStyleSolo=1
ShowStyleReal=1 ShowStyleReal=1
ShowStepsTypeDance-single=1
ShowStepsTypeDance-double=1
ShowStepsTypeDance-couple=1
ShowStepsTypeDance-solo=1
ShowStepsTypePump-single=1
ShowStepsTypePump-halfdouble=1
ShowStepsTypePump-double=1
ShowStepsTypePump-couple=1
ShowStepsTypeEz2-single=1
ShowStepsTypeEz2-double=1
ShowStepsTypeEz2-real=1
ShowStepsTypePara-single=1
ShowStepsTypePara-versus=1
ShowStepsTypeDs3ddx-single=1
ShowStepsTypeBm-single5=1
ShowStepsTypeBm-double5=1
ShowStepsTypeBm-single7=1
ShowStepsTypeBm-double7=1
ShowStepsTypeManiax-single=1
ShowStepsTypeManiax-double=1
ShowStepsTypeTechno-single4=1
ShowStepsTypeTechno-single5=1
ShowStepsTypeTechno-single8=1
ShowStepsTypeTechno-double4=1
ShowStepsTypeTechno-double5=1
ShowStepsTypePnm-five=1
ShowStepsTypePnm-nine=1
ShowStepsTypeLights-cabinet=1
InternetRankingHomeUrl= InternetRankingHomeUrl=
InternetRankingUploadUrl= InternetRankingUploadUrl=
InternetRankingViewGuidUrl= InternetRankingViewGuidUrl=
@@ -4286,9 +4258,6 @@ SortLevel5Color=0,1,0,1
[Inventory] [Inventory]
ItemUseRateSeconds=0 ItemUseRateSeconds=0
[OptionRowHandler]
StepsTypesToHide=
[ScreenMemcardSaveEditsAfterDeleteSteps] [ScreenMemcardSaveEditsAfterDeleteSteps]
[ScreenMemcardSaveEditsAfterSave] [ScreenMemcardSaveEditsAfterSave]
+14 -29
View File
@@ -22,7 +22,6 @@
#define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str())) #define SHOW_PLAY_MODE(pm) THEME->GetMetricB("CatalogXml",ssprintf("ShowPlayMode%s",PlayModeToString(pm).c_str()))
#define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str())) #define SHOW_STYLE(ps) THEME->GetMetricB("CatalogXml",ssprintf("ShowStyle%s",Capitalize((ps)->m_szName).c_str()))
#define SHOW_STEPS_TYPE(st) THEME->GetMetricB("CatalogXml",ssprintf("ShowStepsType%s",Capitalize(GAMEMAN->StepsTypeToString(st)).c_str()))
#define INTERNET_RANKING_HOME_URL THEME->GetMetric ("CatalogXml","InternetRankingHomeUrl") #define INTERNET_RANKING_HOME_URL THEME->GetMetric ("CatalogXml","InternetRankingHomeUrl")
#define INTERNET_RANKING_UPLOAD_URL THEME->GetMetric ("CatalogXml","InternetRankingUploadUrl") #define INTERNET_RANKING_UPLOAD_URL THEME->GetMetric ("CatalogXml","InternetRankingUploadUrl")
#define INTERNET_RANKING_VIEW_GUID_URL THEME->GetMetric ("CatalogXml","InternetRankingViewGuidUrl") #define INTERNET_RANKING_VIEW_GUID_URL THEME->GetMetric ("CatalogXml","InternetRankingViewGuidUrl")
@@ -39,11 +38,9 @@ void SaveCatalogXml()
XNode xml; XNode xml;
xml.m_sName = "Catalog"; xml.m_sName = "Catalog";
{ const vector<StepsType> &vStepsTypesToShow = STEPS_TYPES_TO_SHOW.GetValue();
bool ShowStepsType[NUM_STEPS_TYPES];
FOREACH_StepsType( st )
ShowStepsType[st] = SHOW_STEPS_TYPE( st );
{
XNode* pNode = xml.AppendChild( "Songs" ); XNode* pNode = xml.AppendChild( "Songs" );
vector<Song*> vpSongs = SONGMAN->GetAllSongs(); vector<Song*> vpSongs = SONGMAN->GetAllSongs();
@@ -64,16 +61,11 @@ void SaveCatalogXml()
pSongNode->AppendChild( "MainTitle", pSong->GetDisplayMainTitle() ); pSongNode->AppendChild( "MainTitle", pSong->GetDisplayMainTitle() );
pSongNode->AppendChild( "SubTitle", pSong->GetDisplaySubTitle() ); pSongNode->AppendChild( "SubTitle", pSong->GetDisplaySubTitle() );
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow(); FOREACH_CONST( StepsType, vStepsTypesToShow, st )
FOREACH_StepsType( st )
{ {
if( !ShowStepsType[st] ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), dc )
continue; // skip
for( set<Difficulty>::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
{ {
Steps* pSteps = pSong->GetStepsByDifficulty( st, *iter, false ); // no autogen Steps* pSteps = pSong->GetStepsByDifficulty( *st, *dc, false ); // no autogen
if( pSteps == NULL ) if( pSteps == NULL )
continue; // skip continue; // skip
@@ -111,16 +103,13 @@ void SaveCatalogXml()
pCourseNode->AppendChild( "SubTitle", pCourse->GetDisplaySubTitle() ); pCourseNode->AppendChild( "SubTitle", pCourse->GetDisplaySubTitle() );
pCourseNode->AppendChild( "HasMods", pCourse->HasMods() ); pCourseNode->AppendChild( "HasMods", pCourse->HasMods() );
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); const vector<CourseDifficulty> &vDiffs = DIFFICULTIES_TO_SHOW.GetValue();
FOREACH_StepsType( st ) FOREACH_CONST( StepsType, vStepsTypesToShow, st )
{ {
if( !SHOW_STEPS_TYPE(st) ) FOREACH_CONST( CourseDifficulty, vDiffs, dc )
continue; // skip
for( set<CourseDifficulty>::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
{ {
Trail *pTrail = pCourse->GetTrail( st, *iter ); Trail *pTrail = pCourse->GetTrail( *st, *dc );
if( pTrail == NULL ) if( pTrail == NULL )
continue; continue;
if( !pTrail->m_vEntries.size() ) if( !pTrail->m_vEntries.size() )
@@ -143,8 +132,7 @@ void SaveCatalogXml()
XNode* pNode = xml.AppendChild( "Types" ); XNode* pNode = xml.AppendChild( "Types" );
{ {
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow(); FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
FOREACHS_CONST( Difficulty, vDiffs, iter )
{ {
XNode* pNode2 = pNode->AppendChild( "Difficulty", DifficultyToString(*iter) ); XNode* pNode2 = pNode->AppendChild( "Difficulty", DifficultyToString(*iter) );
pNode2->AppendAttr( "DisplayAs", DifficultyToThemedString(*iter) ); pNode2->AppendAttr( "DisplayAs", DifficultyToThemedString(*iter) );
@@ -152,8 +140,7 @@ void SaveCatalogXml()
} }
{ {
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); FOREACH_CONST( CourseDifficulty, COURSE_DIFFICULTIES_TO_SHOW.GetValue(), iter )
FOREACHS_CONST( CourseDifficulty, vDiffs, iter )
{ {
XNode* pNode2 = pNode->AppendChild( "CourseDifficulty", CourseDifficultyToString(*iter) ); XNode* pNode2 = pNode->AppendChild( "CourseDifficulty", CourseDifficultyToString(*iter) );
pNode2->AppendAttr( "DisplayAs", CourseDifficultyToThemedString(*iter) ); pNode2->AppendAttr( "DisplayAs", CourseDifficultyToThemedString(*iter) );
@@ -161,12 +148,10 @@ void SaveCatalogXml()
} }
{ {
vector<StepsType> vStepsTypes; vector<StepsType> vStepsTypesToShow;
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypes ); GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, vStepsTypesToShow );
FOREACH_CONST( StepsType, vStepsTypes, iter ) FOREACH_CONST( StepsType, vStepsTypesToShow, iter )
{ {
if( !SHOW_STEPS_TYPE(*iter) )
continue;
XNode* pNode2 = pNode->AppendChild( "StepsType", GAMEMAN->StepsTypeToString(*iter) ); XNode* pNode2 = pNode->AppendChild( "StepsType", GAMEMAN->StepsTypeToString(*iter) );
pNode2->AppendAttr( "DisplayAs", GAMEMAN->StepsTypeToThemedString(*iter) ); pNode2->AppendAttr( "DisplayAs", GAMEMAN->StepsTypeToThemedString(*iter) );
} }
+58 -22
View File
@@ -2,6 +2,9 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "Foreach.h" #include "Foreach.h"
#include "GameManager.h"
#include "RageLog.h"
#include "GameState.h"
CString PLAYER_COLOR_NAME( size_t p ) { return ssprintf("ColorP%d",int(p+1)); } CString PLAYER_COLOR_NAME( size_t p ) { return ssprintf("ColorP%d",int(p+1)); }
@@ -16,22 +19,24 @@ ThemeMetric<CString> WINDOW_TITLE ("Common","WindowTitle");
ThemeMetric<bool> HOME_EDIT_MODE ("Common","HomeEditMode"); ThemeMetric<bool> HOME_EDIT_MODE ("Common","HomeEditMode");
ThemeMetric<int> MAX_COURSE_ENTRIES_BEFORE_VARIOUS ("Common","MaxCourseEntriesBeforeShowVarious"); ThemeMetric<int> MAX_COURSE_ENTRIES_BEFORE_VARIOUS ("Common","MaxCourseEntriesBeforeShowVarious");
ThemeMetric<float> TICK_EARLY_SECONDS ("ScreenGameplay","TickEarlySeconds"); ThemeMetric<float> TICK_EARLY_SECONDS ("ScreenGameplay","TickEarlySeconds");
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW ("Common","DifficultiesToShow");
ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW ("Common","CourseDifficultiesToShow");
ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW ("Common","StepsTypesToHide");
class ThemeMetricDifficultiesToShow : ThemeMetric<CString> ThemeMetricDifficultiesToShow::ThemeMetricDifficultiesToShow( const CString& sGroup, const CString& sName ) :
ThemeMetric<CString>(sGroup,sName)
{ {
public: ASSERT( sName.Right(6) == "ToShow" );
set<Difficulty> m_v; }
void ThemeMetricDifficultiesToShow::Read()
ThemeMetricDifficultiesToShow() : ThemeMetric<CString>("Common","DifficultiesToShow") {}
void Read()
{ {
ThemeMetric<CString>::Read(); ThemeMetric<CString>::Read();
m_v.clear(); m_v.clear();
CStringArray v; CStringArray v;
split( GetValue(), ",", v ); split( ThemeMetric<CString>::GetValue(), ",", v );
ASSERT( v.size() > 0 ); ASSERT( v.size() > 0 );
FOREACH_CONST( CString, v, i ) FOREACH_CONST( CString, v, i )
@@ -39,28 +44,25 @@ public:
Difficulty d = StringToDifficulty( *i ); Difficulty d = StringToDifficulty( *i );
if( d == DIFFICULTY_INVALID ) if( d == DIFFICULTY_INVALID )
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", i->c_str() );
m_v.insert( d ); m_v.push_back( d );
} }
} }
}; const vector<Difficulty>& ThemeMetricDifficultiesToShow::GetValue() { return m_v; }
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
const set<Difficulty>& CommonMetrics::GetDifficultiesToShow() { return DIFFICULTIES_TO_SHOW.m_v; }
class ThemeMetricCourseDifficultiesToShow : ThemeMetric<CString> ThemeMetricCourseDifficultiesToShow::ThemeMetricCourseDifficultiesToShow( const CString& sGroup, const CString& sName ) :
ThemeMetric<CString>(sGroup,sName)
{ {
public: ASSERT( sName.Right(6) == "ToShow" );
set<CourseDifficulty> m_v; }
void ThemeMetricCourseDifficultiesToShow::Read()
ThemeMetricCourseDifficultiesToShow() : ThemeMetric<CString>("Common","CourseDifficultiesToShow") {}
void Read()
{ {
ThemeMetric<CString>::Read(); ThemeMetric<CString>::Read();
m_v.clear(); m_v.clear();
CStringArray v; CStringArray v;
split( GetValue(), ",", v ); split( ThemeMetric<CString>::GetValue(), ",", v );
ASSERT( v.size() > 0 ); ASSERT( v.size() > 0 );
FOREACH_CONST( CString, v, i ) FOREACH_CONST( CString, v, i )
@@ -68,12 +70,46 @@ public:
CourseDifficulty d = StringToCourseDifficulty( *i ); CourseDifficulty d = StringToCourseDifficulty( *i );
if( d == DIFFICULTY_INVALID ) if( d == DIFFICULTY_INVALID )
RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow", i->c_str() ); RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow", i->c_str() );
m_v.insert( d ); m_v.push_back( d );
} }
} }
}; const vector<CourseDifficulty>& ThemeMetricCourseDifficultiesToShow::GetValue() { return m_v; }
ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW;
const set<CourseDifficulty>& CommonMetrics::GetCourseDifficultiesToShow() { return COURSE_DIFFICULTIES_TO_SHOW.m_v; }
static void RemoveStepsTypes( vector<StepsType>& inout, CString sStepsTypesToRemove )
{
CStringArray v;
split( sStepsTypesToRemove, ",", v );
ASSERT( v.size() > 0 );
// subtract StepsTypes
FOREACH_CONST( CString, v, i )
{
StepsType st = GameManager::StringToStepsType(*i);
if( st == STEPS_TYPE_INVALID )
LOG->Warn( "Invalid StepsType value '%s' in '%s'", i->c_str(), sStepsTypesToRemove.c_str() );
const vector<StepsType>::iterator iter = find( inout.begin(), inout.end(), st );
if( iter != inout.end() )
inout.erase( iter );
}
}
ThemeMetricStepsTypesToShow::ThemeMetricStepsTypesToShow( const CString& sGroup, const CString& sName ) :
ThemeMetric<CString>(sGroup,sName)
{
ASSERT( sName.Right(6) == "ToHide" );
}
void ThemeMetricStepsTypesToShow::Read()
{
ThemeMetric<CString>::Read();
m_v.clear();
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_v );
RemoveStepsTypes( m_v, ThemeMetric<CString>::GetValue() );
}
const vector<StepsType>& ThemeMetricStepsTypesToShow::GetValue() { return m_v; }
CString THEME_OPTION_ITEM( CString s, bool bOptional ) CString THEME_OPTION_ITEM( CString s, bool bOptional )
{ {
+40 -5
View File
@@ -6,7 +6,44 @@
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "PlayerNumber.h" #include "PlayerNumber.h"
#include "Difficulty.h" #include "Difficulty.h"
#include "GameConstantsAndTypes.h"
//
// Types
//
class ThemeMetricDifficultiesToShow : ThemeMetric<CString>
{
public:
ThemeMetricDifficultiesToShow( const CString& sGroup, const CString& sName );
void Read();
const vector<Difficulty> &GetValue();
private:
vector<Difficulty> m_v;
};
class ThemeMetricCourseDifficultiesToShow : ThemeMetric<CString>
{
public:
ThemeMetricCourseDifficultiesToShow( const CString& sGroup, const CString& sName );
void Read();
const vector<CourseDifficulty> &GetValue();
private:
vector<CourseDifficulty> m_v;
};
class ThemeMetricStepsTypesToShow : ThemeMetric<CString>
{
public:
ThemeMetricStepsTypesToShow( const CString& sGroup, const CString& sName );
void Read();
const vector<StepsType> &GetValue();
private:
vector<StepsType> m_v;
};
//
// Metrics
//
extern ThemeMetric<CString> INITIAL_SCREEN; extern ThemeMetric<CString> INITIAL_SCREEN;
extern ThemeMetric<CString> FIRST_RUN_INITIAL_SCREEN; extern ThemeMetric<CString> FIRST_RUN_INITIAL_SCREEN;
extern ThemeMetric<CString> DEFAULT_MODIFIERS; extern ThemeMetric<CString> DEFAULT_MODIFIERS;
@@ -17,14 +54,12 @@ extern ThemeMetric<CString> WINDOW_TITLE;
extern ThemeMetric<bool> HOME_EDIT_MODE; extern ThemeMetric<bool> HOME_EDIT_MODE;
extern ThemeMetric<int> MAX_COURSE_ENTRIES_BEFORE_VARIOUS; extern ThemeMetric<int> MAX_COURSE_ENTRIES_BEFORE_VARIOUS;
extern ThemeMetric<float> TICK_EARLY_SECONDS; extern ThemeMetric<float> TICK_EARLY_SECONDS;
extern ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
extern ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW;
extern ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW;
CString THEME_OPTION_ITEM( CString s, bool bOptional ); CString THEME_OPTION_ITEM( CString s, bool bOptional );
namespace CommonMetrics
{
const set<Difficulty>& GetDifficultiesToShow();
const set<CourseDifficulty>& GetCourseDifficultiesToShow();
}
#endif #endif
+1 -2
View File
@@ -286,9 +286,8 @@ void DifficultyList::SetFromGameState()
// FIXME: This clamps to between the min and the max difficulty, but // FIXME: This clamps to between the min and the max difficulty, but
// it really should round to the nearest difficulty that's in // it really should round to the nearest difficulty that's in
// DIFFICULTIES_TO_SHOW. // DIFFICULTIES_TO_SHOW.
const set<Difficulty> &diffs = CommonMetrics::GetDifficultiesToShow();
unsigned i=0; unsigned i=0;
FOREACHS_CONST( Difficulty, diffs, d ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d )
{ {
m_Rows.resize( m_Rows.size()+1 ); m_Rows.resize( m_Rows.size()+1 );
+1 -1
View File
@@ -121,7 +121,7 @@ EditMenu::EditMenu()
// fill in data structures // fill in data structures
SONGMAN->GetGroupNames( m_sGroups ); SONGMAN->GetGroupNames( m_sGroups );
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_StepsTypes ); m_StepsTypes = STEPS_TYPES_TO_SHOW.GetValue();
if( HOME_EDIT_MODE ) if( HOME_EDIT_MODE )
{ {
m_vDifficulties.push_back( DIFFICULTY_EDIT ); m_vDifficulties.push_back( DIFFICULTY_EDIT );
+7 -6
View File
@@ -33,6 +33,7 @@
#include "CommonMetrics.h" #include "CommonMetrics.h"
#include "Foreach.h" #include "Foreach.h"
#include "LuaReference.h" #include "LuaReference.h"
#include "CommonMetrics.h"
#include <ctime> #include <ctime>
#include <set> #include <set>
@@ -1702,7 +1703,7 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir ) bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
{ {
const set<Difficulty> &asDiff = CommonMetrics::GetDifficultiesToShow(); const vector<Difficulty> &v = DIFFICULTIES_TO_SHOW.GetValue();
Difficulty d = m_PreferredDifficulty[pn]; Difficulty d = m_PreferredDifficulty[pn];
while( 1 ) while( 1 )
@@ -1710,7 +1711,7 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
d = (Difficulty)(d+dir); d = (Difficulty)(d+dir);
if( d < 0 || d >= NUM_DIFFICULTIES ) if( d < 0 || d >= NUM_DIFFICULTIES )
return false; return false;
if( asDiff.find(d) == asDiff.end() ) if( find(v.begin(), v.end(), d) == v.end() )
continue; /* not available */ continue; /* not available */
} }
@@ -1734,7 +1735,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
/* If we have a course selected, only choose among difficulties available in the course. */ /* If we have a course selected, only choose among difficulties available in the course. */
const Course *pCourse = this->m_pCurCourse; const Course *pCourse = this->m_pCurCourse;
const set<CourseDifficulty> &asDiff = CommonMetrics::GetCourseDifficultiesToShow(); const vector<CourseDifficulty> &v = COURSE_DIFFICULTIES_TO_SHOW.GetValue();
CourseDifficulty cd = m_PreferredCourseDifficulty[pn]; CourseDifficulty cd = m_PreferredCourseDifficulty[pn];
while( 1 ) while( 1 )
@@ -1742,7 +1743,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
cd = (CourseDifficulty)(cd+dir); cd = (CourseDifficulty)(cd+dir);
if( cd < 0 || cd >= NUM_DIFFICULTIES ) if( cd < 0 || cd >= NUM_DIFFICULTIES )
return false; return false;
if( asDiff.find(cd) == asDiff.end() ) if( find(v.begin(),v.end(),cd) == v.end() )
continue; /* not available */ continue; /* not available */
if( !pCourse || pCourse->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType, cd ) ) if( !pCourse || pCourse->GetTrail( GAMESTATE->GetCurrentStyle()->m_StepsType, cd ) )
break; break;
@@ -1753,8 +1754,8 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
bool GameState::IsCourseDifficultyShown( CourseDifficulty cd ) bool GameState::IsCourseDifficultyShown( CourseDifficulty cd )
{ {
const set<CourseDifficulty> &asDiff = CommonMetrics::GetCourseDifficultiesToShow(); const vector<CourseDifficulty> &v = COURSE_DIFFICULTIES_TO_SHOW.GetValue();
return asDiff.find(cd) != asDiff.end(); return find(v.begin(), v.end(), cd) != v.end();
} }
Difficulty GameState::GetEasiestNotesDifficulty() const Difficulty GameState::GetEasiestNotesDifficulty() const
+2 -20
View File
@@ -24,8 +24,6 @@
#define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1))) #define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1)))
#define ENTRY_DEFAULT(s) THEME->GetMetric ("ScreenOptionsMaster",(s) + "Default") #define ENTRY_DEFAULT(s) THEME->GetMetric ("ScreenOptionsMaster",(s) + "Default")
#define STEPS_TYPES_TO_HIDE THEME->GetMetric ("OptionRowHandler","StepsTypesToHide")
static void SelectExactlyOne( int iSelection, vector<bool> &vbSelectedOut ) static void SelectExactlyOne( int iSelection, vector<bool> &vbSelectedOut )
{ {
for( int i=0; i<(int)vbSelectedOut.size(); i++ ) for( int i=0; i<(int)vbSelectedOut.size(); i++ )
@@ -429,8 +427,6 @@ public:
ASSERT( sParam.size() ); ASSERT( sParam.size() );
m_sName = sParam; m_sName = sParam;
const set<Difficulty> &vDifficulties = CommonMetrics::GetDifficultiesToShow();
defOut.bOneChoiceForAllPlayers = true; defOut.bOneChoiceForAllPlayers = true;
defOut.name = "Difficulty"; defOut.name = "Difficulty";
Default.m_dc = DIFFICULTY_INVALID; Default.m_dc = DIFFICULTY_INVALID;
@@ -443,7 +439,7 @@ public:
ListEntries.push_back( mc ); ListEntries.push_back( mc );
} }
FOREACHS_CONST( Difficulty, vDifficulties, d ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), d )
{ {
CString s = DifficultyToThemedString( *d ); CString s = DifficultyToThemedString( *d );
@@ -864,21 +860,7 @@ public:
defOut.m_bAllowThemeItems = false; // we theme the text ourself defOut.m_bAllowThemeItems = false; // we theme the text ourself
// calculate which StepsTypes to show // calculate which StepsTypes to show
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, m_vStepsTypesToShow ); m_vStepsTypesToShow = STEPS_TYPES_TO_SHOW.GetValue();
// subtract hidden StepsTypes
vector<CString> vsStepsTypesToHide;
split( STEPS_TYPES_TO_HIDE, ",", vsStepsTypesToHide, true );
for( unsigned i=0; i<vsStepsTypesToHide.size(); i++ )
{
StepsType st = GameManager::StringToStepsType(vsStepsTypesToHide[i]);
if( st != STEPS_TYPE_INVALID )
{
const vector<StepsType>::iterator iter = find( m_vStepsTypesToShow.begin(), m_vStepsTypesToShow.end(), st );
if( iter != m_vStepsTypesToShow.end() )
m_vStepsTypesToShow.erase( iter );
}
}
FOREACH_CONST( StepsType, m_vStepsTypesToShow, st ) FOREACH_CONST( StepsType, m_vStepsTypesToShow, st )
{ {
+2 -4
View File
@@ -84,8 +84,7 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
if( GAMESTATE->IsCourseMode() ) if( GAMESTATE->IsCourseMode() )
{ {
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow(); FOREACH_CONST( CourseDifficulty, COURSE_DIFFICULTIES_TO_SHOW.GetValue(), iter )
FOREACHS_CONST( CourseDifficulty, vDiffs, iter )
{ {
fActual += pProfile->GetCoursesActual(st,*iter); fActual += pProfile->GetCoursesActual(st,*iter);
fPossible += pProfile->GetCoursesPossible(st,*iter); fPossible += pProfile->GetCoursesPossible(st,*iter);
@@ -93,8 +92,7 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
} }
else else
{ {
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow(); FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
FOREACHS_CONST( Difficulty, vDiffs, iter )
{ {
fActual += pProfile->GetSongsActual(st,*iter); fActual += pProfile->GetSongsActual(st,*iter);
fPossible += pProfile->GetSongsPossible(st,*iter); fPossible += pProfile->GetSongsPossible(st,*iter);
+6 -13
View File
@@ -18,11 +18,10 @@
#include "PlayerState.h" #include "PlayerState.h"
#include "ProfileManager.h" #include "ProfileManager.h"
#include "StatsManager.h" #include "StatsManager.h"
#include "CommonMetrics.h"
// HACK: This belongs in ScreenDemonstration
#define DIFFICULTIES_TO_SHOW THEME->GetMetric ("ScreenDemonstration","DifficultiesToShow")
#define SHOW_COURSE_MODIFIERS THEME->GetMetricB("ScreenJukebox","ShowCourseModifiers") #define SHOW_COURSE_MODIFIERS THEME->GetMetricB("ScreenJukebox","ShowCourseModifiers")
static ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW_HERE("ScreenDemonstration","DifficultiesToShow");
REGISTER_SCREEN_CLASS( ScreenJukebox ); REGISTER_SCREEN_CLASS( ScreenJukebox );
@@ -41,20 +40,15 @@ bool ScreenJukebox::SetSong( bool bDemonstration )
if ( vSongs.size() == 0 ) if ( vSongs.size() == 0 )
SONGMAN->GetSongs( vSongs, GAMESTATE->m_sPreferredSongGroup ); SONGMAN->GetSongs( vSongs, GAMESTATE->m_sPreferredSongGroup );
// //
// Calculate what difficulties to show // Calculate what difficulties to show
// //
CStringArray asBits;
vector<Difficulty> vDifficultiesToShow; vector<Difficulty> vDifficultiesToShow;
if( bDemonstration ) if( bDemonstration )
{ {
split( DIFFICULTIES_TO_SHOW, ",", asBits ); // HACK: This belongs in ScreenDemonstration
for( unsigned i=0; i<asBits.size(); i++ ) vDifficultiesToShow = DIFFICULTIES_TO_SHOW_HERE.GetValue();
{
Difficulty dc = StringToDifficulty( asBits[i] );
if( dc != DIFFICULTY_INVALID )
vDifficultiesToShow.push_back( dc );
}
} }
else else
{ {
@@ -69,8 +63,7 @@ bool ScreenJukebox::SetSong( bool bDemonstration )
} }
} }
if( vDifficultiesToShow.empty() ) ASSERT( !vDifficultiesToShow.empty() )
vDifficultiesToShow.push_back( DIFFICULTY_EASY );
// //
// Search for a Song and Steps to play during the demo // Search for a Song and Steps to play during the demo
+30 -67
View File
@@ -51,11 +51,12 @@ CString STEPS_TYPE_COLOR_NAME( size_t i ) { return ssprintf("StepsTypeColor%d",i
REGISTER_SCREEN_CLASS( ScreenRanking ); REGISTER_SCREEN_CLASS( ScreenRanking );
ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName ), ScreenRanking::ScreenRanking( CString sClassName ) : ScreenAttract( sClassName ),
STEPS_TYPES_TO_HIDE (m_sName,"StepsTypesToHide"), STEPS_TYPES_TO_SHOW (m_sName,"StepsTypesToHide"),
DIFFICULTIES_TO_SHOW (m_sName,"DifficultiesToShow"),
SHOW_CATEGORIES (m_sName,"ShowCategories"), SHOW_CATEGORIES (m_sName,"ShowCategories"),
SHOW_ALL_STEPS_SCORES (m_sName,"ShowAllStepsScores"), SHOW_ALL_STEPS_SCORES (m_sName,"ShowAllStepsScores"),
SHOW_ALL_COURSE_SCORES (m_sName,"ShowAllCourseScores"), SHOW_ALL_COURSE_SCORES (m_sName,"ShowAllCourseScores"),
DIFFICULTIES_TO_SHOW (m_sName,"DifficultiesToShow"),
SECONDS_PER_PAGE (m_sName,"SecondsPerPage"), SECONDS_PER_PAGE (m_sName,"SecondsPerPage"),
PAGE_FADE_SECONDS (m_sName,"PageFadeSeconds"), PAGE_FADE_SECONDS (m_sName,"PageFadeSeconds"),
PERCENT_DECIMAL_PLACES (m_sName,"PercentDecimalPlaces"), PERCENT_DECIMAL_PLACES (m_sName,"PercentDecimalPlaces"),
@@ -164,22 +165,12 @@ void ScreenRanking::Init()
} }
} }
// make the list of difficulties to show
{
vector<CString> sShowDiffs;
split( DIFFICULTIES_TO_SHOW, ",", sShowDiffs, true );
for( vector<CString>::const_iterator iter = sShowDiffs.begin(); iter != sShowDiffs.end(); iter++ )
{
m_vDiffsToShow.push_back( StringToDifficulty( *iter ) );
}
}
// init Actors for all_steps // init Actors for all_steps
{ {
const vector<Difficulty> &v = DIFFICULTIES_TO_SHOW.GetValue();
FOREACH_Difficulty( d ) FOREACH_Difficulty( d )
{ {
bool bShowThis = find(m_vDiffsToShow.begin(), m_vDiffsToShow.end(), d) != m_vDiffsToShow.end(); bool bShowThis = find( v.begin(), v.end(), d ) != v.end();
if( !bShowThis ) if( !bShowThis )
continue; // skip continue; // skip
@@ -273,34 +264,12 @@ void ScreenRanking::Init()
m_ListCourseRowItems.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y ); m_ListCourseRowItems.SetXY( SCREEN_CENTER_X, SCREEN_CENTER_Y );
} }
// calculate which StepsTypes to show
vector<StepsType> aStepsTypesToShow;
{
GAMEMAN->GetStepsTypesForGame( GAMESTATE->m_pCurGame, aStepsTypesToShow );
// subtract hidden StepsTypes
{
vector<CString> asStepsTypesToHide;
split( STEPS_TYPES_TO_HIDE, ",", asStepsTypesToHide, true );
for( unsigned i=0; i<asStepsTypesToHide.size(); i++ )
{
StepsType st = GameManager::StringToStepsType(asStepsTypesToHide[i]);
if( st != STEPS_TYPE_INVALID )
{
const vector<StepsType>::iterator iter = find( aStepsTypesToShow.begin(), aStepsTypesToShow.end(), st );
if( iter != aStepsTypesToShow.end() )
aStepsTypesToShow.erase( iter );
}
}
}
}
// //
// fill m_vPagesToShow // fill m_vPagesToShow
// //
if( SHOW_CATEGORIES ) if( SHOW_CATEGORIES )
{ {
for( unsigned i=0; i<aStepsTypesToShow.size(); i++ ) for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
{ {
for( int c=0; c<NUM_RANKING_CATEGORIES; c++ ) for( int c=0; c<NUM_RANKING_CATEGORIES; c++ )
{ {
@@ -308,7 +277,7 @@ void ScreenRanking::Init()
pts.type = PAGE_TYPE_CATEGORY; pts.type = PAGE_TYPE_CATEGORY;
pts.colorIndex = i; pts.colorIndex = i;
pts.category = (RankingCategory)c; pts.category = (RankingCategory)c;
pts.nt = aStepsTypesToShow[i]; pts.nt = STEPS_TYPES_TO_SHOW.GetValue()[i];
m_vPagesToShow.push_back( pts ); m_vPagesToShow.push_back( pts );
} }
} }
@@ -317,14 +286,14 @@ void ScreenRanking::Init()
{ {
vector<CString> asCoursePaths; vector<CString> asCoursePaths;
split( COURSES_TO_SHOW, ",", asCoursePaths, true ); split( COURSES_TO_SHOW, ",", asCoursePaths, true );
for( unsigned i=0; i<aStepsTypesToShow.size(); i++ ) for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
{ {
for( unsigned c=0; c<asCoursePaths.size(); c++ ) for( unsigned c=0; c<asCoursePaths.size(); c++ )
{ {
PageToShow pts; PageToShow pts;
pts.type = PAGE_TYPE_TRAIL; pts.type = PAGE_TYPE_TRAIL;
pts.colorIndex = i; pts.colorIndex = i;
pts.nt = aStepsTypesToShow[i]; pts.nt = STEPS_TYPES_TO_SHOW.GetValue()[i];
pts.pCourse = SONGMAN->GetCourseFromPath( asCoursePaths[c] ); pts.pCourse = SONGMAN->GetCourseFromPath( asCoursePaths[c] );
if( pts.pCourse == NULL ) if( pts.pCourse == NULL )
continue; continue;
@@ -343,12 +312,12 @@ void ScreenRanking::Init()
vector<Song*> vpSongs = SONGMAN->GetAllSongs(); vector<Song*> vpSongs = SONGMAN->GetAllSongs();
if( !vpSongs.empty() ) if( !vpSongs.empty() )
{ {
for( unsigned i=0; i<aStepsTypesToShow.size(); i++ ) for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
{ {
PageToShow pts; PageToShow pts;
pts.type = PAGE_TYPE_ALL_STEPS; pts.type = PAGE_TYPE_ALL_STEPS;
pts.colorIndex = i; pts.colorIndex = i;
pts.nt = aStepsTypesToShow[i]; pts.nt = STEPS_TYPES_TO_SHOW.GetValue()[i];
m_vPagesToShow.push_back( pts ); m_vPagesToShow.push_back( pts );
} }
} }
@@ -360,12 +329,12 @@ void ScreenRanking::Init()
SONGMAN->GetAllCourses( courses, false ); SONGMAN->GetAllCourses( courses, false );
if( !courses.empty() ) if( !courses.empty() )
{ {
for( unsigned i=0; i<aStepsTypesToShow.size(); i++ ) for( unsigned i=0; i<STEPS_TYPES_TO_SHOW.GetValue().size(); i++ )
{ {
PageToShow pts; PageToShow pts;
pts.type = PAGE_TYPE_ALL_COURSES; pts.type = PAGE_TYPE_ALL_COURSES;
pts.colorIndex = i; pts.colorIndex = i;
pts.nt = aStepsTypesToShow[i]; pts.nt = STEPS_TYPES_TO_SHOW.GetValue()[i];
m_vPagesToShow.push_back( pts ); m_vPagesToShow.push_back( pts );
} }
} }
@@ -567,7 +536,6 @@ float ScreenRanking::SetPage( PageToShow pts )
this->AddChild( m_sprPageType ); this->AddChild( m_sprPageType );
SET_XY_AND_ON_COMMAND( m_sprPageType ); SET_XY_AND_ON_COMMAND( m_sprPageType );
{
for( int l=0; l<NUM_RANKING_LINES; l++ ) for( int l=0; l<NUM_RANKING_LINES; l++ )
{ {
m_sprBullets[l].SetHidden( !bShowBullets ); m_sprBullets[l].SetHidden( !bShowBullets );
@@ -616,17 +584,15 @@ float ScreenRanking::SetPage( PageToShow pts )
ON_COMMAND( m_textTime[l] ); ON_COMMAND( m_textTime[l] );
} }
} }
}
FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
{ {
for( vector<Difficulty>::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) m_sprDifficulty[*iter]->SetHidden( !bShowDifficulty );
{
m_sprDifficulty[*dc_iter]->SetHidden( !bShowDifficulty );
if( bShowDifficulty ) if( bShowDifficulty )
{ {
m_sprDifficulty[*dc_iter]->Reset(); m_sprDifficulty[*iter]->Reset();
m_sprDifficulty[*dc_iter]->SetXY( DIFFICULTY_X(*dc_iter), DIFFICULTY_Y ); m_sprDifficulty[*iter]->SetXY( DIFFICULTY_X(*iter), DIFFICULTY_Y );
ON_COMMAND( m_sprDifficulty[*dc_iter] ); ON_COMMAND( m_sprDifficulty[*iter] );
} }
} }
@@ -660,19 +626,17 @@ float ScreenRanking::SetPage( PageToShow pts )
pStepsScoreRowItems->m_textSongTitle.SetUseZBuffer( true ); pStepsScoreRowItems->m_textSongTitle.SetUseZBuffer( true );
ON_COMMAND( pStepsScoreRowItems->m_textSongTitle ); ON_COMMAND( pStepsScoreRowItems->m_textSongTitle );
for( vector<Difficulty>::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
{ {
pStepsScoreRowItems->m_textStepsScore[*dc_iter].Reset(); pStepsScoreRowItems->m_textStepsScore[*iter].Reset();
pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetXY( STEPS_SCORE_OFFSET_X(*dc_iter), STEPS_SCORE_OFFSET_Y ); pStepsScoreRowItems->m_textStepsScore[*iter].SetXY( STEPS_SCORE_OFFSET_X(*iter), STEPS_SCORE_OFFSET_Y );
pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetUseZBuffer( true ); pStepsScoreRowItems->m_textStepsScore[*iter].SetUseZBuffer( true );
pStepsScoreRowItems->m_textStepsScore[*dc_iter].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) ); pStepsScoreRowItems->m_textStepsScore[*iter].SetDiffuse( STEPS_TYPE_COLOR.GetValue(pts.colorIndex) );
ON_COMMAND( pStepsScoreRowItems->m_textStepsScore[*dc_iter] ); ON_COMMAND( pStepsScoreRowItems->m_textStepsScore[*iter] );
}
} }
} }
} }
{
FOREACH_ShownCourseDifficulty(d) FOREACH_ShownCourseDifficulty(d)
{ {
m_sprCourseDifficulty[d]->SetHidden( !bShowCourseDifficulty ); m_sprCourseDifficulty[d]->SetHidden( !bShowCourseDifficulty );
@@ -724,7 +688,6 @@ float ScreenRanking::SetPage( PageToShow pts )
} }
} }
} }
}
// get ranking feat list // get ranking feat list
@@ -835,10 +798,10 @@ float ScreenRanking::SetPage( PageToShow pts )
pStepsScoreRowItem->m_textSongTitle.SetText( pSong->GetFullDisplayTitle() ); pStepsScoreRowItem->m_textSongTitle.SetText( pSong->GetFullDisplayTitle() );
for( vector<Difficulty>::iterator dc_iter = m_vDiffsToShow.begin(); dc_iter != m_vDiffsToShow.end(); dc_iter++ ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
{ {
const Steps* pSteps = pSong->GetStepsByDifficulty( pts.nt, *dc_iter, false ); const Steps* pSteps = pSong->GetStepsByDifficulty( pts.nt, *iter, false );
BitmapText* pTextStepsScore = &pStepsScoreRowItem->m_textStepsScore[*dc_iter]; BitmapText* pTextStepsScore = &pStepsScoreRowItem->m_textStepsScore[*iter];
if( pSteps == NULL ) if( pSteps == NULL )
{ {
@@ -934,10 +897,10 @@ void ScreenRanking::TweenPageOffScreen()
OFF_COMMAND( m_textPoints[l] ); OFF_COMMAND( m_textPoints[l] );
OFF_COMMAND( m_textTime[l] ); OFF_COMMAND( m_textTime[l] );
} }
for( vector<Difficulty>::iterator dc_iter=m_vDiffsToShow.begin(); dc_iter!=m_vDiffsToShow.end(); dc_iter++ ) FOREACH_CONST( Difficulty, DIFFICULTIES_TO_SHOW.GetValue(), iter )
{ {
if( !m_sprDifficulty[*dc_iter]->GetHidden() ) if( !m_sprDifficulty[*iter]->GetHidden() )
OFF_COMMAND( m_sprDifficulty[*dc_iter] ); OFF_COMMAND( m_sprDifficulty[*iter] );
} }
FOREACH_ShownCourseDifficulty(d) FOREACH_ShownCourseDifficulty(d)
{ {
+5 -3
View File
@@ -10,6 +10,7 @@
#include "ActorUtil.h" #include "ActorUtil.h"
#include "Difficulty.h" #include "Difficulty.h"
#include "ThemeMetric.h" #include "ThemeMetric.h"
#include "CommonMetrics.h"
class Course; class Course;
class Song; class Song;
@@ -102,14 +103,15 @@ protected:
ListDisplay m_ListCourseRowItems; ListDisplay m_ListCourseRowItems;
vector<PageToShow> m_vPagesToShow; vector<PageToShow> m_vPagesToShow;
vector<Difficulty> m_vDiffsToShow;
// Don't use the version in CommonMetrics because we may have multiple
// ranking screens that want to show different types and difficulties.
ThemeMetricStepsTypesToShow STEPS_TYPES_TO_SHOW;
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
ThemeMetric<CString> STEPS_TYPES_TO_HIDE;
ThemeMetric<bool> SHOW_CATEGORIES; ThemeMetric<bool> SHOW_CATEGORIES;
ThemeMetric<bool> SHOW_ALL_STEPS_SCORES; ThemeMetric<bool> SHOW_ALL_STEPS_SCORES;
ThemeMetric<bool> SHOW_ALL_COURSE_SCORES; ThemeMetric<bool> SHOW_ALL_COURSE_SCORES;
ThemeMetric<CString> DIFFICULTIES_TO_SHOW;
ThemeMetric<float> SECONDS_PER_PAGE; ThemeMetric<float> SECONDS_PER_PAGE;
ThemeMetric<float> PAGE_FADE_SECONDS; ThemeMetric<float> PAGE_FADE_SECONDS;
ThemeMetric<int> PERCENT_DECIMAL_PLACES; ThemeMetric<int> PERCENT_DECIMAL_PLACES;