convert some prefs to use Preference

This commit is contained in:
Chris Danford
2004-12-04 08:21:54 +00:00
parent 27c69a2a04
commit d46bfd460d
5 changed files with 97 additions and 104 deletions
+11
View File
@@ -73,6 +73,17 @@ public:
{
return m_currentValue;
}
T& operator=( const T& other )
{
return m_currentValue = other;
}
T operator!()
{
return !m_currentValue;
}
};
#endif
+23 -40
View File
@@ -50,7 +50,29 @@ void PrefsManager::Unsubscribe( IPreference *p )
bool g_bAutoRestart = false;
PrefsManager::PrefsManager()
PrefsManager::PrefsManager() :
m_bWindowed ( Options, "Windowed",
#ifdef DEBUG
true
#else
false
#endif
),
m_iDisplayWidth ( Options, "DisplayWidth", 640 ),
m_iDisplayHeight ( Options, "DisplayHeight", 480 ),
m_iDisplayColorDepth ( Options, "DisplayColorDepth", 16 ),
m_iTextureColorDepth ( Options, "TextureColorDepth", 16 ),
m_iMovieColorDepth ( Options, "MovieColorDepth", 16 ),
m_iMaxTextureResolution ( Options, "MaxTextureResolution", 2048 ),
m_iRefreshRate ( Options, "RefreshRate", REFRESH_DEFAULT ),
m_bShowStats ( Options, "ShowStats",
#ifdef DEBUG
true
#else
false
#endif
),
m_bShowBanners ( Options, "ShowBanners", true )
{
Init();
ReadGlobalPrefsFromDisk();
@@ -58,27 +80,9 @@ PrefsManager::PrefsManager()
void PrefsManager::Init()
{
#ifdef DEBUG
m_bWindowed = true;
#else
m_bWindowed = false;
#endif
m_iDisplayWidth = 640;
m_iDisplayHeight = 480;
m_iDisplayColorDepth = 16;
m_iTextureColorDepth = 16; // default to 16 for better preformance on slower cards
m_iMovieColorDepth = 16;
m_iMaxTextureResolution = 2048;
m_iRefreshRate = REFRESH_DEFAULT;
m_bOnlyDedicatedMenuButtons = false;
m_bCelShadeModels = false; // Work-In-Progress.. disable by default.
m_fConstantUpdateDeltaSeconds = 0;
#ifdef DEBUG
m_bShowStats = true;
#else
m_bShowStats = false;
#endif
m_bShowBanners = true ;
m_BackgroundMode = BGMODE_ANIMATIONS;
m_iNumBackgrounds = 8;
m_bShowDanger = true;
@@ -365,21 +369,11 @@ void PrefsManager::ReadPrefsFromFile( CString sIni )
if( !ini.ReadFile(sIni) )
return;
ini.GetValue( "Options", "Windowed", m_bWindowed );
ini.GetValue( "Options", "Interlaced", m_bInterlaced );
ini.GetValue( "Options", "PAL", m_bPAL );
ini.GetValue( "Options", "CelShadeModels", m_bCelShadeModels );
ini.GetValue( "Options", "ConstantUpdateDeltaSeconds", m_fConstantUpdateDeltaSeconds );
ini.GetValue( "Options", "DisplayWidth", m_iDisplayWidth );
ini.GetValue( "Options", "DisplayHeight", m_iDisplayHeight );
ini.GetValue( "Options", "DisplayColorDepth", m_iDisplayColorDepth );
ini.GetValue( "Options", "TextureColorDepth", m_iTextureColorDepth );
ini.GetValue( "Options", "MovieColorDepth", m_iMovieColorDepth );
ini.GetValue( "Options", "MaxTextureResolution", m_iMaxTextureResolution );
ini.GetValue( "Options", "RefreshRate", m_iRefreshRate );
ini.GetValue( "Options", "UseDedicatedMenuButtons", m_bOnlyDedicatedMenuButtons );
ini.GetValue( "Options", "ShowStats", m_bShowStats );
ini.GetValue( "Options", "ShowBanners", m_bShowBanners );
ini.GetValue( "Options", "BackgroundMode", (int&)m_BackgroundMode );
ini.GetValue( "Options", "NumBackgrounds", m_iNumBackgrounds);
ini.GetValue( "Options", "ShowDanger", m_bShowDanger );
@@ -624,19 +618,9 @@ void PrefsManager::SaveGlobalPrefsToDisk() const
{
IniFile ini;
ini.SetValue( "Options", "Windowed", m_bWindowed );
ini.SetValue( "Options", "CelShadeModels", m_bCelShadeModels );
ini.SetValue( "Options", "ConstantUpdateDeltaSeconds", m_fConstantUpdateDeltaSeconds );
ini.SetValue( "Options", "DisplayWidth", m_iDisplayWidth );
ini.SetValue( "Options", "DisplayHeight", m_iDisplayHeight );
ini.SetValue( "Options", "DisplayColorDepth", m_iDisplayColorDepth );
ini.SetValue( "Options", "TextureColorDepth", m_iTextureColorDepth );
ini.SetValue( "Options", "MovieColorDepth", m_iMovieColorDepth );
ini.SetValue( "Options", "MaxTextureResolution", m_iMaxTextureResolution );
ini.SetValue( "Options", "RefreshRate", m_iRefreshRate );
ini.SetValue( "Options", "UseDedicatedMenuButtons", m_bOnlyDedicatedMenuButtons );
ini.SetValue( "Options", "ShowStats", m_bShowStats );
ini.SetValue( "Options", "ShowBanners", m_bShowBanners );
ini.SetValue( "Options", "BackgroundMode", m_BackgroundMode);
ini.SetValue( "Options", "NumBackgrounds", m_iNumBackgrounds);
ini.SetValue( "Options", "ShowDanger", m_bShowDanger );
@@ -901,7 +885,6 @@ PrefsManager::Premium PrefsManager::GetPremium()
return m_Premium;
}
/*
* (c) 2001-2004 Chris Danford, Chris Gomez
* All rights reserved.
+11 -12
View File
@@ -5,8 +5,7 @@
#include "PlayerNumber.h"
#include "Grade.h" // for NUM_GRADE_TIERS
class IPreference;
#include "Preference.h"
class IniFile;
class PrefsManager
@@ -18,16 +17,16 @@ public:
void Init();
// GameOptions (ARE saved between sessions)
bool m_bWindowed;
int m_iDisplayWidth;
int m_iDisplayHeight;
int m_iDisplayColorDepth;
int m_iTextureColorDepth;
int m_iMovieColorDepth;
int m_iMaxTextureResolution;
int m_iRefreshRate;
bool m_bShowStats;
bool m_bShowBanners;
Preference<bool> m_bWindowed;
Preference<int> m_iDisplayWidth;
Preference<int> m_iDisplayHeight;
Preference<int> m_iDisplayColorDepth;
Preference<int> m_iTextureColorDepth;
Preference<int> m_iMovieColorDepth;
Preference<int> m_iMaxTextureResolution;
Preference<int> m_iRefreshRate;
Preference<bool> m_bShowStats;
Preference<bool> m_bShowBanners;
enum BackgroundModes { BGMODE_OFF, BGMODE_ANIMATIONS, BGMODE_MOVIEVIS, BGMODE_RANDOMMOVIES } m_BackgroundMode;
int m_iNumBackgrounds;
float m_fBGBrightness;
+47 -47
View File
@@ -199,60 +199,60 @@ static void DefaultNoteSkin( int &sel, bool ToSel, const CStringArray &choices )
}
/* Appearance options */
MOVE( Instructions, PREFSMAN->m_bShowInstructions );
MOVE( Caution, PREFSMAN->m_bShowCaution );
MOVE( OniScoreDisplay, PREFSMAN->m_bDancePointsForOni );
MOVE( SongGroup, PREFSMAN->m_bShowSelectGroup );
MOVE( Instructions, (bool&)PREFSMAN->m_bShowInstructions );
MOVE( Caution, (bool&)PREFSMAN->m_bShowCaution );
MOVE( OniScoreDisplay, (bool&)PREFSMAN->m_bDancePointsForOni );
MOVE( SongGroup, (bool&)PREFSMAN->m_bShowSelectGroup );
MOVE( WheelSections, PREFSMAN->m_MusicWheelUsesSections );
MOVE( CourseSort, PREFSMAN->m_iCourseSortOrder );
MOVE( RandomAtEnd, PREFSMAN->m_bMoveRandomToEnd );
MOVE( Translations, PREFSMAN->m_bShowNativeLanguage );
MOVE( Lyrics, PREFSMAN->m_bShowLyrics );
MOVE( RandomAtEnd, (bool&)PREFSMAN->m_bMoveRandomToEnd );
MOVE( Translations, (bool&)PREFSMAN->m_bShowNativeLanguage );
MOVE( Lyrics, (bool&)PREFSMAN->m_bShowLyrics );
/* Misc. options */
MOVE( AutogenSteps, PREFSMAN->m_bAutogenSteps );
MOVE( AutogenGroupCourses, PREFSMAN->m_bAutogenGroupCourses );
MOVE( FastLoad, PREFSMAN->m_bFastLoad );
MOVE( AutogenSteps, (bool&)PREFSMAN->m_bAutogenSteps );
MOVE( AutogenGroupCourses, (bool&)PREFSMAN->m_bAutogenGroupCourses );
MOVE( FastLoad, (bool&)PREFSMAN->m_bFastLoad );
/* Background options */
MOVE( BackgroundMode, PREFSMAN->m_BackgroundMode );
MOVE( ShowDanger, PREFSMAN->m_bShowDanger );
MOVE( BackgroundMode, , PREFSMAN->m_BackgroundMode );
MOVE( ShowDanger, (bool&)PREFSMAN->m_bShowDanger );
MOVE( DancingCharacters, PREFSMAN->m_ShowDancingCharacters );
MOVE( BeginnerHelper, PREFSMAN->m_bShowBeginnerHelper );
MOVE( BeginnerHelper, (bool&)PREFSMAN->m_bShowBeginnerHelper );
static void BGBrightness( int &sel, bool ToSel, const CStringArray &choices )
{
const float mapping[] = { 0.0f,0.1f,0.2f,0.3f,0.4f,0.5f,0.6f,0.7f,0.8f,0.9f,1.0f };
MoveMap( sel, PREFSMAN->m_fBGBrightness, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (float&)PREFSMAN->m_fBGBrightness, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void NumBackgrounds( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 5,10,15,20 };
MoveMap( sel, PREFSMAN->m_iNumBackgrounds, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iNumBackgrounds, ToSel, mapping, ARRAYSIZE(mapping) );
}
/* Input options */
MOVE( AutoMapOnJoyChange, PREFSMAN->m_bAutoMapOnJoyChange );
MOVE( MenuButtons, PREFSMAN->m_bOnlyDedicatedMenuButtons );
MOVE( AutoPlay, PREFSMAN->m_bAutoPlay );
MOVE( BackDelayed, PREFSMAN->m_bDelayedBack );
MOVE( OptionsNavigation, PREFSMAN->m_bArcadeOptionsNavigation );
MOVE( AutoMapOnJoyChange, (bool&)PREFSMAN->m_bAutoMapOnJoyChange );
MOVE( MenuButtons, (bool&)PREFSMAN->m_bOnlyDedicatedMenuButtons );
MOVE( AutoPlay, (bool&)PREFSMAN->m_bAutoPlay );
MOVE( BackDelayed, (bool&)PREFSMAN->m_bDelayedBack );
MOVE( OptionsNavigation, (bool&)PREFSMAN->m_bArcadeOptionsNavigation );
static void WheelSpeed( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 5, 10, 15, 25 };
MoveMap( sel, PREFSMAN->m_iMusicWheelSwitchSpeed, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iMusicWheelSwitchSpeed, ToSel, mapping, ARRAYSIZE(mapping) );
}
/* Gameplay options */
MOVE( SoloSingles, PREFSMAN->m_bSoloSingle );
MOVE( HiddenSongs, PREFSMAN->m_bHiddenSongs );
MOVE( EasterEggs, PREFSMAN->m_bEasterEggs );
MOVE( SoloSingles, (bool&)PREFSMAN->m_bSoloSingle );
MOVE( HiddenSongs, (bool&)PREFSMAN->m_bHiddenSongs );
MOVE( EasterEggs, (bool&)PREFSMAN->m_bEasterEggs );
MOVE( MarvelousTiming, PREFSMAN->m_iMarvelousTiming );
MOVE( AllowExtraStage, PREFSMAN->m_bAllowExtraStage );
MOVE( PickExtraStage, PREFSMAN->m_bPickExtraStage );
MOVE( UnlockSystem, PREFSMAN->m_bUseUnlockSystem );
MOVE( AllowExtraStage, (bool&)PREFSMAN->m_bAllowExtraStage );
MOVE( PickExtraStage, (bool&)PREFSMAN->m_bPickExtraStage );
MOVE( UnlockSystem, (bool&)PREFSMAN->m_bUseUnlockSystem );
/* Coin options */
MOVE( CoinMode, PREFSMAN->m_iCoinMode );
@@ -260,13 +260,13 @@ MOVE( CoinMode, PREFSMAN->m_iCoinMode );
static void CoinModeNoHome( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 1,2 };
MoveMap( sel, PREFSMAN->m_iCoinMode, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iCoinMode, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void CoinsPerCredit( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 1,2,3,4,5,6,7,8 };
MoveMap( sel, PREFSMAN->m_iCoinsPerCredit, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iCoinsPerCredit, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void Premium( int &sel, bool ToSel, const CStringArray &choices )
@@ -278,24 +278,24 @@ static void Premium( int &sel, bool ToSel, const CStringArray &choices )
static void SongsPerPlay( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 1,2,3,4,5,6,7 };
MoveMap( sel, PREFSMAN->m_iNumArcadeStages, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iNumArcadeStages, ToSel, mapping, ARRAYSIZE(mapping) );
}
MOVE( EventMode, PREFSMAN->m_bEventMode );
MOVE( EventMode, (bool&)PREFSMAN->m_bEventMode );
/* Machine options */
MOVE( MenuTimer, PREFSMAN->m_bMenuTimer );
MOVE( MenuTimer, (bool&)PREFSMAN->m_bMenuTimer );
MOVE( ScoringType, PREFSMAN->m_iScoringType );
static void JudgeDifficulty( int &sel, bool ToSel, const CStringArray &choices )
{
const float mapping[] = { 1.50f,1.33f,1.16f,1.00f,0.84f,0.66f,0.50f,0.33f,0.20f };
MoveMap( sel, PREFSMAN->m_fJudgeWindowScale, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (float&)PREFSMAN->m_fJudgeWindowScale, ToSel, mapping, ARRAYSIZE(mapping) );
}
void LifeDifficulty( int &sel, bool ToSel, const CStringArray &choices )
{
const float mapping[] = { 1.60f,1.40f,1.20f,1.00f,0.80f,0.60f,0.40f };
MoveMap( sel, PREFSMAN->m_fLifeDifficultyScale, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (float&)PREFSMAN->m_fLifeDifficultyScale, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void ShowSongOptions( int &sel, bool ToSel, const CStringArray &choices )
@@ -341,13 +341,13 @@ MOVE( ProgressiveStageLifebar, PREFSMAN->m_iProgressiveStageLifebar );
MOVE( ProgressiveNonstopLifebar, PREFSMAN->m_iProgressiveNonstopLifebar );
/* Graphic options */
MOVE( DisplayMode, PREFSMAN->m_bWindowed );
MOVE( WaitForVsync, PREFSMAN->m_bVsync );
MOVE( ShowStats, PREFSMAN->m_bShowStats );
MOVE( ShowBanners, PREFSMAN->m_bShowBanners );
MOVE( KeepTexturesInMemory, PREFSMAN->m_bDelayedTextureDelete );
MOVE( CelShadeModels, PREFSMAN->m_bCelShadeModels );
MOVE( SmoothLines, PREFSMAN->m_bSmoothLines );
MOVE( DisplayMode, (bool&)PREFSMAN->m_bWindowed );
MOVE( WaitForVsync, (bool&)PREFSMAN->m_bVsync );
MOVE( ShowStats, (bool&)PREFSMAN->m_bShowStats );
MOVE( ShowBanners, (bool&)PREFSMAN->m_bShowBanners );
MOVE( KeepTexturesInMemory, (bool&)PREFSMAN->m_bDelayedTextureDelete );
MOVE( CelShadeModels, (bool&)PREFSMAN->m_bCelShadeModels );
MOVE( SmoothLines, (bool&)PREFSMAN->m_bSmoothLines );
struct res_t
{
@@ -392,31 +392,31 @@ static void DisplayResolution( int &sel, bool ToSel, const CStringArray &choices
static void DisplayColor( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 16,32 };
MoveMap( sel, PREFSMAN->m_iDisplayColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iDisplayColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void TextureResolution( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 256,512,1024,2048 };
MoveMap( sel, PREFSMAN->m_iMaxTextureResolution, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iMaxTextureResolution, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void TextureColor( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 16,32 };
MoveMap( sel, PREFSMAN->m_iTextureColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iTextureColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void MovieColor( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { 16,32 };
MoveMap( sel, PREFSMAN->m_iMovieColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iMovieColorDepth, ToSel, mapping, ARRAYSIZE(mapping) );
}
static void RefreshRate( int &sel, bool ToSel, const CStringArray &choices )
{
const int mapping[] = { (int) REFRESH_DEFAULT,60,70,72,75,80,85,90,100,120,150 };
MoveMap( sel, PREFSMAN->m_iRefreshRate, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (int&)PREFSMAN->m_iRefreshRate, ToSel, mapping, ARRAYSIZE(mapping) );
}
/* Sound options */
@@ -426,7 +426,7 @@ MOVE( AttractSoundFrequency,PREFSMAN->m_iAttractSoundFrequency );
static void SoundVolume( int &sel, bool ToSel, const CStringArray &choices )
{
const float mapping[] = { 0.0f,0.1f,0.2f,0.3f,0.4f,0.5f,0.6f,0.7f,0.8f,0.9f,1.0f };
MoveMap( sel, PREFSMAN->m_fSoundVolume, ToSel, mapping, ARRAYSIZE(mapping) );
MoveMap( sel, (float&)PREFSMAN->m_fSoundVolume, ToSel, mapping, ARRAYSIZE(mapping) );
}
+5 -5
View File
@@ -109,11 +109,11 @@ static void StoreActualGraphicOptions( bool initial )
CString log = ssprintf("%s %dx%d %d color %d texture %dHz %s %s",
PREFSMAN->m_bWindowed ? "Windowed" : "Fullscreen",
PREFSMAN->m_iDisplayWidth,
PREFSMAN->m_iDisplayHeight,
PREFSMAN->m_iDisplayColorDepth,
PREFSMAN->m_iTextureColorDepth,
PREFSMAN->m_iRefreshRate,
(int)PREFSMAN->m_iDisplayWidth,
(int)PREFSMAN->m_iDisplayHeight,
(int)PREFSMAN->m_iDisplayColorDepth,
(int)PREFSMAN->m_iTextureColorDepth,
(int)PREFSMAN->m_iRefreshRate,
PREFSMAN->m_bVsync ? "Vsync" : "NoVsync",
PREFSMAN->m_bSmoothLines? "AA" : "NoAA" );
if( initial )