Files
itgmania212121/stepmania/src/PrefsManager.cpp
T

503 lines
23 KiB
C++
Raw Normal View History

2003-02-16 04:01:45 +00:00
#include "global.h"
2002-02-28 19:40:40 +00:00
#include "PrefsManager.h"
#include "IniFile.h"
2002-07-23 01:41:40 +00:00
#include "GameState.h"
#include "RageDisplay.h"
#include "RageUtil.h"
#include "arch/arch_default.h"
2003-09-25 01:37:56 +00:00
#include "RageSoundReader_Resample.h" /* for ResampleQuality */
2003-11-01 22:04:43 +00:00
#include "RageFile.h"
#include "ProductInfo.h"
2004-09-13 03:58:39 +00:00
#include "Foreach.h"
#include "Preference.h"
#include "RageLog.h"
2002-02-28 19:40:40 +00:00
#define DEFAULTS_INI_PATH "Data/Defaults.ini" // these can be overridden
#define STEPMANIA_INI_PATH "Data/StepMania.ini" // overlay on Defaults.ini, contains the user's choices
#define STATIC_INI_PATH "Data/Static.ini" // overlay on the 2 above, can't be overridden
2002-02-28 19:40:40 +00:00
2002-05-27 08:23:27 +00:00
PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our program
2002-02-28 19:40:40 +00:00
2003-11-02 21:05:59 +00:00
const float DEFAULT_SOUND_VOLUME = 1.00f;
2003-11-16 04:45:12 +00:00
const CString DEFAULT_LIGHTS_DRIVER = "Null";
2002-02-28 19:40:40 +00:00
2004-09-13 03:58:39 +00:00
//
// For self-registering prefs
//
#include "SubscriptionManager.h"
2005-02-05 21:40:36 +00:00
template<>
set<IPreference*>* SubscriptionManager<IPreference>::s_pSubscribers = NULL;
2004-09-13 03:58:39 +00:00
void PrefsManager::Subscribe( IPreference *p )
2004-09-13 03:58:39 +00:00
{
SubscriptionManager<IPreference>::Subscribe( p );
2004-09-13 03:58:39 +00:00
}
void PrefsManager::Unsubscribe( IPreference *p )
{
SubscriptionManager<IPreference>::Unsubscribe( p );
}
2004-09-13 03:58:39 +00:00
2004-12-07 10:04:19 +00:00
IPreference *PrefsManager::GetPreferenceByName( const CString &sName )
{
FOREACHS( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
2004-12-07 10:04:19 +00:00
{
if( !(*p)->GetName().CompareNoCase( sName ) )
return *p;
}
return NULL;
}
2004-09-13 03:58:39 +00:00
2003-10-16 08:55:32 +00:00
bool g_bAutoRestart = false;
2004-12-04 08:21:54 +00:00
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_fDisplayAspectRatio ( Options, "DisplayAspectRatio", 4/3.0f ),
2005-04-28 08:27:40 +00:00
m_bShowStats ( Options, "ShowStats", false ),
2004-12-04 10:35:50 +00:00
m_bShowBanners ( Options, "ShowBanners", true ),
2005-04-28 08:27:40 +00:00
m_BackgroundMode ( Options, "BackgroundMode", BGMODE_ANIMATIONS ),
2005-04-27 07:50:38 +00:00
m_iNumBackgrounds ( Options, "NumBackgrounds", 8 ),
2004-12-07 01:41:55 +00:00
m_fBGBrightness ( Options, "BGBrightness", 0.8f ),
m_bHiddenSongs ( Options, "HiddenSongs", false ), /* I'd rather get occasional people asking for support for this even though it's already here than lots of people asking why songs aren't being displayed. */
m_bVsync ( Options, "Vsync", true ),
2005-04-27 07:50:38 +00:00
m_bInterlaced ( Options, "Interlaced", false ),
2004-12-04 10:35:50 +00:00
/* XXX: Set these defaults for individual consoles using VideoCardDefaults.ini. */
2004-12-07 01:41:55 +00:00
m_bPAL ( Options, "PAL", false ),
m_bDelayedTextureDelete ( Options, "DelayedTextureDelete", true ),
2005-04-27 07:50:38 +00:00
m_bTexturePreload ( Options, "TexturePreload", false ),
2004-12-07 01:41:55 +00:00
m_bDelayedScreenLoad ( Options, "DelayedScreenLoad", false ),
2005-04-27 07:50:38 +00:00
m_bDelayedModelDelete ( Options, "DelayedModelDelete", false ),
2005-04-28 08:27:40 +00:00
m_BannerCache ( Options, "BannerCache", BNCACHE_LOW_RES_PRELOAD ),
2004-12-07 01:41:55 +00:00
m_bPalettedBannerCache ( Options, "PalettedBannerCache", false ),
m_bFastLoad ( Options, "FastLoad", true ),
2004-12-04 10:35:50 +00:00
m_bOnlyDedicatedMenuButtons ( Options, "OnlyDedicatedMenuButtons", false ),
2004-12-07 01:41:55 +00:00
m_bMenuTimer ( Options, "MenuTimer", true ),
m_bShowDanger ( Options, "ShowDanger", true ),
2004-12-04 10:35:50 +00:00
2004-12-07 01:41:55 +00:00
m_fJudgeWindowScale ( Options, "JudgeWindowScale", 1.0f ),
2005-04-27 07:50:38 +00:00
m_fJudgeWindowAdd ( Options, "JudgeWindowAdd", 0 ),
2004-12-07 01:41:55 +00:00
m_fJudgeWindowSecondsMarvelous ( Options, "JudgeWindowSecondsMarvelous", 0.0225f ),
m_fJudgeWindowSecondsPerfect ( Options, "JudgeWindowSecondsPerfect", 0.045f ),
m_fJudgeWindowSecondsGreat ( Options, "JudgeWindowSecondsGreat", 0.090f ),
2005-04-27 07:50:38 +00:00
m_fJudgeWindowSecondsGood ( Options, "JudgeWindowSecondsGood", 0.135f ),
2004-12-07 01:41:55 +00:00
m_fJudgeWindowSecondsBoo ( Options, "JudgeWindowSecondsBoo", 0.180f ),
m_fJudgeWindowSecondsOK ( Options, "JudgeWindowSecondsOK", 0.250f ), // allow enough time to take foot off and put back on
2005-04-20 01:52:55 +00:00
m_fJudgeWindowSecondsRoll ( Options, "JudgeWindowSecondsRoll", 0.350f ),
2005-04-27 07:50:38 +00:00
m_fJudgeWindowSecondsMine ( Options, "JudgeWindowSecondsMine", 0.090f ), // same as great
2004-12-07 01:41:55 +00:00
m_fJudgeWindowSecondsAttack ( Options, "JudgeWindowSecondsAttack", 0.135f ),
2004-12-04 10:35:50 +00:00
2004-12-07 01:41:55 +00:00
m_fLifeDifficultyScale ( Options, "LifeDifficultyScale", 1.0f ),
m_fLifeDeltaPercentChangeMarvelous ( Options, "LifeDeltaPercentChangeMarvelous", +0.008f ),
m_fLifeDeltaPercentChangePerfect ( Options, "LifeDeltaPercentChangePerfect", +0.008f ),
m_fLifeDeltaPercentChangeGreat ( Options, "LifeDeltaPercentChangeGreat", +0.004f ),
2005-04-27 07:50:38 +00:00
m_fLifeDeltaPercentChangeGood ( Options, "LifeDeltaPercentChangeGood", +0.000f ),
2004-12-07 01:41:55 +00:00
m_fLifeDeltaPercentChangeBoo ( Options, "LifeDeltaPercentChangeBoo", -0.040f ),
2005-04-27 07:50:38 +00:00
m_fLifeDeltaPercentChangeMiss ( Options, "LifeDeltaPercentChangeMiss", -0.080f ),
2004-12-07 01:41:55 +00:00
m_fLifeDeltaPercentChangeHitMine ( Options, "LifeDeltaPercentChangeHitMine", -0.160f ),
m_fLifeDeltaPercentChangeOK ( Options, "LifeDeltaPercentChangeOK", +0.008f ),
m_fLifeDeltaPercentChangeNG ( Options, "LifeDeltaPercentChangeNG", -0.080f ),
2005-04-27 07:50:38 +00:00
m_fTugMeterPercentChangeMarvelous ( Options, "TugMeterPercentChangeMarvelous", +0.010f ),
m_fTugMeterPercentChangePerfect ( Options, "TugMeterPercentChangePerfect", +0.008f ),
m_fTugMeterPercentChangeGreat ( Options, "TugMeterPercentChangeGreat", +0.004f ),
m_fTugMeterPercentChangeGood ( Options, "TugMeterPercentChangeGood", +0.000f ),
m_fTugMeterPercentChangeBoo ( Options, "TugMeterPercentChangeBoo", -0.010f ),
m_fTugMeterPercentChangeMiss ( Options, "TugMeterPercentChangeMiss", -0.020f ),
m_fTugMeterPercentChangeHitMine ( Options, "TugMeterPercentChangeHitMine", -0.040f ),
m_fTugMeterPercentChangeOK ( Options, "TugMeterPercentChangeOK", +0.008f ),
m_fTugMeterPercentChangeNG ( Options, "TugMeterPercentChangeNG", -0.020f ),
m_iRegenComboAfterFail ( Options, "RegenComboAfterFail", 10 ),
m_iRegenComboAfterMiss ( Options, "RegenComboAfterMiss", 5 ),
m_iMaxRegenComboAfterFail ( Options, "MaxRegenComboAfterFail", 10 ),
m_iMaxRegenComboAfterMiss ( Options, "MaxRegenComboAfterMiss", 10 ),
m_bTwoPlayerRecovery ( Options, "TwoPlayerRecovery", true ),
m_bMercifulDrain ( Options, "MercifulDrain", true ), // negative life deltas are scaled by the players life percentage
m_bMinimum1FullSongInNonstop ( Options, "Minimum1FullSongInNonstop", false ), // FEoS for 1st song, FailImmediate thereafter
2005-04-27 07:50:38 +00:00
m_bFailOffInBeginner ( Options, "FailOffInBeginner", false ),
m_bFailOffForFirstStageEasy ( Options, "FailOffForFirstStageEasy", false ),
2005-04-27 08:52:58 +00:00
m_bMercifulBeginner ( Options, "MercifulBeginner", false ),
2005-04-27 07:50:38 +00:00
m_iPercentScoreWeightMarvelous ( Options, "PercentScoreWeightMarvelous", 3 ),
m_iPercentScoreWeightPerfect ( Options, "PercentScoreWeightPerfect", 2 ),
m_iPercentScoreWeightGreat ( Options, "PercentScoreWeightGreat", 1 ),
m_iPercentScoreWeightGood ( Options, "PercentScoreWeightGood", 0 ),
m_iPercentScoreWeightBoo ( Options, "PercentScoreWeightBoo", 0 ),
m_iPercentScoreWeightMiss ( Options, "PercentScoreWeightMiss", 0 ),
2005-04-28 17:16:49 +00:00
m_iPercentScoreWeightHitMine ( Options, "PercentScoreWeightHitMine", -2 ),
2005-04-27 07:50:38 +00:00
m_iPercentScoreWeightOK ( Options, "PercentScoreWeightOK", 3 ),
m_iPercentScoreWeightNG ( Options, "PercentScoreWeightNG", 0 ),
m_iGradeWeightMarvelous ( Options, "GradeWeightMarvelous", 2 ),
m_iGradeWeightPerfect ( Options, "GradeWeightPerfect", 2 ),
m_iGradeWeightGreat ( Options, "GradeWeightGreat", 1 ),
m_iGradeWeightGood ( Options, "GradeWeightGood", 0 ),
m_iGradeWeightBoo ( Options, "GradeWeightBoo", -4 ),
m_iGradeWeightMiss ( Options, "GradeWeightMiss", -8 ),
m_iGradeWeightHitMine ( Options, "GradeWeightHitMine", -8 ),
m_iGradeWeightOK ( Options, "GradeWeightOK", 6 ),
m_iGradeWeightNG ( Options, "GradeWeightNG", 0 ),
m_fSuperMeterPercentChangeMarvelous ( Options, "SuperMeterPercentChangeMarvelous", +0.05f ),
m_fSuperMeterPercentChangePerfect ( Options, "SuperMeterPercentChangePerfect", +0.04f ),
m_fSuperMeterPercentChangeGreat ( Options, "SuperMeterPercentChangeGreat", +0.02f ),
m_fSuperMeterPercentChangeGood ( Options, "SuperMeterPercentChangeGood", +0.00f ),
m_fSuperMeterPercentChangeBoo ( Options, "SuperMeterPercentChangeBoo", -0.00f ),
m_fSuperMeterPercentChangeMiss ( Options, "SuperMeterPercentChangeMiss", -0.20f ),
m_fSuperMeterPercentChangeHitMine ( Options, "SuperMeterPercentChangeHitMine", -0.40f ),
m_fSuperMeterPercentChangeOK ( Options, "SuperMeterPercentChangeOK", +0.04f ),
m_fSuperMeterPercentChangeNG ( Options, "SuperMeterPercentChangeNG", -0.20f ),
m_bMercifulSuperMeter ( Options, "MercifulSuperMeter", true ),
2005-04-28 06:15:11 +00:00
m_fTimeMeterSecondsChangeMarvelous ( Options, "TimeMeterSecondsChangeMarvelous", +0.1f ),
m_fTimeMeterSecondsChangePerfect ( Options, "TimeMeterSecondsChangePerfect", 0.0f ),
2005-04-27 07:50:38 +00:00
m_fTimeMeterSecondsChangeGreat ( Options, "TimeMeterSecondsChangeGreat", -0.5f ),
m_fTimeMeterSecondsChangeGood ( Options, "TimeMeterSecondsChangeGood", -1.0f ),
m_fTimeMeterSecondsChangeBoo ( Options, "TimeMeterSecondsChangeBoo", -2.0f ),
m_fTimeMeterSecondsChangeMiss ( Options, "TimeMeterSecondsChangeMiss", -4.0f ),
m_fTimeMeterSecondsChangeHitMine ( Options, "TimeMeterSecondsChangeHitMine", -2.0f ),
m_fTimeMeterSecondsChangeOK ( Options, "TimeMeterSecondsChangeOK", -0.0f ),
m_fTimeMeterSecondsChangeNG ( Options, "TimeMeterSecondsChangeNG", -4.0f ),
m_bAutoPlay ( Options, "AutoPlay", false ),
m_bDelayedBack ( Options, "DelayedBack", true ),
m_bShowInstructions ( Options, "ShowInstructions", true ),
m_bShowSelectGroup ( Options, "ShowSelectGroup", true ),
2005-04-28 17:16:49 +00:00
m_bShowCaution ( Options, "ShowCaution", true ),
2005-04-27 07:50:38 +00:00
m_bShowNativeLanguage ( Options, "ShowNativeLanguage", true ),
m_bArcadeOptionsNavigation ( Options, "ArcadeOptionsNavigation", false ),
m_MusicWheelUsesSections ( Options, "MusicWheelUsesSections", ALWAYS ),
m_iMusicWheelSwitchSpeed ( Options, "MusicWheelSwitchSpeed", 10 ),
m_bEasterEggs ( Options, "EasterEggs", true ),
2005-04-28 08:27:40 +00:00
m_MarvelousTiming ( Options, "MarvelousTiming", MARVELOUS_EVERYWHERE ),
2005-04-27 07:50:38 +00:00
m_bEventMode ( Options, "EventMode", false ),
m_iCoinsPerCredit ( Options, "CoinsPerCredit", 1 ),
2005-04-28 08:27:40 +00:00
m_iSongsPerPlay ( Options, "SongsPerPlay", 3 ),
m_CoinMode ( Options, "CoinMode", COIN_HOME ),
m_Premium ( Options, "Premium", PREMIUM_NONE ),
m_bDelayedCreditsReconcile ( Options, "DelayedCreditsReconcile", false ),
m_bPickExtraStage ( Options, "PickExtraStage", false ),
m_bComboContinuesBetweenSongs ( Options, "ComboContinuesBetweenSongs",false ),
m_fLongVerSongSeconds ( Options, "LongVerSongSeconds", 60*2.5f ), // Dynamite Rave is 2:55
m_fMarathonVerSongSeconds ( Options, "MarathonVerSongSeconds", 60*5.f ),
m_ShowSongOptions ( Options, "ShowSongOptions", YES ),
m_bSoloSingle ( Options, "SoloSingle", false ),
m_bDancePointsForOni ( Options, "DancePointsForOni", false ),
m_bPercentageScoring ( Options, "PercentageScoring", false ),
m_fMinPercentageForMachineSongHighScore ( Options, "MinPercentageForMachineSongHighScore", 0.5f ),
m_fMinPercentageForMachineCourseHighScore ( Options, "MinPercentageForMachineCourseHighScore", 0.0001f ), // don't save course scores with 0 percentage
m_bDisqualification ( Options, "Disqualification", false ),
m_bShowLyrics ( Options, "ShowLyrics", true ),
m_bAutogenSteps ( Options, "AutogenSteps", true ),
m_bAutogenGroupCourses ( Options, "AutogenGroupCourses", true ),
m_bBreakComboToGetItem ( Options, "BreakComboToGetItem", false ),
m_bLockCourseDifficulties ( Options, "LockCourseDifficulties", true ),
m_ShowDancingCharacters ( Options, "ShowDancingCharacters", CO_OFF ),
m_bUseUnlockSystem ( Options, "UseUnlockSystem", false ),
m_bFirstRun ( Options, "FirstRun", true ),
m_bAutoMapOnJoyChange ( Options, "AutoMapOnJoyChange", true ),
m_fGlobalOffsetSeconds ( Options, "GlobalOffsetSeconds", 0 ),
m_iProgressiveLifebar ( Options, "ProgressiveLifebar", 0 ),
m_iProgressiveStageLifebar ( Options, "ProgressiveStageLifebar", 0 ),
m_iProgressiveNonstopLifebar ( Options, "ProgressiveNonstopLifebar", 0 ),
m_bShowBeginnerHelper ( Options, "ShowBeginnerHelper", false ),
m_bEndlessBreakEnabled ( Options, "EndlessBreakEnabled", true ),
m_iEndlessNumStagesUntilBreak ( Options, "EndlessNumStagesUntilBreak",5 ),
m_iEndlessBreakLength ( Options, "EndlessBreakLength", 5 ),
m_bDisableScreenSaver ( Options, "DisableScreenSaver", true ),
m_sLanguage ( Options, "Language", "" ), // ThemeManager will deal with this invalid language
m_sMemoryCardProfileSubdir ( Options, "MemoryCardProfileSubdir", PRODUCT_NAME ),
2005-05-16 09:36:32 +00:00
m_iProductID ( Options, "ProductID", 1 ),
m_sDefaultLocalProfileIDP1 ( Options, "DefaultLocalProfileIDP1", "" ),
m_sDefaultLocalProfileIDP2 ( Options, "DefaultLocalProfileIDP2", "" ),
m_bMemoryCards ( Options, "MemoryCards", false ),
m_sMemoryCardOsMountPointP1 ( Options, "MemoryCardOsMountPointP1", "" ),
m_sMemoryCardOsMountPointP2 ( Options, "MemoryCardOsMountPointP2", "" ),
m_iMemoryCardUsbBusP1 ( Options, "MemoryCardUsbBusP1", -1 ),
m_iMemoryCardUsbBusP2 ( Options, "MemoryCardUsbBusP2", -1 ),
m_iMemoryCardUsbPortP1 ( Options, "MemoryCardUsbPortP1", -1 ),
m_iMemoryCardUsbPortP2 ( Options, "MemoryCardUsbPortP2", -1 ),
m_iMemoryCardUsbLevelP1 ( Options, "MemoryCardUsbLevelP1", -1 ),
m_iMemoryCardUsbLevelP2 ( Options, "MemoryCardUsbLevelP2", -1 ),
2005-04-28 08:27:40 +00:00
m_iCenterImageTranslateX ( Options, "CenterImageTranslateX", 0 ),
m_iCenterImageTranslateY ( Options, "CenterImageTranslateY", 0 ),
m_fCenterImageAddWidth ( Options, "CenterImageAddWidth", 0 ),
m_fCenterImageAddHeight ( Options, "CenterImageAddHeight", 0 ),
m_iAttractSoundFrequency ( Options, "AttractSoundFrequency", 1 ),
m_bAllowExtraStage ( Options, "AllowExtraStage", true ),
m_bHideDefaultNoteSkin ( Options, "HideDefaultNoteSkin", false ),
m_iMaxHighScoresPerListForMachine ( Options, "MaxHighScoresPerListForMachine", 10 ),
m_iMaxHighScoresPerListForPlayer ( Options, "MaxHighScoresPerListForPlayer", 3 ),
m_iMaxRecentScoresForMachine ( Options, "MaxRecentScoresForMachine", 100 ),
m_iMaxRecentScoresForPlayer ( Options, "MaxRecentScoresForPlayer", 20 ),
m_bAllowMultipleHighScoreWithSameName ( Options, "AllowMultipleHighScoreWithSameName", true ),
2005-05-09 17:33:22 +00:00
m_bCelShadeModels ( Options, "CelShadeModels", false ), // Work-In-Progress.. disable by default.
2005-05-16 09:36:32 +00:00
m_bPreferredSortUsesGroups ( Options, "PreferredSortUsesGroups", true ),
m_fConstantUpdateDeltaSeconds ( Options, "ConstantUpdateDeltaSeconds",0 ),
m_fPadStickSeconds ( Options, "PadStickSeconds", 0 ),
m_bForceMipMaps ( Options, "ForceMipMaps", 0 ),
m_bTrilinearFiltering ( Options, "TrilinearFiltering", 0 ),
m_bAnisotropicFiltering ( Options, "AnisotropicFiltering", 0 ),
m_bSignProfileData ( Options, "SignProfileData", false ),
m_bEditorShowBGChangesPlay ( Options, "EditorShowBGChangesPlay", false ),
m_CourseSortOrder ( Options, "CourseSortOrder", COURSE_SORT_SONGS ),
m_bMoveRandomToEnd ( Options, "MoveRandomToEnd", false ),
m_bSubSortByNumSteps ( Options, "SubSortByNumSteps", false ),
m_GetRankingName ( Options, "GetRankingName", RANKING_ON ),
m_ScoringType ( Options, "ScoringType", SCORING_MAX2 ),
m_BoostAppPriority ( Options, "BoostAppPriority", BOOST_AUTO ),
m_sAdditionalSongFolders ( Options, "AdditionalSongFolders", "" ),
m_sAdditionalFolders ( Options, "AdditionalFolders", "" ),
m_sLastSeenVideoDriver ( Options, "LastSeenVideoDriver", "" ),
m_sLastSeenInputDevices ( Options, "LastSeenInputDevices", "" ),
#if defined(WIN32)
m_iLastSeenMemory ( Options, "LastSeenMemory", 0 ),
#endif
m_sVideoRenderers ( Options, "VideoRenderers", "" ), // StepMania.cpp sets these on first run:
m_bSmoothLines ( Options, "SmoothLines", false ),
m_sSoundDrivers ( Options, "SoundDrivers", "" ),
m_iSoundWriteAhead ( Options, "SoundWriteAhead", 0 ),
m_iSoundDevice ( Options, "SoundDevice", "" ),
m_fSoundVolume ( Options, "SoundVolume", -1 ), // default
m_SoundResampleQuality ( Options, "SoundResampleQuality", RageSoundReader_Resample::RESAMP_NORMAL ),
m_sInputDrivers ( Options, "InputDrivers", "" ),
m_sMovieDrivers ( Options, "MovieDrivers", "" ),
m_sLightsDriver ( Options, "LightsDriver", "" ),
m_sLightsStepsDifficulty ( Options, "LightsStepsDifficulty", "medium" ),
m_bBlinkGameplayButtonLightsOnNote ( Options, "BlinkGameplayButtonLightsOnNote",false ),
m_bAllowUnacceleratedRenderer ( Options, "AllowUnacceleratedRenderer",false ),
m_bThreadedInput ( Options, "ThreadedInput", true ),
m_bThreadedMovieDecode ( Options, "ThreadedMovieDecode", true ),
m_bScreenTestMode ( Options, "ScreenTestMode", false ),
m_sMachineName ( Options, "MachineName", "" ),
m_sIgnoredMessageWindows ( Options, "IgnoredMessageWindows", "" ),
m_sCoursesToShowRanking ( Options, "CoursesToShowRanking", "" ),
/* Debug: */
m_bLogToDisk ( Options, "LogToDisk", true ),
m_bForceLogFlush ( Options, "ForceLogFlush", false ),
m_bShowLogOutput ( Options, "ShowLogOutput", false ),
m_bTimestamping ( Options, "Timestamping", false ),
m_bLogSkips ( Options, "LogSkips", false ),
m_bLogCheckpoints ( Options, "LogCheckpoints", false ),
m_bShowLoadingWindow ( Options, "ShowLoadingWindow", true ),
/* Game-specific prefs: */
m_sDefaultModifiers ( Options, "DefaultModifiers", "" )
#if defined(XBOX)
,
m_bEnableVirtualMemory ( Options, "EnableVirtualMemory", true ),
m_iPageFileSize ( Options, "PageFileSize", 384 ),
m_iPageSize ( Options, "PageSize", 16 ),
m_iPageThreshold ( Options, "PageThreshold", 8 ),
m_bLogVirtualMemory ( Options, "LogVirtualMemory", false )
#endif
{
Init();
ReadGlobalPrefsFromDisk();
}
void PrefsManager::Init()
2002-02-28 19:40:40 +00:00
{
FOREACHS_CONST( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
(*p)->LoadDefault();
2002-02-28 19:40:40 +00:00
}
PrefsManager::~PrefsManager()
{
}
2003-10-08 08:01:41 +00:00
void PrefsManager::ReadGlobalPrefsFromDisk()
2002-02-28 19:40:40 +00:00
{
ReadPrefsFromFile( DEFAULTS_INI_PATH );
ReadPrefsFromFile( STEPMANIA_INI_PATH );
ReadPrefsFromFile( STATIC_INI_PATH );
}
2003-10-08 08:01:41 +00:00
void PrefsManager::ResetToFactoryDefaults()
{
// clobber the users prefs by initing then applying defaults
Init();
2005-05-06 20:41:05 +00:00
m_bFirstRun.Set( false );
ReadPrefsFromFile( DEFAULTS_INI_PATH );
2004-08-22 18:08:06 +00:00
ReadPrefsFromFile( STATIC_INI_PATH );
SaveGlobalPrefsToDisk();
}
void PrefsManager::ReadPrefsFromFile( CString sIni )
{
IniFile ini;
if( !ini.ReadFile(sIni) )
return;
2002-02-28 19:40:40 +00:00
2005-02-19 01:59:31 +00:00
ReadGlobalPrefsFromIni( ini );
}
void PrefsManager::ReadGlobalPrefsFromIni( const IniFile &ini )
{
FOREACHS_CONST( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
(*p)->ReadFrom( ini );
2005-05-06 10:48:32 +00:00
2005-05-16 09:36:32 +00:00
// validate
2005-05-06 20:41:05 +00:00
m_iSongsPerPlay.Set( clamp(m_iSongsPerPlay.Get(),0,MAX_SONGS_PER_PLAY) );
2005-05-16 09:36:32 +00:00
FOREACH_PlayerNumber( pn )
GetMemoryCardOsMountPoint(pn).Set( FixSlashes(GetMemoryCardOsMountPoint(pn)) );
2002-02-28 19:40:40 +00:00
}
void PrefsManager::SaveGlobalPrefsToDisk() const
2002-02-28 19:40:40 +00:00
{
IniFile ini;
2005-02-19 01:59:31 +00:00
SaveGlobalPrefsToIni( ini );
ini.WriteFile( STEPMANIA_INI_PATH );
}
2002-04-28 20:42:32 +00:00
2005-02-19 01:59:31 +00:00
void PrefsManager::SaveGlobalPrefsToIni( IniFile &ini ) const
{
FOREACHS_CONST( IPreference*, *SubscriptionManager<IPreference>::s_pSubscribers, p )
(*p)->WriteTo( ini );
2002-02-28 19:40:40 +00:00
}
2005-05-16 09:36:32 +00:00
// wrappers
CString PrefsManager::GetSoundDrivers() { return m_sSoundDrivers.Get().empty() ? (CString)DEFAULT_SOUND_DRIVER_LIST : m_sSoundDrivers; }
float PrefsManager::GetSoundVolume() { return m_fSoundVolume==-1 ? DEFAULT_SOUND_VOLUME : m_fSoundVolume; }
CString PrefsManager::GetInputDrivers() { return m_sInputDrivers.Get().empty() ? (CString)DEFAULT_INPUT_DRIVER_LIST : m_sInputDrivers; }
CString PrefsManager::GetMovieDrivers() { return m_sMovieDrivers.Get().empty() ? (CString)DEFAULT_MOVIE_DRIVER_LIST : m_sMovieDrivers; }
CString PrefsManager::GetLightsDriver() { return m_sLightsDriver.Get().empty() ? (CString)DEFAULT_LIGHTS_DRIVER : m_sLightsDriver; }
2005-02-17 21:35:45 +00:00
// lua start
#include "LuaBinding.h"
template<class T>
class LunaPrefsManager : public Luna<T>
{
public:
LunaPrefsManager() { LUA->Register( Register ); }
static int GetPreference( T* p, lua_State *L )
{
CString sName = SArg(1);
IPreference *pPref = PREFSMAN->GetPreferenceByName( sName );
if( pPref == NULL )
{
LOG->Warn( "GetPreference: unknown preference \"%s\"", sName.c_str() );
lua_pushnil( L );
}
else
2005-02-23 01:11:02 +00:00
{
pPref->PushValue( L );
2005-02-23 01:11:02 +00:00
}
return 1;
}
static int SetPreference( T* p, lua_State *L )
{
CString sName = SArg(1);
IPreference *pPref = PREFSMAN->GetPreferenceByName( sName );
if( pPref == NULL )
LOG->Warn( "GetPreference: unknown preference \"%s\"", sName.c_str() );
else
{
lua_pushvalue( L, 2 );
pPref->SetFromStack( L );
}
return 0;
}
2005-02-17 21:35:45 +00:00
static void Register(lua_State *L)
{
ADD_METHOD( GetPreference )
ADD_METHOD( SetPreference )
2005-02-17 21:35:45 +00:00
Luna<T>::Register( L );
// Add global singleton if constructed already. If it's not constructed yet,
// then we'll register it later when we reinit Lua just before
// initializing the display.
if( PREFSMAN )
{
lua_pushstring(L, "PREFSMAN");
PREFSMAN->PushSelf( LUA->L );
lua_settable(L, LUA_GLOBALSINDEX);
}
}
};
LUA_REGISTER_CLASS( PrefsManager )
// lua end
2005-01-17 04:05:40 +00:00
#include "LuaFunctions.h"
int LuaFunc_GetPreference( lua_State *L )
{
REQ_ARGS( "GetPreference", 1 );
REQ_ARG( "GetPreference", 1, string );
CString sName;
LuaHelpers::PopStack( sName, NULL );
IPreference *pPref = PREFSMAN->GetPreferenceByName( sName );
if( pPref == NULL )
{
LOG->Warn( "GetPreference: unknown preference \"%s\"", sName.c_str() );
lua_pushnil( L );
}
else
pPref->PushValue( L );
return 1;
}
LuaFunction( GetPreference ); /* register it */
2005-01-26 07:34:20 +00:00
LuaFunction_NoArgs( EventMode, PREFSMAN->m_bEventMode )
LuaFunction_NoArgs( ShowCaution, PREFSMAN->m_bShowCaution )
2005-01-17 04:05:40 +00:00
2004-06-08 01:24:17 +00:00
/*
* (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.
*/