move DifficultiesToShow into CommonMetrics
re-cache on theme reload, not on timer expired
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "Style.h"
|
||||
#include "CommonMetrics.h"
|
||||
|
||||
#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()))
|
||||
@@ -63,8 +64,7 @@ void SaveCatalogXml()
|
||||
pSongNode->AppendChild( "MainTitle", pSong->GetDisplayMainTitle() );
|
||||
pSongNode->AppendChild( "SubTitle", pSong->GetDisplaySubTitle() );
|
||||
|
||||
set<Difficulty> vDiffs;
|
||||
GAMESTATE->GetDifficultiesToShow( vDiffs );
|
||||
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow();
|
||||
|
||||
FOREACH_StepsType( st )
|
||||
{
|
||||
@@ -111,8 +111,7 @@ void SaveCatalogXml()
|
||||
pCourseNode->AppendChild( "SubTitle", pCourse->GetDisplaySubTitle() );
|
||||
pCourseNode->AppendChild( "HasMods", pCourse->HasMods() );
|
||||
|
||||
set<CourseDifficulty> vDiffs;
|
||||
GAMESTATE->GetCourseDifficultiesToShow( vDiffs );
|
||||
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow();
|
||||
|
||||
FOREACH_StepsType( st )
|
||||
{
|
||||
@@ -144,9 +143,8 @@ void SaveCatalogXml()
|
||||
XNode* pNode = xml.AppendChild( "Types" );
|
||||
|
||||
{
|
||||
set<Difficulty> vDiffs;
|
||||
GAMESTATE->GetDifficultiesToShow( vDiffs );
|
||||
for( set<Difficulty>::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
|
||||
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow();
|
||||
FOREACHS_CONST( Difficulty, vDiffs, iter )
|
||||
{
|
||||
XNode* pNode2 = pNode->AppendChild( "Difficulty", DifficultyToString(*iter) );
|
||||
pNode2->AppendAttr( "DisplayAs", DifficultyToThemedString(*iter) );
|
||||
@@ -154,9 +152,8 @@ void SaveCatalogXml()
|
||||
}
|
||||
|
||||
{
|
||||
set<CourseDifficulty> vDiffs;
|
||||
GAMESTATE->GetCourseDifficultiesToShow( vDiffs );
|
||||
for( set<CourseDifficulty>::const_iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
|
||||
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow();
|
||||
FOREACHS_CONST( CourseDifficulty, vDiffs, iter )
|
||||
{
|
||||
XNode* pNode2 = pNode->AppendChild( "CourseDifficulty", CourseDifficultyToString(*iter) );
|
||||
pNode2->AppendAttr( "DisplayAs", CourseDifficultyToThemedString(*iter) );
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
#include "global.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "RageUtil.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
CString PLAYER_COLOR_NAME( size_t p ) { return ssprintf("ColorP%d",p+1); }
|
||||
|
||||
ThemeMetric<CString> DIFFICULTIES_TO_SHOW ("Common","DifficultiesToShow");
|
||||
ThemeMetric<CString> INITIAL_SCREEN ("Common","InitialScreen");
|
||||
ThemeMetric<CString> FIRST_RUN_INITIAL_SCREEN ("Common","FirstRunInitialScreen");
|
||||
ThemeMetric<CString> DEFAULT_MODIFIERS ("Common","DefaultModifiers" );
|
||||
ThemeMetric<CString> DEFAULT_CPU_MODIFIERS ("Common","DefaultCpuModifiers" );
|
||||
ThemeMetric<CString> COURSE_DIFFICULTIES_TO_SHOW ("Common","CourseDifficultiesToShow");
|
||||
ThemeMetric1D<RageColor> PLAYER_COLOR ("Common",PLAYER_COLOR_NAME,NUM_PLAYERS);
|
||||
ThemeMetric<float> JOIN_PAUSE_SECONDS ("Common","JoinPauseSeconds");
|
||||
ThemeMetric<CString> WINDOW_TITLE ("Common","WindowTitle");
|
||||
@@ -18,6 +17,65 @@ ThemeMetric<bool> HOME_EDIT_MODE ("Common","HomeEditMode");
|
||||
ThemeMetric<int> MAX_STEPS_LOADED_FROM_PROFILE ("Common","MaxStepsLoadedFromProfile");
|
||||
|
||||
|
||||
class ThemeMetricDifficultiesToShow : ThemeMetric<CString>
|
||||
{
|
||||
public:
|
||||
set<Difficulty> m_v;
|
||||
|
||||
ThemeMetricDifficultiesToShow() : ThemeMetric<CString>("Common","DifficultiesToShow") {}
|
||||
void Read()
|
||||
{
|
||||
ThemeMetric<CString>::Read();
|
||||
|
||||
m_v.clear();
|
||||
|
||||
CStringArray v;
|
||||
split( GetValue(), ",", v );
|
||||
ASSERT( v.size() > 0 );
|
||||
|
||||
FOREACH_CONST( CString, v, i )
|
||||
{
|
||||
Difficulty d = StringToDifficulty( *i );
|
||||
if( d == DIFFICULTY_INVALID )
|
||||
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", i->c_str() );
|
||||
m_v.insert( d );
|
||||
}
|
||||
}
|
||||
};
|
||||
ThemeMetricDifficultiesToShow DIFFICULTIES_TO_SHOW;
|
||||
const set<Difficulty>& CommonMetrics::GetDifficultiesToShow() { return DIFFICULTIES_TO_SHOW.m_v; }
|
||||
|
||||
|
||||
class ThemeMetricCourseDifficultiesToShow : ThemeMetric<CString>
|
||||
{
|
||||
public:
|
||||
set<CourseDifficulty> m_v;
|
||||
|
||||
ThemeMetricCourseDifficultiesToShow() : ThemeMetric<CString>("Common","CourseDifficultiesToShow") {}
|
||||
void Read()
|
||||
{
|
||||
ThemeMetric<CString>::Read();
|
||||
|
||||
m_v.clear();
|
||||
|
||||
CStringArray v;
|
||||
split( GetValue(), ",", v );
|
||||
ASSERT( v.size() > 0 );
|
||||
|
||||
FOREACH_CONST( CString, v, i )
|
||||
{
|
||||
CourseDifficulty d = StringToCourseDifficulty( *i );
|
||||
if( d == DIFFICULTY_INVALID )
|
||||
RageException::Throw( "Unknown CourseDifficulty \"%s\" in CourseDifficultiesToShow", i->c_str() );
|
||||
m_v.insert( d );
|
||||
}
|
||||
}
|
||||
};
|
||||
ThemeMetricCourseDifficultiesToShow COURSE_DIFFICULTIES_TO_SHOW;
|
||||
const set<CourseDifficulty>& CommonMetrics::GetCourseDifficultiesToShow() { return COURSE_DIFFICULTIES_TO_SHOW.m_v; }
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford
|
||||
* All rights reserved.
|
||||
|
||||
@@ -5,19 +5,23 @@
|
||||
|
||||
#include "ThemeMetric.h"
|
||||
#include "PlayerNumber.h"
|
||||
#include "Difficulty.h"
|
||||
|
||||
extern ThemeMetric<CString> DIFFICULTIES_TO_SHOW;
|
||||
extern ThemeMetric<CString> INITIAL_SCREEN;
|
||||
extern ThemeMetric<CString> FIRST_RUN_INITIAL_SCREEN;
|
||||
extern ThemeMetric<CString> DEFAULT_MODIFIERS;
|
||||
extern ThemeMetric<CString> DEFAULT_CPU_MODIFIERS;
|
||||
extern ThemeMetric<CString> COURSE_DIFFICULTIES_TO_SHOW;
|
||||
extern ThemeMetric1D<RageColor> PLAYER_COLOR;
|
||||
extern ThemeMetric<float> JOIN_PAUSE_SECONDS;
|
||||
extern ThemeMetric<CString> WINDOW_TITLE;
|
||||
extern ThemeMetric<bool> HOME_EDIT_MODE;
|
||||
extern ThemeMetric<int> MAX_STEPS_LOADED_FROM_PROFILE;
|
||||
|
||||
namespace CommonMetrics
|
||||
{
|
||||
const set<Difficulty>& GetDifficultiesToShow();
|
||||
const set<CourseDifficulty>& GetCourseDifficultiesToShow();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -275,7 +275,9 @@ void Course::LoadFromCRSFile( CString sPath )
|
||||
m_RadarCache[CacheEntry(st, cd)] = rv;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG->Trace( "Unexpected value named '%s'", sValueName.c_str() );
|
||||
}
|
||||
}
|
||||
static TitleSubst tsub("courses");
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "StepsUtil.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Command.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
#define MAX_METERS NUM_DIFFICULTIES + MAX_EDITS_PER_SONG
|
||||
|
||||
@@ -283,27 +284,25 @@ void DifficultyList::SetFromGameState()
|
||||
// FIXME: This clamps to between the min and the max difficulty, but
|
||||
// it really should round to the nearest difficulty that's in
|
||||
// DIFFICULTIES_TO_SHOW.
|
||||
CStringArray asDiff;
|
||||
split( DIFFICULTIES_TO_SHOW.GetValue(), ",", asDiff );
|
||||
for( unsigned i=0; i<asDiff.size(); i++ )
|
||||
const set<Difficulty> &diffs = CommonMetrics::GetDifficultiesToShow();
|
||||
unsigned i=0;
|
||||
FOREACHS_CONST( Difficulty, diffs, d )
|
||||
{
|
||||
Difficulty d = StringToDifficulty( asDiff[i] );
|
||||
if( d == DIFFICULTY_INVALID )
|
||||
continue;
|
||||
|
||||
m_Rows.resize( m_Rows.size()+1 );
|
||||
|
||||
Row &row = m_Rows.back();
|
||||
|
||||
row.m_dc = d;
|
||||
row.m_dc = *d;
|
||||
|
||||
m_Lines[i].m_Meter.SetFromMeterAndDifficulty( 3*(d), d );
|
||||
m_Lines[i].m_Meter.SetFromMeterAndDifficulty( 3*(*d), *d );
|
||||
|
||||
m_Lines[i].m_Description.SetText( GetDifficultyString(d) );
|
||||
m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(d) );
|
||||
m_Lines[i].m_Description.SetText( GetDifficultyString(*d) );
|
||||
m_Lines[i].m_Description.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) );
|
||||
|
||||
m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(d) );
|
||||
m_Lines[i].m_Number.SetDiffuseColor( SONGMAN->GetDifficultyColor(*d) );
|
||||
m_Lines[i].m_Number.SetText( "?" );
|
||||
|
||||
i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "PlayerState.h"
|
||||
#include "Style.h"
|
||||
#include "MessageManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <set>
|
||||
@@ -1658,37 +1659,9 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, Difficulty dc )
|
||||
return true;
|
||||
}
|
||||
|
||||
void GameState::GetDifficultiesToShow( set<Difficulty> &ret )
|
||||
{
|
||||
static float fExpiration = -999;
|
||||
static set<Difficulty> cache;
|
||||
if( RageTimer::GetTimeSinceStart() < fExpiration )
|
||||
{
|
||||
ret = cache;
|
||||
return;
|
||||
}
|
||||
|
||||
CStringArray asDiff;
|
||||
split( DIFFICULTIES_TO_SHOW, ",", asDiff );
|
||||
ASSERT( asDiff.size() > 0 );
|
||||
|
||||
cache.clear();
|
||||
for( unsigned i = 0; i < asDiff.size(); ++i )
|
||||
{
|
||||
Difficulty d = StringToDifficulty(asDiff[i]);
|
||||
if( d == DIFFICULTY_INVALID )
|
||||
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", asDiff[i].c_str() );
|
||||
cache.insert( d );
|
||||
}
|
||||
|
||||
fExpiration = RageTimer::GetTimeSinceStart()+1;
|
||||
ret = cache;
|
||||
}
|
||||
|
||||
bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
|
||||
{
|
||||
set<Difficulty> asDiff;
|
||||
GetDifficultiesToShow( asDiff );
|
||||
const set<Difficulty> &asDiff = CommonMetrics::GetDifficultiesToShow();
|
||||
|
||||
Difficulty d = m_PreferredDifficulty[pn];
|
||||
while( 1 )
|
||||
@@ -1703,33 +1676,6 @@ bool GameState::ChangePreferredDifficulty( PlayerNumber pn, int dir )
|
||||
return ChangePreferredDifficulty( pn, d );
|
||||
}
|
||||
|
||||
void GameState::GetCourseDifficultiesToShow( set<CourseDifficulty> &ret )
|
||||
{
|
||||
static float fExpiration = -999;
|
||||
static set<CourseDifficulty> cache;
|
||||
if( RageTimer::GetTimeSinceStart() < fExpiration )
|
||||
{
|
||||
ret = cache;
|
||||
return;
|
||||
}
|
||||
|
||||
CStringArray asDiff;
|
||||
split( COURSE_DIFFICULTIES_TO_SHOW, ",", asDiff );
|
||||
ASSERT( asDiff.size() > 0 );
|
||||
|
||||
cache.clear();
|
||||
for( unsigned i = 0; i < asDiff.size(); ++i )
|
||||
{
|
||||
CourseDifficulty cd = StringToCourseDifficulty(asDiff[i]);
|
||||
if( cd == DIFFICULTY_INVALID )
|
||||
RageException::Throw( "Unknown difficulty \"%s\" in CourseDifficultiesToShow", asDiff[i].c_str() );
|
||||
cache.insert( cd );
|
||||
}
|
||||
|
||||
fExpiration = RageTimer::GetTimeSinceStart()+1;
|
||||
ret = cache;
|
||||
}
|
||||
|
||||
bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, CourseDifficulty cd )
|
||||
{
|
||||
m_PreferredCourseDifficulty[pn].Set( cd );
|
||||
@@ -1747,8 +1693,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
|
||||
/* If we have a course selected, only choose among difficulties available in the course. */
|
||||
const Course *pCourse = this->m_pCurCourse;
|
||||
|
||||
set<CourseDifficulty> asDiff;
|
||||
GetCourseDifficultiesToShow( asDiff );
|
||||
const set<CourseDifficulty> &asDiff = CommonMetrics::GetCourseDifficultiesToShow();
|
||||
|
||||
CourseDifficulty cd = m_PreferredCourseDifficulty[pn];
|
||||
while( 1 )
|
||||
@@ -1767,8 +1712,7 @@ bool GameState::ChangePreferredCourseDifficulty( PlayerNumber pn, int dir )
|
||||
|
||||
bool GameState::IsCourseDifficultyShown( CourseDifficulty cd )
|
||||
{
|
||||
set<CourseDifficulty> asDiff;
|
||||
GetCourseDifficultiesToShow( asDiff );
|
||||
const set<CourseDifficulty> &asDiff = CommonMetrics::GetCourseDifficultiesToShow();
|
||||
return asDiff.find(cd) != asDiff.end();
|
||||
}
|
||||
|
||||
|
||||
@@ -261,12 +261,6 @@ public:
|
||||
int m_iNumTimesThroughAttract; // negative means play regardless of m_iAttractSoundFrequency setting
|
||||
bool IsTimeToPlayAttractSounds();
|
||||
|
||||
//
|
||||
// DifficultiesToShow stuff
|
||||
//
|
||||
void GetDifficultiesToShow( set<Difficulty> &AddTo );
|
||||
void GetCourseDifficultiesToShow( set<CourseDifficulty> &AddTo );
|
||||
|
||||
//
|
||||
// PlayerState
|
||||
//
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include "Foreach.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "GameSoundManager.h"
|
||||
#include "CommonMetrics.h"
|
||||
|
||||
#define ENTRY(s) THEME->GetMetric ("ScreenOptionsMaster",s)
|
||||
#define ENTRY_MODE(s,i) THEME->GetMetric ("ScreenOptionsMaster",ssprintf("%s,%i",(s).c_str(),(i+1)))
|
||||
@@ -451,8 +452,7 @@ public:
|
||||
ASSERT( sParam.size() );
|
||||
m_sName = sParam;
|
||||
|
||||
set<Difficulty> vDifficulties;
|
||||
GAMESTATE->GetDifficultiesToShow( vDifficulties );
|
||||
const set<Difficulty> &vDifficulties = CommonMetrics::GetDifficultiesToShow();
|
||||
|
||||
defOut.bOneChoiceForAllPlayers = true;
|
||||
defOut.name = "Difficulty";
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
#include "StatsManager.h"
|
||||
#include "PlayerState.h"
|
||||
#include "BGAnimation.h"
|
||||
#include "CommonMetrics.h"
|
||||
#include "Foreach.h"
|
||||
|
||||
|
||||
#define SCROLL_DELAY THEME->GetMetricF("ScreenEnding","ScrollDelay")
|
||||
@@ -25,7 +27,6 @@
|
||||
#define TEXT_ZOOM THEME->GetMetricF("ScreenEnding","TextZoom")
|
||||
|
||||
|
||||
|
||||
CString GetStatsLineTitle( PlayerNumber pn, EndingStatsLine line )
|
||||
{
|
||||
switch( line )
|
||||
@@ -83,9 +84,8 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
|
||||
|
||||
if( GAMESTATE->IsCourseMode() )
|
||||
{
|
||||
set<CourseDifficulty> vDiffs;
|
||||
GAMESTATE->GetCourseDifficultiesToShow( vDiffs );
|
||||
for( set<CourseDifficulty>::iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
|
||||
const set<CourseDifficulty> &vDiffs = CommonMetrics::GetCourseDifficultiesToShow();
|
||||
FOREACHS_CONST( CourseDifficulty, vDiffs, iter )
|
||||
{
|
||||
fActual += pProfile->GetCoursesActual(st,*iter);
|
||||
fPossible += pProfile->GetCoursesPossible(st,*iter);
|
||||
@@ -93,9 +93,8 @@ CString GetStatsLineValue( PlayerNumber pn, EndingStatsLine line )
|
||||
}
|
||||
else
|
||||
{
|
||||
set<Difficulty> vDiffs;
|
||||
GAMESTATE->GetDifficultiesToShow( vDiffs );
|
||||
for( set<Difficulty>::iterator iter = vDiffs.begin(); iter != vDiffs.end(); iter++ )
|
||||
const set<Difficulty> &vDiffs = CommonMetrics::GetDifficultiesToShow();
|
||||
FOREACHS_CONST( Difficulty, vDiffs, iter )
|
||||
{
|
||||
fActual += pProfile->GetSongsActual(st,*iter);
|
||||
fPossible += pProfile->GetSongsPossible(st,*iter);
|
||||
|
||||
Reference in New Issue
Block a user