allow theme to specify logical screen dimensions
This commit is contained in:
@@ -22,6 +22,8 @@ DefaultCpuModifiers=
|
||||
JoinPauseSeconds=0.8
|
||||
DifficultiesToShow=beginner,easy,medium,hard,challenge
|
||||
CourseDifficultiesToShow=easy,regular,difficult
|
||||
ScreenWidth=640
|
||||
ScreenHeight=480
|
||||
|
||||
[ModeSwitcher]
|
||||
PrevModeX=-200
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "Actor.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
inline float GetOffScreenLeft( Actor* pActor ) { return SCREEN_LEFT - pActor->GetZoomedWidth()/2; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "NoteDisplay.h"
|
||||
#include "song.h"
|
||||
#include "RageMath.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
const float ARROW_SPACING = ARROW_SIZE;// + 2;
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ const float SPIRAL_MIN_ZOOM = 0.3f;
|
||||
#define MAX_TILES_HIGH (SCREEN_HEIGHT/32+2)
|
||||
#define MAX_SPRITES (MAX_TILES_WIDE*MAX_TILES_HIGH)
|
||||
|
||||
static const RectI FullScreenRectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM);
|
||||
#define FullScreenRectI RectI(SCREEN_LEFT,SCREEN_TOP,SCREEN_RIGHT,SCREEN_BOTTOM)
|
||||
|
||||
|
||||
BGAnimationLayer::BGAnimationLayer( bool Generic )
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "arch/arch.h"
|
||||
#include "BeginnerHelper.h"
|
||||
#include "StageStats.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include <set>
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "Steps.h"
|
||||
#include "Style.h"
|
||||
#include "Model.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
// "PLAYER_X" offsets are relative to the pad.. ex: Setting this to 10, and the HELPER to 300, will put the dancer at 310
|
||||
#define PLAYER_X( px ) THEME->GetMetricF("BeginnerHelper",ssprintf("Player%d_X",px+1))
|
||||
|
||||
@@ -7,25 +7,6 @@
|
||||
#include "Difficulty.h" // TODO: Get rid of this dependency.
|
||||
#include "EnumHelper.h"
|
||||
|
||||
//
|
||||
// Screen Dimensions
|
||||
//
|
||||
#define SCREEN_WIDTH (640)
|
||||
#define SCREEN_HEIGHT (480)
|
||||
|
||||
#define SCREEN_LEFT (0)
|
||||
#define SCREEN_RIGHT (SCREEN_WIDTH)
|
||||
#define SCREEN_TOP (0)
|
||||
#define SCREEN_BOTTOM (SCREEN_HEIGHT)
|
||||
|
||||
#define CENTER_X (SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT)/2.0f)
|
||||
#define CENTER_Y (SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP)/2.0f)
|
||||
|
||||
#define SCREEN_NEAR (-1000)
|
||||
#define SCREEN_FAR (1000)
|
||||
|
||||
#define ARROW_SIZE (64)
|
||||
|
||||
|
||||
//
|
||||
// Note definitions
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "global.h"
|
||||
#include "LyricDisplay.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include "GameState.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "NoteFieldPositioning.h"
|
||||
#include "NoteSkinManager.h"
|
||||
#include "song.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
NoteField::NoteField()
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "GameManager.h"
|
||||
#include "IniFile.h"
|
||||
#include "Game.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
/* Copies of the current mode. Update this by calling Load. */
|
||||
NoteFieldMode g_NoteFieldMode[NUM_PLAYERS];
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include "Game.h"
|
||||
#include "NetworkSyncManager.h" //used for sending timing offset
|
||||
#include "DancingCharacters.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
CachedThemeMetricF GRAY_ARROWS_Y_STANDARD ("Player","ReceptorArrowsYStandard");
|
||||
CachedThemeMetricF GRAY_ARROWS_Y_REVERSE ("Player","ReceptorArrowsYReverse");
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
m_defaultValue( defaultValue ),
|
||||
m_currentValue( defaultValue )
|
||||
{
|
||||
Subscribe( this );
|
||||
PrefsManager::Subscribe( this );
|
||||
}
|
||||
|
||||
void LoadDefault()
|
||||
|
||||
@@ -25,9 +25,9 @@ const CString DEFAULT_LIGHTS_DRIVER = "Null";
|
||||
//
|
||||
// For self-registering prefs
|
||||
//
|
||||
vector<IPreference*> *g_pvpSubscribers = NULL;
|
||||
static vector<IPreference*> *g_pvpSubscribers = NULL;
|
||||
|
||||
void Subscribe( IPreference *p )
|
||||
void PrefsManager::Subscribe( IPreference *p )
|
||||
{
|
||||
// TRICKY: If we make this a global vector instead of a global pointer,
|
||||
// then we'd have to be careful that the static constructors of all
|
||||
|
||||
@@ -281,16 +281,17 @@ public:
|
||||
|
||||
void ResetToFactoryDefaults();
|
||||
|
||||
//
|
||||
// For self-registering prefs
|
||||
//
|
||||
static void Subscribe( IPreference *p );
|
||||
|
||||
protected:
|
||||
void ReadPrefsFromFile( CString sIni );
|
||||
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
// For self-registering prefs
|
||||
//
|
||||
void Subscribe( IPreference *p );
|
||||
|
||||
|
||||
/* This is global, because it can be accessed by crash handlers and error handlers
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "SDL_rotozoom.h"
|
||||
#include "RageSurface.h"
|
||||
#include "Preference.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
//
|
||||
// Statistics stuff
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include "arch/arch.h"
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RageSurface.h"
|
||||
#include "RageSurfaceUtils.h"
|
||||
#include "PrefsManager.h" // XXX
|
||||
#include "ScreenDimensions.h" // XXX
|
||||
|
||||
/* Windows's broken gl.h defines GL_EXT_paletted_texture incompletely: */
|
||||
#ifndef GL_TEXTURE_INDEX_SIZE_EXT
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "Bookkeeper.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
ScreenBookkeeping::ScreenBookkeeping( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "HelpDisplay.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
ScreenCenterImage::ScreenCenterImage( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
#include "global.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
ThemeMetric<float> SCREEN_WIDTH("Common","ScreenWidth");
|
||||
ThemeMetric<float> SCREEN_HEIGHT("Common","ScreenHeight");
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2001-2002 Chris Danford
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
@@ -1,9 +1,12 @@
|
||||
/* ScoreKeeperMAX2 - MAX2-style scorekeeping. */
|
||||
|
||||
#ifndef SCREEN_DIMENSIONS_H
|
||||
#define SCREEN_DIMENSIONS_H
|
||||
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
#define SCREEN_WIDTH (640)
|
||||
#define SCREEN_HEIGHT (480)
|
||||
extern ThemeMetric<float> SCREEN_WIDTH;
|
||||
extern ThemeMetric<float> SCREEN_HEIGHT;
|
||||
|
||||
#define SCREEN_LEFT (0)
|
||||
#define SCREEN_RIGHT (SCREEN_WIDTH)
|
||||
@@ -13,6 +16,10 @@
|
||||
#define CENTER_X (SCREEN_LEFT + (SCREEN_RIGHT - SCREEN_LEFT)/2.0f)
|
||||
#define CENTER_Y (SCREEN_TOP + (SCREEN_BOTTOM - SCREEN_TOP)/2.0f)
|
||||
|
||||
#define SCREEN_NEAR (-1000)
|
||||
#define SCREEN_FAR (1000)
|
||||
|
||||
#define ARROW_SIZE (64)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "SongUtil.h"
|
||||
#include "StepsUtil.h"
|
||||
#include "Foreach.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
const float RECORD_HOLD_SECONDS = 0.3f;
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include "RageLog.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "ScreenEndlessBreak.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
//TODO:: Add scripting support
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
#include "AnnouncerManager.h"
|
||||
#include "MenuTimer.h"
|
||||
#include "StepsUtil.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#define SCROLLING_LIST_X THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListX")
|
||||
#define SCROLLING_LIST_Y THEME->GetMetricF("ScreenEz2SelectMusic","ScrollingListY")
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "RageTimer.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "MenuTimer.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
/* Constants */
|
||||
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include "NetworkSyncManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "DancingCharacters.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
//
|
||||
// Defines
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "GameState.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
ScreenInstructions::ScreenInstructions( CString sName ) : ScreenWithMenuElements( sName )
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "Game.h"
|
||||
#include "HelpDisplay.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
#define EVEN_LINE_IN THEME->GetMetric("ScreenMapControllers","EvenLineIn")
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "Foreach.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
const float LABEL_X = 200;
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "AnnouncerManager.h"
|
||||
#include "song.h"
|
||||
#include "SongUtil.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
#define SCROLL_DELAY THEME->GetMetricF("ScreenMusicScroll","ScrollDelay")
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "NoteFieldPositioning.h"
|
||||
#include "StageStats.h"
|
||||
#include "Game.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "Foreach.h"
|
||||
#include "Style.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
//
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "song.h"
|
||||
#include "Course.h"
|
||||
#include "Style.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
const float ITEM_X[NUM_PLAYERS] = { 260, 420 };
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "ScreenSongOptions.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "CodeDetector.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
#define PREV_SCREEN THEME->GetMetric ("ScreenPlayerOptions","PrevScreen")
|
||||
|
||||
@@ -6,12 +6,13 @@
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
const float QUESTION_X = CENTER_X;
|
||||
const float QUESTION_Y = CENTER_Y - 60;
|
||||
#define QUESTION_X (CENTER_X)
|
||||
#define QUESTION_Y (CENTER_Y - 60)
|
||||
|
||||
const float PROMPT_X = CENTER_X;
|
||||
const float PROMPT_Y = CENTER_Y + 120;
|
||||
#define PROMPT_X (CENTER_X)
|
||||
#define PROMPT_Y (CENTER_Y + 120)
|
||||
|
||||
bool ScreenPrompt::s_bLastAnswer = false;
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ProfileManager.h"
|
||||
#include "RageLog.h"
|
||||
#include "UnlockSystem.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
static const CString PageTypeNames[NUM_PAGE_TYPES] = {
|
||||
"Category",
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "RageTimer.h"
|
||||
#include "RageLog.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#include "arch/LoadingWindow/LoadingWindow.h"
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include "AnnouncerManager.h"
|
||||
#include "ModeChoice.h"
|
||||
#include "ActorUtil.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
#define NUM_CHOICES_ON_PAGE_1 THEME->GetMetricI(m_sName,"NumChoicesOnPage1")
|
||||
#define LOCK_INPUT_SECONDS THEME->GetMetricF(m_sName,"LockInputSeconds")
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "RageTextureManager.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "GameConstantsAndTypes.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
static const float LineWidth = 400;
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "ThemeManager.h"
|
||||
#include "RageDisplay.h"
|
||||
#include "Game.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
ScreenTestInput::ScreenTestInput( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "RageDisplay.h"
|
||||
#include "LightsManager.h"
|
||||
#include "Game.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
ScreenTestLights::ScreenTestLights( CString sClassName ) : ScreenWithMenuElements( sClassName )
|
||||
|
||||
@@ -8,14 +8,15 @@
|
||||
#include "PrefsManager.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "FontCharAliases.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
const float QUESTION_X = CENTER_X;
|
||||
const float QUESTION_Y = CENTER_Y - 60;
|
||||
#define QUESTION_X (CENTER_X)
|
||||
#define QUESTION_Y (CENTER_Y - 60)
|
||||
|
||||
const float ANSWER_X = CENTER_X;
|
||||
const float ANSWER_Y = CENTER_Y + 120;
|
||||
const float ANSWER_WIDTH = 440;
|
||||
const float ANSWER_HEIGHT = 30;
|
||||
#define ANSWER_X (CENTER_X)
|
||||
#define ANSWER_Y (CENTER_Y + 120)
|
||||
#define ANSWER_WIDTH (440)
|
||||
#define ANSWER_HEIGHT (30)
|
||||
|
||||
|
||||
CString ScreenTextEntry::s_sLastAnswer = "";
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "GameState.h"
|
||||
#include "ThemeManager.h"
|
||||
#include "Style.h"
|
||||
#include "ScreenDimensions.h"
|
||||
|
||||
|
||||
SnapDisplay::SnapDisplay()
|
||||
|
||||
@@ -59,10 +59,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /verbose /profile /pdb:none /incremental:no /nodefaultlib
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Debug6
|
||||
TargetDir=\temp\stepmania\Program
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania-debug
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -96,10 +96,10 @@ LINK32=link.exe
|
||||
# SUBTRACT LINK32 /verbose /pdb:none /debug
|
||||
# Begin Special Build Tool
|
||||
IntDir=.\../Release6
|
||||
TargetDir=\temp\stepmania\Program
|
||||
TargetDir=\stepmania\stepmania\Program
|
||||
TargetName=StepMania
|
||||
SOURCE="$(InputPath)"
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PreLink_Cmds=disasm\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
|
||||
PostBuild_Cmds=disasm\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
|
||||
# End Special Build Tool
|
||||
|
||||
@@ -952,6 +952,10 @@ SOURCE=.\ScoreKeeperRave.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ScreenDimensions.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Song.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
@@ -830,6 +830,9 @@ cl /Zl /nologo /c verstub.cpp /Fo"$(IntDir)"\
|
||||
<File
|
||||
RelativePath="ScoreKeeperRave.h">
|
||||
</File>
|
||||
<File
|
||||
RelativePath="ScreenDimensions.cpp">
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Song.cpp">
|
||||
</File>
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "RageFile.h"
|
||||
#include "ScreenManager.h"
|
||||
#include "StepMania.h"
|
||||
#include "Foreach.h"
|
||||
#include "ThemeMetric.h"
|
||||
|
||||
|
||||
ThemeManager* THEME = NULL; // global object accessable from anywhere in the program
|
||||
@@ -45,6 +47,28 @@ struct Theme
|
||||
deque<Theme> g_vThemes;
|
||||
|
||||
|
||||
|
||||
|
||||
//
|
||||
// For self-registering metrics
|
||||
//
|
||||
static vector<IThemeMetric*> *g_pvpSubscribers = NULL;
|
||||
|
||||
void ThemeManager::Subscribe( IThemeMetric *p )
|
||||
{
|
||||
// TRICKY: If we make this a global vector instead of a global pointer,
|
||||
// then we'd have to be careful that the static constructors of all
|
||||
// Preferences are called before the vector constructor. It's
|
||||
// too tricky to enfore that, so we'll allocate the vector ourself
|
||||
// so that the compiler can't possibly call the vector constructor
|
||||
// after we've already added to the vector.
|
||||
if( g_pvpSubscribers == NULL )
|
||||
g_pvpSubscribers = new vector<IThemeMetric*>;
|
||||
g_pvpSubscribers->push_back( p );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* We spend a lot of time doing redundant theme path lookups. Cache results. */
|
||||
static map<CString, CString> g_ThemePathCache[NUM_ELEMENT_CATEGORIES];
|
||||
|
||||
@@ -221,6 +245,9 @@ void ThemeManager::SwitchThemeAndLanguage( CString sThemeName, CString sLanguage
|
||||
// reload common sounds
|
||||
if ( SCREENMAN != NULL )
|
||||
SCREENMAN->ThemeChanged();
|
||||
|
||||
// reload subscribers
|
||||
FOREACH( IThemeMetric*, *g_pvpSubscribers, p ) (*p)->Read();
|
||||
}
|
||||
|
||||
CString ThemeManager::GetThemeDirFromName( const CString &sThemeName )
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <set>
|
||||
#include <deque>
|
||||
|
||||
class IThemeMetric;
|
||||
class IniFile;
|
||||
|
||||
enum ElementCategory { BGAnimations, Fonts, Graphics, Numbers, Sounds, Other, NUM_ELEMENT_CATEGORIES };
|
||||
@@ -57,6 +58,17 @@ public:
|
||||
float GetMetricF( CString sClassName, CString sValueName );
|
||||
bool GetMetricB( CString sClassName, CString sValueName );
|
||||
RageColor GetMetricC( CString sClassName, CString sValueName );
|
||||
void GetMetric( CString sClassName, CString sValueName, CString &valueOut ) { valueOut = GetMetric( sClassName, sValueName ); }
|
||||
void GetMetric( CString sClassName, CString sValueName, int &valueOut ) { valueOut = GetMetricI( sClassName, sValueName ); }
|
||||
void GetMetric( CString sClassName, CString sValueName, float &valueOut ) { valueOut = GetMetricF( sClassName, sValueName ); }
|
||||
void GetMetric( CString sClassName, CString sValueName, bool &valueOut ) { valueOut = GetMetricB( sClassName, sValueName ); }
|
||||
void GetMetric( CString sClassName, CString sValueName, RageColor &valueOut ){ valueOut = GetMetricC( sClassName, sValueName ); }
|
||||
|
||||
//
|
||||
// For self-registering metrics
|
||||
//
|
||||
static void Subscribe( IThemeMetric *p );
|
||||
|
||||
|
||||
protected:
|
||||
void LoadThemeRecursive( deque<Theme> &theme, CString sThemeName );
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/* ThemeMetric - Theme specific data. */
|
||||
|
||||
#ifndef THEME_METRIC_H
|
||||
#define THEME_METRIC_H
|
||||
|
||||
#include "IniFile.h"
|
||||
#include "ThemeManager.h"
|
||||
|
||||
class IThemeMetric
|
||||
{
|
||||
public:
|
||||
virtual ~IThemeMetric() { }
|
||||
virtual void Read() = 0;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class ThemeMetric : public IThemeMetric
|
||||
{
|
||||
private:
|
||||
CString m_sGroup;
|
||||
CString m_sName;
|
||||
T m_currentValue;
|
||||
|
||||
public:
|
||||
ThemeMetric( const CString& sGroup, const CString& sName ):
|
||||
m_sGroup( sGroup ),
|
||||
m_sName( sName )
|
||||
{
|
||||
ThemeManager::Subscribe( this );
|
||||
}
|
||||
|
||||
void Read()
|
||||
{
|
||||
THEME->GetMetric( m_sGroup, m_sName, m_currentValue );
|
||||
}
|
||||
|
||||
const T& GetValue() const
|
||||
{
|
||||
return m_currentValue;
|
||||
}
|
||||
|
||||
operator const T& () const
|
||||
{
|
||||
return m_currentValue;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* (c) 2001-2004 Chris Danford, Chris Gomez
|
||||
* All rights reserved.
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
* without limitation the rights to use, copy, modify, merge, publish,
|
||||
* distribute, and/or sell copies of the Software, and to permit persons to
|
||||
* whom the Software is furnished to do so, provided that the above
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
* THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS
|
||||
* INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT
|
||||
* OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
|
||||
* OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
Reference in New Issue
Block a user