From e389ba6191f53f13ed0815be7288b79f687b67d5 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Mon, 16 May 2005 09:36:32 +0000 Subject: [PATCH] convert the rest to use Preference --- stepmania/src/Course.cpp | 2 +- stepmania/src/MemoryCardManager.cpp | 16 +- stepmania/src/MusicWheel.cpp | 21 +- stepmania/src/Preference.cpp | 5 + stepmania/src/PrefsManager.cpp | 362 +++++--------------- stepmania/src/PrefsManager.h | 140 +++++--- stepmania/src/ProfileManager.cpp | 2 +- stepmania/src/RageInputDevice.h | 4 + stepmania/src/RageSound.cpp | 2 +- stepmania/src/ScoreKeeperMAX2.cpp | 6 +- stepmania/src/ScreenDemonstration.cpp | 4 +- stepmania/src/ScreenEdit.cpp | 2 +- stepmania/src/ScreenEvaluation.cpp | 2 +- stepmania/src/ScreenGameplay.cpp | 2 +- stepmania/src/ScreenGameplayMultiplayer.cpp | 2 +- stepmania/src/ScreenNameEntry.cpp | 4 +- stepmania/src/ScreenOptionsMaster.cpp | 2 +- stepmania/src/ScreenOptionsMasterPrefs.cpp | 10 +- stepmania/src/ScreenProfileOptions.cpp | 14 +- stepmania/src/ScreenRanking.cpp | 4 +- stepmania/src/ScreenSMOnlineLogin.cpp | 6 +- stepmania/src/StepMania.cpp | 56 +-- 22 files changed, 261 insertions(+), 407 deletions(-) diff --git a/stepmania/src/Course.cpp b/stepmania/src/Course.cpp index 47b51f06a1..ce9c6121d9 100644 --- a/stepmania/src/Course.cpp +++ b/stepmania/src/Course.cpp @@ -1143,7 +1143,7 @@ RageColor Course::GetColor() const // FIXME: Calculate the meter. int iMeter = 5; - switch (PREFSMAN->m_iCourseSortOrder) + switch (PREFSMAN->m_CourseSortOrder) { case PrefsManager::COURSE_SORT_SONGS: if( m_entries.size() >= 7 ) return SORT_LEVEL2_COLOR; diff --git a/stepmania/src/MemoryCardManager.cpp b/stepmania/src/MemoryCardManager.cpp index e383d6e455..7f57fbdb75 100644 --- a/stepmania/src/MemoryCardManager.cpp +++ b/stepmania/src/MemoryCardManager.cpp @@ -376,21 +376,21 @@ void MemoryCardManager::Update( float fDelta ) FOREACH( UsbStorageDevice, vUnassignedDevices, d ) { // search for card dir match - if( !PREFSMAN->m_sMemoryCardOsMountPoint[p].empty() && - d->sOsMountDir.CompareNoCase(PREFSMAN->m_sMemoryCardOsMountPoint[p]) ) + if( !PREFSMAN->GetMemoryCardOsMountPoint(p).Get().empty() && + d->sOsMountDir.CompareNoCase(PREFSMAN->GetMemoryCardOsMountPoint(p).Get()) ) continue; // not a match // search for USB bus match - if( PREFSMAN->m_iMemoryCardUsbBus[p] != -1 && - PREFSMAN->m_iMemoryCardUsbBus[p] != d->iBus ) + if( PREFSMAN->GetMemoryCardUsbBus(p) != -1 && + PREFSMAN->GetMemoryCardUsbBus(p) != d->iBus ) continue; // not a match - if( PREFSMAN->m_iMemoryCardUsbPort[p] != -1 && - PREFSMAN->m_iMemoryCardUsbPort[p] != d->iPort ) + if( PREFSMAN->GetMemoryCardUsbPort(p) != -1 && + PREFSMAN->GetMemoryCardUsbPort(p) != d->iPort ) continue; // not a match - if( PREFSMAN->m_iMemoryCardUsbLevel[p] != -1 && - PREFSMAN->m_iMemoryCardUsbLevel[p] != d->iLevel ) + if( PREFSMAN->GetMemoryCardUsbLevel(p) != -1 && + PREFSMAN->GetMemoryCardUsbLevel(p) != d->iLevel ) continue; // not a match LOG->Trace( "Player %i: device match: sDevice: %s, iBus: %d, iLevel: %d, iPort: %d, sOsMountDir: %s", diff --git a/stepmania/src/MusicWheel.cpp b/stepmania/src/MusicWheel.cpp index 27725a0fa4..99c0b7e50f 100644 --- a/stepmania/src/MusicWheel.cpp +++ b/stepmania/src/MusicWheel.cpp @@ -663,21 +663,28 @@ void MusicWheel::BuildWheelItemDatas( vector &arrayWheelItemDatas default: ASSERT(0); break; } - if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_SONGS) + if( PREFSMAN->m_CourseSortOrder == PrefsManager::COURSE_SORT_SONGS ) + { CourseUtil::SortCoursePointerArrayByDifficulty( apCourses ); + } else { - if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_METER) + switch( PREFSMAN->m_CourseSortOrder ) + { + case PrefsManager::COURSE_SORT_METER: CourseUtil::SortCoursePointerArrayByAvgDifficulty( apCourses ); - - if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_METER_SUM) + break; + case PrefsManager::COURSE_SORT_METER_SUM: CourseUtil::SortCoursePointerArrayByTotalDifficulty( apCourses ); - - if (PREFSMAN->m_iCourseSortOrder == PrefsManager::COURSE_SORT_RANK) + break; + case PrefsManager::COURSE_SORT_RANK: CourseUtil::SortCoursePointerArrayByRanking( apCourses ); + break; + default: ASSERT(0); + } // since we can't agree, make it an option - if (PREFSMAN->m_bMoveRandomToEnd) + if( PREFSMAN->m_bMoveRandomToEnd ) CourseUtil::MoveRandomToEnd( apCourses ); } diff --git a/stepmania/src/Preference.cpp b/stepmania/src/Preference.cpp index 1f6872c6cf..e00b2875de 100644 --- a/stepmania/src/Preference.cpp +++ b/stepmania/src/Preference.cpp @@ -72,6 +72,11 @@ READFROM_AND_WRITETO( CoinMode, int& ) READFROM_AND_WRITETO( Premium, int& ) READFROM_AND_WRITETO( PrefsManager::Maybe, int& ) READFROM_AND_WRITETO( PrefsManager::CharacterOption, int& ) +READFROM_AND_WRITETO( PrefsManager::CourseSortOrders, int& ) +READFROM_AND_WRITETO( PrefsManager::GetRankingName, int& ) +READFROM_AND_WRITETO( PrefsManager::ScoringTypes, int& ) +READFROM_AND_WRITETO( PrefsManager::BoostAppPriority, int& ) +READFROM_AND_WRITETO( RageSoundReader_Resample::ResampleQuality, int& ) void IPreference::ReadFrom( const IniFile &ini ) { diff --git a/stepmania/src/PrefsManager.cpp b/stepmania/src/PrefsManager.cpp index 7c5b16e22f..43f6531750 100644 --- a/stepmania/src/PrefsManager.cpp +++ b/stepmania/src/PrefsManager.cpp @@ -21,7 +21,6 @@ PrefsManager* PREFSMAN = NULL; // global and accessable from anywhere in our pro const float DEFAULT_SOUND_VOLUME = 1.00f; const CString DEFAULT_LIGHTS_DRIVER = "Null"; - // // For self-registering prefs // @@ -226,10 +225,18 @@ PrefsManager::PrefsManager() : m_bDisableScreenSaver ( Options, "DisableScreenSaver", true ), m_sLanguage ( Options, "Language", "" ), // ThemeManager will deal with this invalid language m_sMemoryCardProfileSubdir ( Options, "MemoryCardProfileSubdir", PRODUCT_NAME ), - m_iProductID ( Options, "ProductID", 1 ), - - m_bMemoryCards ( Options, "MemoryCards", false ), - + 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 ), m_iCenterImageTranslateX ( Options, "CenterImageTranslateX", 0 ), m_iCenterImageTranslateY ( Options, "CenterImageTranslateY", 0 ), m_fCenterImageAddWidth ( Options, "CenterImageAddWidth", 0 ), @@ -243,7 +250,69 @@ PrefsManager::PrefsManager() : m_iMaxRecentScoresForPlayer ( Options, "MaxRecentScoresForPlayer", 20 ), m_bAllowMultipleHighScoreWithSameName ( Options, "AllowMultipleHighScoreWithSameName", true ), m_bCelShadeModels ( Options, "CelShadeModels", false ), // Work-In-Progress.. disable by default. - m_bPreferredSortUsesGroups ( Options, "PreferredSortUsesGroups", true ) + 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(); @@ -251,88 +320,6 @@ PrefsManager::PrefsManager() : void PrefsManager::Init() { - m_fConstantUpdateDeltaSeconds = 0; - - m_iBoostAppPriority = -1; - m_bSmoothLines = false; - - // default to old sort order - m_iCourseSortOrder = COURSE_SORT_SONGS; - m_bMoveRandomToEnd = false; - m_bSubSortByNumSteps = false; - m_iScoringType = SCORING_MAX2; - - m_iGetRankingName = RANKING_ON; - - - m_fPadStickSeconds = 0; - m_bForceMipMaps = false; - m_bTrilinearFiltering = false; - m_bAnisotropicFiltering = false; - g_bAutoRestart = false; - m_bSignProfileData = false; - - m_bEditorShowBGChangesPlay = false; - - m_sSoundDrivers = DEFAULT_SOUND_DRIVER_LIST; - /* Number of frames to write ahead; usually 44100 frames per second. - * (Number of millisec would be more flexible, but it's more useful to - * specify numbers directly.) This is purely a troubleshooting option - * and is not honored by all sound drivers. */ - m_iSoundWriteAhead = 0; - m_iSoundDevice = ""; - m_fSoundVolume = DEFAULT_SOUND_VOLUME; - m_iSoundResampleQuality = RageSoundReader_Resample::RESAMP_NORMAL; - - m_sInputDrivers = DEFAULT_INPUT_DRIVER_LIST; - - m_sMovieDrivers = DEFAULT_MOVIE_DRIVER_LIST; - - // StepMania.cpp sets these on first run: - m_sVideoRenderers = ""; -#if defined(WIN32) - m_iLastSeenMemory = 0; -#endif - - m_sLightsDriver = DEFAULT_LIGHTS_DRIVER; - m_sLightsStepsDifficulty = "medium"; - m_bBlinkGameplayButtonLightsOnNote = false; - m_bAllowUnacceleratedRenderer = false; - m_bThreadedInput = true; - m_bThreadedMovieDecode = true; - m_bScreenTestMode = false; - m_sMachineName = "NoName"; - m_sIgnoredMessageWindows = ""; - - m_sCoursesToShowRanking = ""; - - m_bLogToDisk = true; - m_bForceLogFlush = false; -#ifdef DEBUG - m_bShowLogOutput = true; -#else - m_bShowLogOutput = false; -#endif - m_bTimestamping = false; - m_bLogSkips = false; - m_bLogCheckpoints = false; - m_bShowLoadingWindow = true; - - FOREACH_PlayerNumber( p ) - { - m_iMemoryCardUsbBus[p] = -1; - m_iMemoryCardUsbPort[p] = -1; - m_iMemoryCardUsbLevel[p] = -1; - } - -#if defined(XBOX) - m_bEnableVirtualMemory = true; - m_iPageFileSize = 384; - m_iPageSize = 16; - m_iPageThreshold = 8; - m_bLogVirtualMemory = false; -#endif - FOREACHS_CONST( IPreference*, *SubscriptionManager::s_pSubscribers, p ) (*p)->LoadDefault(); } @@ -370,89 +357,13 @@ void PrefsManager::ReadPrefsFromFile( CString sIni ) void PrefsManager::ReadGlobalPrefsFromIni( const IniFile &ini ) { - ini.GetValue( "Options", "ConstantUpdateDeltaSeconds", m_fConstantUpdateDeltaSeconds ); - - ini.GetValue( "Options", "SoundDrivers", m_sSoundDrivers ); - ini.GetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead ); - ini.GetValue( "Options", "SoundDevice", m_iSoundDevice ); - ini.GetValue( "Options", "InputDrivers", m_sInputDrivers ); - ini.GetValue( "Options", "MovieDrivers", m_sMovieDrivers ); - ini.GetValue( "Options", "SoundVolume", m_fSoundVolume ); - ini.GetValue( "Options", "LightsDriver", m_sLightsDriver ); - ini.GetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality ); - - m_iCoinsPerCredit.Set( max(m_iCoinsPerCredit.Get(),1) ); - - ini.GetValue( "Options", "BoostAppPriority", m_iBoostAppPriority ); - ini.GetValue( "Options", "LightsStepsDifficulty", m_sLightsStepsDifficulty ); - ini.GetValue( "Options", "BlinkGameplayButtonLightsOnNote", m_bBlinkGameplayButtonLightsOnNote ); - ini.GetValue( "Options", "AllowUnacceleratedRenderer", m_bAllowUnacceleratedRenderer ); - ini.GetValue( "Options", "ThreadedInput", m_bThreadedInput ); - ini.GetValue( "Options", "ThreadedMovieDecode", m_bThreadedMovieDecode ); - ini.GetValue( "Options", "ScreenTestMode", m_bScreenTestMode ); - ini.GetValue( "Options", "MachineName", m_sMachineName ); - ini.GetValue( "Options", "IgnoredMessageWindows", m_sIgnoredMessageWindows ); - - ini.GetValue( "Options", "CourseSortOrder", (int&)m_iCourseSortOrder ); - ini.GetValue( "Options", "MoveRandomToEnd", m_bMoveRandomToEnd ); - ini.GetValue( "Options", "SubSortByNumSteps", m_bSubSortByNumSteps ); - - ini.GetValue( "Options", "ScoringType", (int&)m_iScoringType ); - - ini.GetValue( "Options", "VideoRenderers", m_sVideoRenderers ); - ini.GetValue( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); - ini.GetValue( "Options", "LastSeenInputDevices", m_sLastSeenInputDevices ); -#if defined(WIN32) - ini.GetValue( "Options", "LastSeenMemory", m_iLastSeenMemory ); -#endif - ini.GetValue( "Options", "CoursesToShowRanking", m_sCoursesToShowRanking ); - ini.GetValue( "Options", "GetRankingName", (int&)m_iGetRankingName); - ini.GetValue( "Options", "SmoothLines", m_bSmoothLines ); - - FOREACH_PlayerNumber( p ) - { - ini.GetValue( "Options", ssprintf("DefaultLocalProfileIDP%d",p+1), m_sDefaultLocalProfileID[p] ); - ini.GetValue( "Options", ssprintf("MemoryCardOsMountPointP%d",p+1), m_sMemoryCardOsMountPoint[p] ); - FixSlashesInPlace( m_sMemoryCardOsMountPoint[p] ); - ini.GetValue( "Options", ssprintf("MemoryCardUsbBusP%d",p+1), m_iMemoryCardUsbBus[p] ); - ini.GetValue( "Options", ssprintf("MemoryCardUsbPortP%d",p+1), m_iMemoryCardUsbPort[p] ); - ini.GetValue( "Options", ssprintf("MemoryCardUsbLevelP%d",p+1), m_iMemoryCardUsbLevel[p] ); - } - - ini.GetValue( "Options", "PadStickSeconds", m_fPadStickSeconds ); - ini.GetValue( "Options", "ForceMipMaps", m_bForceMipMaps ); - ini.GetValue( "Options", "TrilinearFiltering", m_bTrilinearFiltering ); - ini.GetValue( "Options", "AnisotropicFiltering", m_bAnisotropicFiltering ); - ini.GetValue( "Options", "AutoRestart", g_bAutoRestart ); - ini.GetValue( "Options", "SignProfileData", m_bSignProfileData ); - - ini.GetValue( "Editor", "ShowBGChangesPlay", m_bEditorShowBGChangesPlay ); - - ini.GetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders ); - ini.GetValue( "Options", "AdditionalFolders", m_sAdditionalFolders ); - FixSlashesInPlace(m_sAdditionalSongFolders); - FixSlashesInPlace(m_sAdditionalFolders); - -#if defined(XBOX) - ini.GetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory ); - ini.GetValue( "Options", "PageFileSize", m_iPageFileSize ); - ini.GetValue( "Options", "PageSize", m_iPageSize ); - ini.GetValue( "Options", "PageThreshold", m_iPageThreshold ); - ini.GetValue( "Debug", "LogVirtualMemory", m_bLogVirtualMemory ); -#endif - - ini.GetValue( "Debug", "LogToDisk", m_bLogToDisk ); - ini.GetValue( "Debug", "ForceLogFlush", m_bForceLogFlush ); - ini.GetValue( "Debug", "ShowLogOutput", m_bShowLogOutput ); - ini.GetValue( "Debug", "Timestamping", m_bTimestamping ); - ini.GetValue( "Debug", "LogSkips", m_bLogSkips ); - ini.GetValue( "Debug", "LogCheckpoints", m_bLogCheckpoints ); - ini.GetValue( "Debug", "ShowLoadingWindow", m_bShowLoadingWindow ); - FOREACHS_CONST( IPreference*, *SubscriptionManager::s_pSubscribers, p ) (*p)->ReadFrom( ini ); + // validate m_iSongsPerPlay.Set( clamp(m_iSongsPerPlay.Get(),0,MAX_SONGS_PER_PLAY) ); + FOREACH_PlayerNumber( pn ) + GetMemoryCardOsMountPoint(pn).Set( FixSlashes(GetMemoryCardOsMountPoint(pn)) ); } void PrefsManager::SaveGlobalPrefsToDisk() const @@ -464,120 +375,17 @@ void PrefsManager::SaveGlobalPrefsToDisk() const void PrefsManager::SaveGlobalPrefsToIni( IniFile &ini ) const { - ini.SetValue( "Options", "ConstantUpdateDeltaSeconds", m_fConstantUpdateDeltaSeconds ); - ini.SetValue( "Options", "BackgroundMode", m_BackgroundMode); - ini.SetValue( "Options", "NumBackgrounds", m_iNumBackgrounds); - ini.SetValue( "Options", "BGBrightness", m_fBGBrightness ); - - ini.SetValue( "Options", "JudgeWindowScale", m_fJudgeWindowScale ); - ini.SetValue( "Options", "JudgeWindowAdd", m_fJudgeWindowAdd ); - ini.SetValue( "Options", "JudgeWindowSecondsMarvelous", m_fJudgeWindowSecondsMarvelous ); - ini.SetValue( "Options", "JudgeWindowSecondsPerfect", m_fJudgeWindowSecondsPerfect ); - ini.SetValue( "Options", "JudgeWindowSecondsGreat", m_fJudgeWindowSecondsGreat ); - ini.SetValue( "Options", "JudgeWindowSecondsGood", m_fJudgeWindowSecondsGood ); - ini.SetValue( "Options", "JudgeWindowSecondsBoo", m_fJudgeWindowSecondsBoo ); - ini.SetValue( "Options", "JudgeWindowSecondsOK", m_fJudgeWindowSecondsOK ); - ini.SetValue( "Options", "JudgeWindowSecondsRoll", m_fJudgeWindowSecondsRoll ); - ini.SetValue( "Options", "JudgeWindowSecondsMine", m_fJudgeWindowSecondsMine ); - ini.SetValue( "Options", "JudgeWindowSecondsAttack", m_fJudgeWindowSecondsAttack ); - ini.SetValue( "Options", "LifeDifficultyScale", m_fLifeDifficultyScale ); - - ini.SetValue( "Options", "HiddenSongs", m_bHiddenSongs ); - ini.SetValue( "Options", "Vsync", m_bVsync ); - ini.SetValue( "Options", "Interlaced", m_bInterlaced ); - ini.SetValue( "Options", "PAL", m_bPAL ); - - ini.SetValue( "Options", "DelayedTextureDelete", m_bDelayedTextureDelete ); - ini.SetValue( "Options", "TexturePreload", m_bTexturePreload ); - ini.SetValue( "Options", "DelayedScreenLoad", m_bDelayedScreenLoad ); - ini.SetValue( "Options", "DelayedModelDelete", m_bDelayedModelDelete ); - ini.SetValue( "Options", "FastLoad", m_bFastLoad ); - ini.SetValue( "Options", "SoundResampleQuality", m_iSoundResampleQuality ); - ini.SetValue( "Options", "BoostAppPriority", m_iBoostAppPriority ); - ini.SetValue( "Options", "LightsStepsDifficulty", m_sLightsStepsDifficulty ); - ini.SetValue( "Options", "BlinkGameplayButtonLightsOnNote", m_bBlinkGameplayButtonLightsOnNote ); - ini.SetValue( "Options", "AllowUnacceleratedRenderer", m_bAllowUnacceleratedRenderer ); - ini.SetValue( "Options", "ThreadedInput", m_bThreadedInput ); - ini.SetValue( "Options", "ThreadedMovieDecode", m_bThreadedMovieDecode ); - ini.SetValue( "Options", "ScreenTestMode", m_bScreenTestMode ); - ini.SetValue( "Options", "MachineName", m_sMachineName ); - ini.SetValue( "Options", "IgnoredMessageWindows", m_sIgnoredMessageWindows ); - ini.SetValue( "Options", "VideoRenderers", m_sVideoRenderers ); - ini.SetValue( "Options", "LastSeenVideoDriver", m_sLastSeenVideoDriver ); - ini.SetValue( "Options", "LastSeenInputDevices", m_sLastSeenInputDevices ); -#if defined(WIN32) - ini.SetValue( "Options", "LastSeenMemory", m_iLastSeenMemory ); -#endif - ini.SetValue( "Options", "CoursesToShowRanking", m_sCoursesToShowRanking ); - ini.SetValue( "Options", "GetRankingName", m_iGetRankingName); - ini.SetValue( "Options", "SmoothLines", m_bSmoothLines ); - - ini.SetValue( "Options", "CourseSortOrder", m_iCourseSortOrder ); - ini.SetValue( "Options", "MoveRandomToEnd", m_bMoveRandomToEnd ); - ini.SetValue( "Options", "SubSortByNumSteps", m_bSubSortByNumSteps ); - - ini.SetValue( "Options", "ScoringType", m_iScoringType ); - - FOREACH_PlayerNumber( p ) - { - ini.SetValue( "Options", ssprintf("DefaultLocalProfileIDP%d",p+1), m_sDefaultLocalProfileID[p] ); - ini.SetValue( "Options", ssprintf("MemoryCardOsMountPointP%d",p+1), m_sMemoryCardOsMountPoint[p] ); - ini.SetValue( "Options", ssprintf("MemoryCardUsbBusP%d",p+1), m_iMemoryCardUsbBus[p] ); - ini.SetValue( "Options", ssprintf("MemoryCardUsbPortP%d",p+1), m_iMemoryCardUsbPort[p] ); - ini.SetValue( "Options", ssprintf("MemoryCardUsbLevelP%d",p+1), m_iMemoryCardUsbLevel[p] ); - } - - ini.SetValue( "Options", "PadStickSeconds", m_fPadStickSeconds ); - ini.SetValue( "Options", "ForceMipMaps", m_bForceMipMaps ); - ini.SetValue( "Options", "TrilinearFiltering", m_bTrilinearFiltering ); - ini.SetValue( "Options", "AnisotropicFiltering", m_bAnisotropicFiltering ); - ini.SetValue( "Options", "AutoRestart", g_bAutoRestart ); - ini.SetValue( "Options", "SignProfileData", m_bSignProfileData ); - - ini.SetValue( "Options", "SoundWriteAhead", m_iSoundWriteAhead ); - ini.SetValue( "Options", "SoundDevice", m_iSoundDevice ); - - ini.SetValue( "Editor", "ShowBGChangesPlay", m_bEditorShowBGChangesPlay ); - - /* Only write these if they aren't the default. This ensures that we can change - * the default and have it take effect for everyone (except people who - * tweaked this value). */ - if(m_sSoundDrivers != DEFAULT_SOUND_DRIVER_LIST) - ini.SetValue ( "Options", "SoundDrivers", m_sSoundDrivers ); - if(m_fSoundVolume != DEFAULT_SOUND_VOLUME) - ini.SetValue( "Options", "SoundVolume", m_fSoundVolume ); - if(m_sInputDrivers != DEFAULT_INPUT_DRIVER_LIST) - ini.SetValue ( "Options", "InputDrivers", m_sInputDrivers ); - if(m_sMovieDrivers != DEFAULT_MOVIE_DRIVER_LIST) - ini.SetValue ( "Options", "MovieDrivers", m_sMovieDrivers ); - if(m_sLightsDriver != DEFAULT_LIGHTS_DRIVER) - ini.SetValue( "Options", "LightsDriver", m_sLightsDriver ); - - ini.SetValue( "Options", "AdditionalSongFolders", m_sAdditionalSongFolders); - ini.SetValue( "Options", "AdditionalFolders", m_sAdditionalFolders); - -#if defined(XBOX) - ini.SetValue( "Options", "EnableVirtualMemory", m_bEnableVirtualMemory ); - ini.SetValue( "Options", "PageFileSize", m_iPageFileSize ); - ini.SetValue( "Options", "PageSize", m_iPageSize ); - ini.SetValue( "Options", "PageThreshold", m_iPageThreshold ); -#endif - - ini.SetValue( "Debug", "LogToDisk", m_bLogToDisk ); - ini.SetValue( "Debug", "ForceLogFlush", m_bForceLogFlush ); - ini.SetValue( "Debug", "ShowLogOutput", m_bShowLogOutput ); - ini.SetValue( "Debug", "Timestamping", m_bTimestamping ); - ini.SetValue( "Debug", "LogSkips", m_bLogSkips ); - ini.SetValue( "Debug", "LogCheckpoints", m_bLogCheckpoints ); - ini.SetValue( "Debug", "ShowLoadingWindow", m_bShowLoadingWindow ); -#if defined(XBOX) - ini.SetValue( "Debug", "LogVirtualMemory", m_bLogVirtualMemory ); -#endif - FOREACHS_CONST( IPreference*, *SubscriptionManager::s_pSubscribers, p ) (*p)->WriteTo( ini ); } +// 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; } + // lua start #include "LuaBinding.h" diff --git a/stepmania/src/PrefsManager.h b/stepmania/src/PrefsManager.h index 15285d4bf8..a3c22ef4e7 100644 --- a/stepmania/src/PrefsManager.h +++ b/stepmania/src/PrefsManager.h @@ -7,6 +7,7 @@ #include "GameConstantsAndTypes.h" #include "Grade.h" // for NUM_GRADE_TIERS #include "Preference.h" +#include "RageSoundReader_Resample.h" // for ResampleQuality class IniFile; const int MAX_SONGS_PER_PLAY = 7; @@ -206,12 +207,22 @@ public: Preference m_sLanguage; Preference m_sMemoryCardProfileSubdir; // the directory on a memory card to look in for a profile Preference m_iProductID; // Saved in HighScore to track what software version a score came from. - CString m_sDefaultLocalProfileID[NUM_PLAYERS]; + Preference m_sDefaultLocalProfileIDP1, m_sDefaultLocalProfileIDP2; + Preference& GetDefaultLocalProfileID( PlayerNumber pn ) + { switch(pn) { case PLAYER_1: return m_sDefaultLocalProfileIDP1; case PLAYER_2: return m_sDefaultLocalProfileIDP2; default: ASSERT(0); } } Preference m_bMemoryCards; - CString m_sMemoryCardOsMountPoint[NUM_PLAYERS]; // if set, always use the device that mounts to this point - int m_iMemoryCardUsbBus[NUM_PLAYERS]; // look for this bus when assigning cards. -1 = match any - int m_iMemoryCardUsbPort[NUM_PLAYERS]; // look for this port when assigning cards. -1 = match any - int m_iMemoryCardUsbLevel[NUM_PLAYERS]; // look for this level when assigning cards. -1 = match any + Preference m_sMemoryCardOsMountPointP1, m_sMemoryCardOsMountPointP2; // if set, always use the device that mounts to this point + Preference& GetMemoryCardOsMountPoint( PlayerNumber pn ) + { switch(pn) { case PLAYER_1: return m_sMemoryCardOsMountPointP1; case PLAYER_2: return m_sMemoryCardOsMountPointP2; default: ASSERT(0); } } + Preference m_iMemoryCardUsbBusP1, m_iMemoryCardUsbBusP2; // look for this bus when assigning cards. -1 = match any + Preference& GetMemoryCardUsbBus( PlayerNumber pn ) + { switch(pn) { case PLAYER_1: return m_iMemoryCardUsbBusP1; case PLAYER_2: return m_iMemoryCardUsbBusP2; default: ASSERT(0); } } + Preference m_iMemoryCardUsbPortP1, m_iMemoryCardUsbPortP2; // look for this port when assigning cards. -1 = match any + Preference& GetMemoryCardUsbPort( PlayerNumber pn ) + { switch(pn) { case PLAYER_1: return m_iMemoryCardUsbPortP1; case PLAYER_2: return m_iMemoryCardUsbPortP2; default: ASSERT(0); } } + Preference m_iMemoryCardUsbLevelP1, m_iMemoryCardUsbLevelP2; // look for this level when assigning cards. -1 = match any + Preference& GetMemoryCardUsbLevel( PlayerNumber pn ) + { switch(pn) { case PLAYER_1: return m_iMemoryCardUsbLevelP1; case PLAYER_2: return m_iMemoryCardUsbLevelP2; default: ASSERT(0); } } Preference m_iCenterImageTranslateX; Preference m_iCenterImageTranslateY; Preference m_fCenterImageAddWidth; @@ -229,90 +240,107 @@ public: /* experimental: force a specific update rate. This prevents big * animation jumps on frame skips. */ - float m_fConstantUpdateDeltaSeconds; // 0 to disable + Preference m_fConstantUpdateDeltaSeconds; // 0 to disable // Number of seconds it takes for a button on the controller to release // after pressed. - float m_fPadStickSeconds; + Preference m_fPadStickSeconds; // Useful for non 4:3 displays and resolutions < 640x480 where texels don't // map directly to pixels. - bool m_bForceMipMaps; - bool m_bTrilinearFiltering; // has no effect without mipmaps on - bool m_bAnisotropicFiltering; // has no effect without mipmaps on. Not mutually exclusive with trilinear. + Preference m_bForceMipMaps; + Preference m_bTrilinearFiltering; // has no effect without mipmaps on + Preference m_bAnisotropicFiltering; // has no effect without mipmaps on. Not mutually exclusive with trilinear. // If true, then signatures created when writing profile data // and verified when reading profile data. Leave this false if // you want to use a profile on different machines that don't // have the same key, or else the profile's data will be discarded. - bool m_bSignProfileData; + Preference m_bSignProfileData; /* Editor prefs: */ - bool m_bEditorShowBGChangesPlay; + Preference m_bEditorShowBGChangesPlay; // course ranking - enum CourseSortOrders { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK } m_iCourseSortOrder; - bool m_bMoveRandomToEnd; - bool m_bSubSortByNumSteps; - enum GetRankingName { RANKING_OFF, RANKING_ON, RANKING_LIST } m_iGetRankingName; + enum CourseSortOrders { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK }; + Preference m_CourseSortOrder; + Preference m_bMoveRandomToEnd; + Preference m_bSubSortByNumSteps; + enum GetRankingName { RANKING_OFF, RANKING_ON, RANKING_LIST }; + Preference m_GetRankingName; // scoring type; SCORING_MAX2 should always be first - enum ScoringTypes { SCORING_MAX2, SCORING_5TH } m_iScoringType; + enum ScoringTypes { SCORING_MAX2, SCORING_5TH }; + Preference m_ScoringType; - /* 0 = no; 1 = yes; -1 = auto (do whatever is appropriate for the arch). */ - int m_iBoostAppPriority; + enum BoostAppPriority { BOOST_NO, BOOST_YES, BOOST_AUTO }; /* auto = do whatever is appropriate for the arch. */ + Preference m_BoostAppPriority; - CString m_sAdditionalSongFolders; - CString m_sAdditionalFolders; + Preference m_sAdditionalSongFolders; + Preference m_sAdditionalFolders; - CString m_sLastSeenVideoDriver; - CString m_sLastSeenInputDevices; + Preference m_sLastSeenVideoDriver; + Preference m_sLastSeenInputDevices; #if defined(WIN32) - int m_iLastSeenMemory; + Preference m_iLastSeenMemory; #endif - CString m_sVideoRenderers; - bool m_bSmoothLines; - CString m_sSoundDrivers; - int m_iSoundWriteAhead; - CString m_iSoundDevice; - float m_fSoundVolume; - int m_iSoundResampleQuality; - CString m_sInputDrivers; - CString m_sMovieDrivers; - CString m_sLightsDriver; - CString m_sLightsStepsDifficulty; - bool m_bBlinkGameplayButtonLightsOnNote; - bool m_bAllowUnacceleratedRenderer; - bool m_bThreadedInput; - bool m_bThreadedMovieDecode; - bool m_bScreenTestMode; - CString m_sMachineName; + Preference m_sVideoRenderers; // StepMania.cpp sets these on first run based on the card + Preference m_bSmoothLines; +private: + Preference m_sSoundDrivers; // "" == default +public: + Preference m_fSoundVolume; // -1 == default + Preference m_iSoundWriteAhead; + Preference m_iSoundDevice; + Preference m_SoundResampleQuality; +private: + Preference m_sInputDrivers; // "" == default + Preference m_sMovieDrivers; // "" == default + Preference m_sLightsDriver; // "" == default +public: + Preference m_sLightsStepsDifficulty; + Preference m_bBlinkGameplayButtonLightsOnNote; + Preference m_bAllowUnacceleratedRenderer; + Preference m_bThreadedInput; + Preference m_bThreadedMovieDecode; + Preference m_bScreenTestMode; + Preference m_sMachineName; - CString m_sIgnoredMessageWindows; + Preference m_sIgnoredMessageWindows; - CString m_sCoursesToShowRanking; + Preference m_sCoursesToShowRanking; /* Debug: */ - bool m_bLogToDisk; - bool m_bForceLogFlush; - bool m_bShowLogOutput; - bool m_bTimestamping; - bool m_bLogSkips; - bool m_bLogCheckpoints; - bool m_bShowLoadingWindow; + Preference m_bLogToDisk; + Preference m_bForceLogFlush; + Preference m_bShowLogOutput; + Preference m_bTimestamping; + Preference m_bLogSkips; + Preference m_bLogCheckpoints; + Preference m_bShowLoadingWindow; /* Game-specific prefs: */ - CString m_sDefaultModifiers; + Preference m_sDefaultModifiers; #if defined(XBOX) // Virtual memory preferences - bool m_bEnableVirtualMemory; - int m_iPageFileSize; // page file size in megabytes - int m_iPageSize; // page size in kilobytes - int m_iPageThreshold; // threshold in kilobytes where virtual memory will be used - bool m_bLogVirtualMemory; // (under debug) log the virtual memory allocation, etc. + Preference m_bEnableVirtualMemory; + Preference m_iPageFileSize; // page file size in megabytes + Preference m_iPageSize; // page size in kilobytes + Preference m_iPageThreshold; // threshold in kilobytes where virtual memory will be used + Preference m_bLogVirtualMemory; // (under debug) log the virtual memory allocation, etc. #endif + + // wrappers + CString GetVideoRenderers(); + CString GetSoundDrivers(); + float GetSoundVolume(); + CString GetInputDrivers(); + CString GetMovieDrivers(); + CString GetLightsDriver(); + + void ReadGlobalPrefsFromIni( const IniFile &ini ); void SaveGlobalPrefsToIni( IniFile &ini ) const; diff --git a/stepmania/src/ProfileManager.cpp b/stepmania/src/ProfileManager.cpp index 24ebe83320..c81efca077 100644 --- a/stepmania/src/ProfileManager.cpp +++ b/stepmania/src/ProfileManager.cpp @@ -127,7 +127,7 @@ Profile::LoadResult ProfileManager::LoadProfile( PlayerNumber pn, CString sProfi bool ProfileManager::LoadLocalProfileFromMachine( PlayerNumber pn ) { - CString sProfileID = PREFSMAN->m_sDefaultLocalProfileID[pn]; + CString sProfileID = PREFSMAN->GetDefaultLocalProfileID(pn); if( sProfileID.empty() ) { m_sProfileDir[pn] = ""; diff --git a/stepmania/src/RageInputDevice.h b/stepmania/src/RageInputDevice.h index 0a1067344e..fe6cc57dc9 100644 --- a/stepmania/src/RageInputDevice.h +++ b/stepmania/src/RageInputDevice.h @@ -351,6 +351,10 @@ public: * compare level or ts. */ return device == other.device && button == other.button; }; + bool operator!=( const DeviceInput &other ) const + { + return ! operator==( other ); + } CString toString(); bool fromString( const CString &s ); diff --git a/stepmania/src/RageSound.cpp b/stepmania/src/RageSound.cpp index 3abba8c70e..3f94889fea 100644 --- a/stepmania/src/RageSound.cpp +++ b/stepmania/src/RageSound.cpp @@ -206,7 +206,7 @@ void RageSound::LoadSoundReader( SoundReader *pSound ) const int NeededRate = SOUNDMAN->GetDriverSampleRate( pSound->GetSampleRate() ); if( NeededRate != pSound->GetSampleRate() ) { - RageSoundReader_Resample *Resample = RageSoundReader_Resample::MakeResampler( (RageSoundReader_Resample::ResampleQuality) PREFSMAN->m_iSoundResampleQuality ); + RageSoundReader_Resample *Resample = RageSoundReader_Resample::MakeResampler( PREFSMAN->m_SoundResampleQuality ); Resample->Open( pSound ); Resample->SetSampleRate( NeededRate ); pSound = Resample; diff --git a/stepmania/src/ScoreKeeperMAX2.cpp b/stepmania/src/ScoreKeeperMAX2.cpp index 5b5f31a6e5..7c896de1be 100644 --- a/stepmania/src/ScoreKeeperMAX2.cpp +++ b/stepmania/src/ScoreKeeperMAX2.cpp @@ -86,7 +86,7 @@ void ScoreKeeperMAX2::Load( m_bIsLastSongInCourse = false; memset( m_ComboBonusFactor, 0, sizeof(m_ComboBonusFactor) ); - switch( PREFSMAN->m_iScoringType ) + switch( PREFSMAN->m_ScoringType ) { case PrefsManager::SCORING_MAX2: m_iRoundTo = 1; @@ -160,7 +160,7 @@ void ScoreKeeperMAX2::OnNextSong( int iSongInCourseIndex, const Steps* pSteps, c // long ver and marathon ver songs have higher max possible scores int iLengthMultiplier = SongManager::GetNumStagesForSong( GAMESTATE->m_pCurSong ); - switch( PREFSMAN->m_iScoringType ) + switch( PREFSMAN->m_ScoringType ) { case PrefsManager::SCORING_MAX2: m_iMaxPossiblePoints = iMeter * 10000000 * iLengthMultiplier; @@ -356,7 +356,7 @@ void ScoreKeeperMAX2::HandleTapRowScore( TapNoteScore scoreOfLastTap, int iNumTa */ /* True if a jump is one to combo, false if combo is purely based on tap count. */ bool ComboIsPerRow = true; - switch( PREFSMAN->m_iScoringType ) + switch( PREFSMAN->m_ScoringType ) { case PrefsManager::SCORING_MAX2: ComboIsPerRow = (GAMESTATE->m_PlayMode == PLAY_MODE_ONI); diff --git a/stepmania/src/ScreenDemonstration.cpp b/stepmania/src/ScreenDemonstration.cpp index 95f0711bb7..8c009663ff 100644 --- a/stepmania/src/ScreenDemonstration.cpp +++ b/stepmania/src/ScreenDemonstration.cpp @@ -66,14 +66,14 @@ void ScreenDemonstration::HandleScreenMessage( const ScreenMessage SM ) } else if( SM == SM_LoseFocus ) { - SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on + SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); // turn volume back on } else if( SM == SM_GoToNextScreen ) { if( m_pSoundMusic ) m_pSoundMusic->Stop(); GAMESTATE->Reset(); - SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); // turn volume back on + SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); // turn volume back on SCREENMAN->SetNewScreen( NEXT_SCREEN ); return; } diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index d5964d7297..c69dcc9338 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -1594,7 +1594,7 @@ void ScreenEdit::HandleScreenMessage( const ScreenMessage SM ) } else if( SM == SM_BackFromPrefs ) { - PREFSMAN->m_bEditorShowBGChangesPlay = !!ScreenMiniMenu::s_viLastAnswers[pref_show_bgs_play]; + PREFSMAN->m_bEditorShowBGChangesPlay.Set( !!ScreenMiniMenu::s_viLastAnswers[pref_show_bgs_play] ); PREFSMAN->SaveGlobalPrefsToDisk(); } else if( SM == SM_BackFromCourseModeMenu ) diff --git a/stepmania/src/ScreenEvaluation.cpp b/stepmania/src/ScreenEvaluation.cpp index 74a5e3e5a8..e2bcbf0ca6 100644 --- a/stepmania/src/ScreenEvaluation.cpp +++ b/stepmania/src/ScreenEvaluation.cpp @@ -243,7 +243,7 @@ void ScreenEvaluation::Init() else grade[p] = GRADE_FAILED; - if( PREFSMAN->m_iScoringType == PrefsManager::SCORING_5TH ) + if( PREFSMAN->m_ScoringType == PrefsManager::SCORING_5TH ) { const int ScoreBonuses[] = { 10000000, 10000000, 1000000, 100000, 10000, 1000, 100 }; if( grade[p] < (int) ARRAYSIZE(ScoreBonuses) ) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 6e3bc18a9d..7de750c313 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -189,7 +189,7 @@ void ScreenGameplay::Init() FOREACH_EnabledPlayer(p) { - switch( PREFSMAN->m_iScoringType ) + switch( PREFSMAN->m_ScoringType ) { case PrefsManager::SCORING_MAX2: case PrefsManager::SCORING_5TH: diff --git a/stepmania/src/ScreenGameplayMultiplayer.cpp b/stepmania/src/ScreenGameplayMultiplayer.cpp index 4bf1a769dd..433957ca29 100644 --- a/stepmania/src/ScreenGameplayMultiplayer.cpp +++ b/stepmania/src/ScreenGameplayMultiplayer.cpp @@ -145,7 +145,7 @@ void ScreenGameplayMultiplayer::Init() FOREACH_MultiPlayer( p ) { - switch( PREFSMAN->m_iScoringType ) + switch( PREFSMAN->m_ScoringType ) { case PrefsManager::SCORING_MAX2: case PrefsManager::SCORING_5TH: diff --git a/stepmania/src/ScreenNameEntry.cpp b/stepmania/src/ScreenNameEntry.cpp index 41264cb894..169c9fe69b 100644 --- a/stepmania/src/ScreenNameEntry.cpp +++ b/stepmania/src/ScreenNameEntry.cpp @@ -149,8 +149,8 @@ ScreenNameEntry::ScreenNameEntry( CString sClassName ) : Screen( sClassName ) bool IsOnRanking = ( (GAMESTATE->m_PlayMode == PLAY_MODE_NONSTOP || GAMESTATE->m_PlayMode == PLAY_MODE_ONI) && !(GAMESTATE->m_pCurCourse->IsRanking()) ); - if (PREFSMAN->m_iGetRankingName == PrefsManager::RANKING_OFF || - (PREFSMAN->m_iGetRankingName == PrefsManager::RANKING_LIST && !IsOnRanking)) + if( PREFSMAN->m_GetRankingName == PrefsManager::RANKING_OFF || + (PREFSMAN->m_GetRankingName == PrefsManager::RANKING_LIST && !IsOnRanking) ) { // don't collect score due to ranking setting HandleScreenMessage( SM_GoToNextScreen ); diff --git a/stepmania/src/ScreenOptionsMaster.cpp b/stepmania/src/ScreenOptionsMaster.cpp index 6d6cbd2a73..e330270fc9 100644 --- a/stepmania/src/ScreenOptionsMaster.cpp +++ b/stepmania/src/ScreenOptionsMaster.cpp @@ -265,7 +265,7 @@ void ScreenOptionsMaster::HandleScreenMessage( const ScreenMessage SM ) if( m_iChangeMask & OPT_APPLY_SOUND ) { - SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); + SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); } if( m_iChangeMask & OPT_APPLY_SONG ) diff --git a/stepmania/src/ScreenOptionsMasterPrefs.cpp b/stepmania/src/ScreenOptionsMasterPrefs.cpp index 03d0533bc6..624ac2c057 100644 --- a/stepmania/src/ScreenOptionsMasterPrefs.cpp +++ b/stepmania/src/ScreenOptionsMasterPrefs.cpp @@ -30,7 +30,7 @@ static void SetDefaultModifiers( const PlayerOptions &po, const SongOptions &so if( so.GetString() != "" ) as.push_back( so.GetString() ); - PREFSMAN->m_sDefaultModifiers = join(", ",as); + PREFSMAN->m_sDefaultModifiers.Set( join(", ",as) ); } template @@ -277,7 +277,7 @@ static void WheelSections( int &sel, bool ToSel, const ConfOption *pConfOption ) MoveMap( sel, PREFSMAN->m_MusicWheelUsesSections, ToSel, mapping, ARRAYSIZE(mapping) ); } -MOVE( CourseSort, (int &) PREFSMAN->m_iCourseSortOrder ); +MOVE( CourseSort, (int &) PREFSMAN->m_CourseSortOrder ); MOVE( RandomAtEnd, PREFSMAN->m_bMoveRandomToEnd ); MOVE( Translations, PREFSMAN->m_bShowNativeLanguage ); MOVE( Lyrics, PREFSMAN->m_bShowLyrics ); @@ -369,7 +369,7 @@ static void SongsPerPlayOrEventMode( int &sel, bool ToSel, const ConfOption *pCo } /* Machine options */ -MOVE( ScoringType, (int &) PREFSMAN->m_iScoringType ); +MOVE( ScoringType, (int &) PREFSMAN->m_ScoringType ); static void JudgeDifficulty( int &sel, bool ToSel, const ConfOption *pConfOption ) { @@ -392,7 +392,7 @@ static void ShowSongOptions( int &sel, bool ToSel, const ConfOption *pConfOption static void ShowNameEntry( int &sel, bool ToSel, const ConfOption *pConfOption ) { const PrefsManager::GetRankingName mapping[] = { PrefsManager::RANKING_OFF, PrefsManager::RANKING_ON, PrefsManager::RANKING_LIST }; - MoveMap( sel, PREFSMAN->m_iGetRankingName, ToSel, mapping, ARRAYSIZE(mapping) ); + MoveMap( sel, PREFSMAN->m_GetRankingName, ToSel, mapping, ARRAYSIZE(mapping) ); } static void DefaultFailType( int &sel, bool ToSel, const ConfOption *pConfOption ) @@ -507,7 +507,7 @@ static void AspectRatio( int &sel, bool ToSel, const ConfOption *pConfOption ) } /* Sound options */ -MOVE( ResamplingQuality, PREFSMAN->m_iSoundResampleQuality ); +MOVE( ResamplingQuality, (int&)PREFSMAN->m_SoundResampleQuality ); MOVE( AttractSoundFrequency,PREFSMAN->m_iAttractSoundFrequency ); static void SoundVolume( int &sel, bool ToSel, const ConfOption *pConfOption ) diff --git a/stepmania/src/ScreenProfileOptions.cpp b/stepmania/src/ScreenProfileOptions.cpp index c9336ca5e7..d3c3987a01 100644 --- a/stepmania/src/ScreenProfileOptions.cpp +++ b/stepmania/src/ScreenProfileOptions.cpp @@ -62,15 +62,15 @@ void ScreenProfileOptions::Init() g_ProfileOptionsLines[PO_RENAME_].choices.push_back( "-NONE-" ); PROFILEMAN->GetLocalProfileNames( g_ProfileOptionsLines[PO_RENAME_].choices ); - if( PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_1].empty() ) + if( PREFSMAN->GetMemoryCardOsMountPoint(PLAYER_1).Get().empty() ) g_ProfileOptionsLines[PO_OS_MOUNT_1].choices[0] = "-NOT SET IN INI-"; else - g_ProfileOptionsLines[PO_OS_MOUNT_1].choices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_1]; + g_ProfileOptionsLines[PO_OS_MOUNT_1].choices[0] = PREFSMAN->GetMemoryCardOsMountPoint(PLAYER_1).Get(); - if( PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2].empty() ) + if( PREFSMAN->GetMemoryCardOsMountPoint(PLAYER_2).Get().empty() ) g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = "-NOT SET IN INI-"; else - g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = PREFSMAN->m_sMemoryCardOsMountPoint[PLAYER_2]; + g_ProfileOptionsLines[PO_OS_MOUNT_2].choices[0] = PREFSMAN->GetMemoryCardOsMountPoint(PLAYER_2).Get(); //Enable all lines for all players for ( unsigned int i = 0; i < NUM_PROFILE_OPTIONS_LINES; i++ ) @@ -98,7 +98,7 @@ void ScreenProfileOptions::ImportOptions( int row, const vector &v CStringArray::iterator iter = find( vsProfiles.begin(), vsProfiles.end(), - PREFSMAN->m_sDefaultLocalProfileID[pn] ); + PREFSMAN->GetDefaultLocalProfileID(pn).Get() ); if( iter != vsProfiles.end() ) m_Rows[row]->SetOneSharedSelection( iter - vsProfiles.begin() + 1 ); } @@ -118,9 +118,9 @@ void ScreenProfileOptions::ExportOptions( int row, const vector &v PROFILEMAN->GetLocalProfileIDs( vsProfiles ); if( m_Rows[row]->GetOneSharedSelection() > 0 ) - PREFSMAN->m_sDefaultLocalProfileID[pn] = vsProfiles[m_Rows[row]->GetOneSharedSelection()-1]; + PREFSMAN->GetDefaultLocalProfileID(pn).Set( vsProfiles[m_Rows[row]->GetOneSharedSelection()-1] ); else - PREFSMAN->m_sDefaultLocalProfileID[pn] = ""; + PREFSMAN->GetDefaultLocalProfileID(pn).Set( "" ); } break; } diff --git a/stepmania/src/ScreenRanking.cpp b/stepmania/src/ScreenRanking.cpp index 4c3a6088bc..b94b9c26e3 100644 --- a/stepmania/src/ScreenRanking.cpp +++ b/stepmania/src/ScreenRanking.cpp @@ -209,8 +209,8 @@ void ScreenRanking::Init() this->AddChild( &m_textTime[l] ); // TODO: Think of a better way to handle this - if( PREFSMAN->m_sCoursesToShowRanking == "" ) - PREFSMAN->m_sCoursesToShowRanking = COURSES_TO_SHOW2; + if( PREFSMAN->m_sCoursesToShowRanking.Get() == "" ) + PREFSMAN->m_sCoursesToShowRanking.Set( COURSES_TO_SHOW2 ); } } diff --git a/stepmania/src/ScreenSMOnlineLogin.cpp b/stepmania/src/ScreenSMOnlineLogin.cpp index b81c5ff7a1..4b25f125cd 100644 --- a/stepmania/src/ScreenSMOnlineLogin.cpp +++ b/stepmania/src/ScreenSMOnlineLogin.cpp @@ -70,7 +70,7 @@ void ScreenSMOnlineLogin::ImportOptions( int row, const vector &vp FOREACH_PlayerNumber( pn ) { - iter = find(vsProfiles.begin(), vsProfiles.end(), PREFSMAN->m_sDefaultLocalProfileID[pn] ); + iter = find(vsProfiles.begin(), vsProfiles.end(), PREFSMAN->GetDefaultLocalProfileID(pn).Get() ); if( iter != vsProfiles.end() ) m_Rows[0]->SetOneSelection((PlayerNumber) pn, iter - vsProfiles.begin()); } @@ -89,9 +89,7 @@ void ScreenSMOnlineLogin::ExportOptions( int row, const vector &vp PROFILEMAN->GetLocalProfileIDs( vsProfiles ); FOREACH_EnabledPlayer( pn ) - { - PREFSMAN->m_sDefaultLocalProfileID[pn] = vsProfiles[m_Rows[0]->GetOneSelection((PlayerNumber) pn)]; - } + PREFSMAN->GetDefaultLocalProfileID(pn).Set( vsProfiles[m_Rows[0]->GetOneSelection(pn)] ); } break; } diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 8f82bc5b03..a8fc5db0e0 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -300,9 +300,9 @@ void ResetGame( bool ReturnToFirstScreen ) INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions); CString sInputDevices = join( ",", vDescriptions ); - if( PREFSMAN->m_sLastSeenInputDevices != sInputDevices ) + if( PREFSMAN->m_sLastSeenInputDevices.Get() != sInputDevices ) { - LOG->Info( "Input devices changed from '%s' to '%s'.", PREFSMAN->m_sLastSeenInputDevices.c_str(), sInputDevices.c_str() ); + LOG->Info( "Input devices changed from '%s' to '%s'.", PREFSMAN->m_sLastSeenInputDevices.Get().c_str(), sInputDevices.c_str() ); if( PREFSMAN->m_bAutoMapOnJoyChange ) { @@ -311,7 +311,7 @@ void ResetGame( bool ReturnToFirstScreen ) INPUTMAPPER->SaveMappingsToDisk(); } - PREFSMAN->m_sLastSeenInputDevices = sInputDevices; + PREFSMAN->m_sLastSeenInputDevices.Set( sInputDevices ); } @@ -332,12 +332,12 @@ static void GameLoop(); static bool ChangeAppPri() { - if( PREFSMAN->m_iBoostAppPriority == 0 ) + if( PREFSMAN->m_BoostAppPriority.Get() == PrefsManager::BOOST_NO ) return false; // if using NTPAD don't boost or else input is laggy #if defined(_WINDOWS) - if( PREFSMAN->m_iBoostAppPriority == -1 ) + if( PREFSMAN->m_BoostAppPriority == PrefsManager::BOOST_AUTO ) { vector vDevices; vector vDescriptions; @@ -353,7 +353,7 @@ static bool ChangeAppPri() /* If -1 and this is a debug build, don't. It makes the debugger sluggish. */ #ifdef DEBUG - if( PREFSMAN->m_iBoostAppPriority == -1 ) + if( PREFSMAN->m_BoostAppPriority == PrefsManager::BOOST_AUTO ) return false; #endif @@ -373,7 +373,7 @@ static void CheckSettings() return; LOG->Trace( "Memory changed from %i to %i; settings changed", PREFSMAN->m_iLastSeenMemory, Memory ); - PREFSMAN->m_iLastSeenMemory = Memory; + PREFSMAN->m_iLastSeenMemory.Set( Memory ); /* Let's consider 128-meg systems low-memory, and 256-meg systems high-memory. * Cut off at 192. This is somewhat conservative; many 128-meg systems can @@ -617,7 +617,7 @@ static void CheckVideoDefaultSettings() // Video card changed since last run CString sVideoDriver = GetVideoDriverName(); - LOG->Trace( "Last seen video driver: " + PREFSMAN->m_sLastSeenVideoDriver ); + LOG->Trace( "Last seen video driver: " + PREFSMAN->m_sLastSeenVideoDriver.Get() ); const VideoCardDefaults* pDefaults = NULL; @@ -639,39 +639,39 @@ static void CheckVideoDefaultSettings() CString sVideoRenderers = pDefaults->szVideoRenderers; bool SetDefaultVideoParams=false; - if( PREFSMAN->m_sVideoRenderers == "" ) + if( PREFSMAN->m_sVideoRenderers.Get() == "" ) { SetDefaultVideoParams = true; LOG->Trace( "Applying defaults for %s.", sVideoDriver.c_str() ); } - else if( PREFSMAN->m_sLastSeenVideoDriver != sVideoDriver ) + else if( PREFSMAN->m_sLastSeenVideoDriver.Get() != sVideoDriver ) { SetDefaultVideoParams = true; - LOG->Trace( "Video card has changed from %s to %s. Applying new defaults.", PREFSMAN->m_sLastSeenVideoDriver.c_str(), sVideoDriver.c_str() ); + LOG->Trace( "Video card has changed from %s to %s. Applying new defaults.", PREFSMAN->m_sLastSeenVideoDriver.Get().c_str(), sVideoDriver.c_str() ); } if( SetDefaultVideoParams ) { - PREFSMAN->m_sVideoRenderers = pDefaults->szVideoRenderers; + PREFSMAN->m_sVideoRenderers.Set( pDefaults->szVideoRenderers ); PREFSMAN->m_iDisplayWidth.Set( pDefaults->iWidth ); PREFSMAN->m_iDisplayHeight.Set( pDefaults->iHeight ); PREFSMAN->m_iDisplayColorDepth.Set( pDefaults->iDisplayColor ); PREFSMAN->m_iTextureColorDepth.Set( pDefaults->iTextureColor ); PREFSMAN->m_iMovieColorDepth.Set( pDefaults->iMovieColor ); PREFSMAN->m_iMaxTextureResolution.Set( pDefaults->iTextureSize ); - PREFSMAN->m_bSmoothLines = pDefaults->bSmoothLines; + PREFSMAN->m_bSmoothLines.Set( pDefaults->bSmoothLines ); // Update last seen video card - PREFSMAN->m_sLastSeenVideoDriver = GetVideoDriverName(); + PREFSMAN->m_sLastSeenVideoDriver.Set( GetVideoDriverName() ); } - else if( PREFSMAN->m_sVideoRenderers.CompareNoCase(sVideoRenderers) ) + else if( PREFSMAN->m_sVideoRenderers.Get().CompareNoCase(sVideoRenderers) ) { LOG->Warn("Video renderer list has been changed from '%s' to '%s'", - sVideoRenderers.c_str(), PREFSMAN->m_sVideoRenderers.c_str() ); + sVideoRenderers.c_str(), PREFSMAN->m_sVideoRenderers.Get().c_str() ); return; } - LOG->Info( "Video renderers: '%s'", PREFSMAN->m_sVideoRenderers.c_str() ); + LOG->Info( "Video renderers: '%s'", PREFSMAN->m_sVideoRenderers.Get().c_str() ); } RageDisplay *CreateDisplay() @@ -801,12 +801,16 @@ void ReadGamePrefsFromDisk( bool bSwitchToLastPlayedGame ) RageException::Throw( "Default note skin for \"%s\" missing", GAMESTATE->m_pCurGame->m_szName ); CString sGameName = GAMESTATE->GetCurrentGame()->m_szName; - CString sAnnouncer = sGameName, sTheme = sGameName, sNoteSkin = sGameName; + CString sAnnouncer = sGameName; + CString sTheme = sGameName; + CString sNoteSkin = sGameName; + CString sDefaultModifiers; // if these calls fail, the three strings will keep the initial values set above. ini.GetValue( sGameName, "Announcer", sAnnouncer ); ini.GetValue( sGameName, "Theme", sTheme ); - ini.GetValue( sGameName, "DefaultModifiers", PREFSMAN->m_sDefaultModifiers ); + ini.GetValue( sGameName, "DefaultModifiers", sDefaultModifiers ); + PREFSMAN->m_sDefaultModifiers.Set( sDefaultModifiers ); // it's OK to call these functions with names that don't exist. ANNOUNCER->SwitchAnnouncer( sAnnouncer ); @@ -1028,14 +1032,14 @@ int main(int argc, char* argv[]) WriteLogHeader(); /* Set up alternative filesystem trees. */ - if( PREFSMAN->m_sAdditionalFolders != "" ) + if( PREFSMAN->m_sAdditionalFolders.Get() != "" ) { CStringArray dirs; split( PREFSMAN->m_sAdditionalFolders, ",", dirs, true ); for( unsigned i=0; i < dirs.size(); i++) FILEMAN->Mount( "dir", dirs[i], "" ); } - if( PREFSMAN->m_sAdditionalSongFolders != "" ) + if( PREFSMAN->m_sAdditionalSongFolders.Get() != "" ) { CStringArray dirs; split( PREFSMAN->m_sAdditionalSongFolders, ",", dirs, true ); @@ -1106,11 +1110,11 @@ int main(int argc, char* argv[]) if( PREFSMAN->m_iSoundWriteAhead ) LOG->Info( "Sound writeahead has been overridden to %i", PREFSMAN->m_iSoundWriteAhead ); SOUNDMAN = new RageSoundManager; - SOUNDMAN->Init( PREFSMAN->m_sSoundDrivers ); - SOUNDMAN->SetPrefs( PREFSMAN->m_fSoundVolume ); + SOUNDMAN->Init( PREFSMAN->GetSoundDrivers() ); + SOUNDMAN->SetPrefs( PREFSMAN->GetSoundVolume() ); SOUND = new GameSoundManager; BOOKKEEPER = new Bookkeeper; - LIGHTSMAN = new LightsManager(PREFSMAN->m_sLightsDriver); + LIGHTSMAN = new LightsManager( PREFSMAN->GetLightsDriver() ); INPUTFILTER = new InputFilter; INPUTMAPPER = new InputMapper; INPUTQUEUE = new InputQueue; @@ -1144,7 +1148,7 @@ int main(int argc, char* argv[]) /* This initializes objects that change the SDL event mask, and has other * dependencies on the SDL video subsystem, so it must be initialized after DISPLAY. */ - INPUTMAN = new RageInput( PREFSMAN->m_sInputDrivers ); + INPUTMAN = new RageInput( PREFSMAN->GetInputDrivers() ); // These things depend on the TextureManager, so do them after! FONT = new FontManager; @@ -1407,7 +1411,7 @@ bool HandleGlobalInputs( DeviceInput DeviceI, InputEventType type, GameInput Gam { static bool bMute = false; bMute = !bMute; - SOUNDMAN->SetPrefs( bMute ? 0 : PREFSMAN->m_fSoundVolume ); + SOUNDMAN->SetPrefs( bMute ? 0 : PREFSMAN->GetSoundVolume() ); SCREENMAN->SystemMessage( bMute ? "Mute on" : "Mute off" ); return true; }