/* PrefsManager - Holds user-chosen preferences that are saved between sessions. */ #ifndef PREFSMANAGER_H #define PREFSMANAGER_H #include "PlayerNumber.h" #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; class PrefsManager { public: PrefsManager(); ~PrefsManager(); IPreference *GetPreferenceByName( const CString &sName ); void Init(); // GameOptions (ARE saved between sessions) Preference m_bWindowed; Preference m_iDisplayWidth; Preference m_iDisplayHeight; Preference m_iDisplayColorDepth; Preference m_iTextureColorDepth; Preference m_iMovieColorDepth; Preference m_iMaxTextureResolution; Preference m_iRefreshRate; Preference m_fDisplayAspectRatio; Preference m_bShowStats; Preference m_bShowBanners; enum BackgroundMode { BGMODE_OFF, BGMODE_ANIMATIONS, BGMODE_RANDOMMOVIES, NUM_BackgroundMode }; Preference m_BackgroundMode; Preference m_iNumBackgrounds; Preference m_fBGBrightness; Preference m_bHiddenSongs; Preference m_bVsync; Preference m_bInterlaced; Preference m_bPAL; Preference m_bDelayedTextureDelete; Preference m_bTexturePreload; Preference m_bDelayedScreenLoad; Preference m_bDelayedModelDelete; enum BannerCache { BNCACHE_OFF, BNCACHE_LOW_RES_PRELOAD, // preload low-res on start BNCACHE_LOW_RES_LOAD_ON_DEMAND, // preload low-res on screen load BNCACHE_FULL }; Preference m_BannerCache; Preference m_bPalettedBannerCache; Preference m_bFastLoad; Preference m_bOnlyDedicatedMenuButtons; Preference m_bMenuTimer; Preference m_bShowDanger; Preference m_fJudgeWindowScale; Preference m_fJudgeWindowAdd; // this is useful for compensating for changes in sampling rate between devices Preference m_fJudgeWindowSecondsMarvelous; Preference m_fJudgeWindowSecondsPerfect; Preference m_fJudgeWindowSecondsGreat; Preference m_fJudgeWindowSecondsGood; Preference m_fJudgeWindowSecondsBoo; Preference m_fJudgeWindowSecondsOK; Preference m_fJudgeWindowSecondsRoll; Preference m_fJudgeWindowSecondsMine; Preference m_fJudgeWindowSecondsAttack; Preference m_fLifeDifficultyScale; Preference m_fLifeDeltaPercentChangeMarvelous; Preference m_fLifeDeltaPercentChangePerfect; Preference m_fLifeDeltaPercentChangeGreat; Preference m_fLifeDeltaPercentChangeGood; Preference m_fLifeDeltaPercentChangeBoo; Preference m_fLifeDeltaPercentChangeMiss; Preference m_fLifeDeltaPercentChangeHitMine; Preference m_fLifeDeltaPercentChangeOK; Preference m_fLifeDeltaPercentChangeNG; // tug meter used in rave Preference m_fTugMeterPercentChangeMarvelous; Preference m_fTugMeterPercentChangePerfect; Preference m_fTugMeterPercentChangeGreat; Preference m_fTugMeterPercentChangeGood; Preference m_fTugMeterPercentChangeBoo; Preference m_fTugMeterPercentChangeMiss; Preference m_fTugMeterPercentChangeHitMine; Preference m_fTugMeterPercentChangeOK; Preference m_fTugMeterPercentChangeNG; // Whoever added these: Please add a comment saying what they do. -Chris Preference m_iRegenComboAfterFail; Preference m_iRegenComboAfterMiss; Preference m_iMaxRegenComboAfterFail; Preference m_iMaxRegenComboAfterMiss; Preference m_bTwoPlayerRecovery; Preference m_bMercifulDrain; // negative life deltas are scaled by the players life percentage Preference m_bMinimum1FullSongInCourses; // FEoS for 1st song, FailImmediate thereafter Preference m_bFailOffInBeginner; Preference m_bFailOffForFirstStageEasy; Preference m_bMercifulBeginner; // don't subtract from percent score or grade DP, larger boo window // percent score (the number that is shown on the screen and saved to memory card) Preference m_iPercentScoreWeightMarvelous; Preference m_iPercentScoreWeightPerfect; Preference m_iPercentScoreWeightGreat; Preference m_iPercentScoreWeightGood; Preference m_iPercentScoreWeightBoo; Preference m_iPercentScoreWeightMiss; Preference m_iPercentScoreWeightHitMine; Preference m_iPercentScoreWeightOK; Preference m_iPercentScoreWeightNG; // grades are calculated based on a percentage, but might have different weights than the percent score Preference m_iGradeWeightMarvelous; Preference m_iGradeWeightPerfect; Preference m_iGradeWeightGreat; Preference m_iGradeWeightGood; Preference m_iGradeWeightBoo; Preference m_iGradeWeightMiss; Preference m_iGradeWeightHitMine; Preference m_iGradeWeightOK; Preference m_iGradeWeightNG; // super meter used in rave Preference m_fSuperMeterPercentChangeMarvelous; Preference m_fSuperMeterPercentChangePerfect; Preference m_fSuperMeterPercentChangeGreat; Preference m_fSuperMeterPercentChangeGood; Preference m_fSuperMeterPercentChangeBoo; Preference m_fSuperMeterPercentChangeMiss; Preference m_fSuperMeterPercentChangeHitMine; Preference m_fSuperMeterPercentChangeOK; Preference m_fSuperMeterPercentChangeNG; Preference m_bMercifulSuperMeter; // negative super deltas are scaled by the players life percentage // time meter used in survival Preference m_fTimeMeterSecondsChangeMarvelous; Preference m_fTimeMeterSecondsChangePerfect; Preference m_fTimeMeterSecondsChangeGreat; Preference m_fTimeMeterSecondsChangeGood; Preference m_fTimeMeterSecondsChangeBoo; Preference m_fTimeMeterSecondsChangeMiss; Preference m_fTimeMeterSecondsChangeHitMine; Preference m_fTimeMeterSecondsChangeOK; Preference m_fTimeMeterSecondsChangeNG; Preference m_AutoPlay; Preference m_bDelayedBack; Preference m_bShowInstructions; Preference m_bShowSelectGroup; Preference m_bShowCaution; Preference m_bShowNativeLanguage; Preference m_bArcadeOptionsNavigation; enum MusicWheelUsesSections { NEVER, ALWAYS, ABC_ONLY }; Preference m_MusicWheelUsesSections; Preference m_iMusicWheelSwitchSpeed; Preference m_bEasterEggs; enum MarvelousTiming { MARVELOUS_NEVER, MARVELOUS_COURSES_ONLY, MARVELOUS_EVERYWHERE }; Preference m_MarvelousTiming; Preference m_bEventMode; Preference m_iCoinsPerCredit; Preference m_iSongsPerPlay; // These options have weird interactions depending on m_bEventMode, // so wrap them in GameState. Preference m_CoinMode; Preference m_Premium; Preference m_bDelayedCreditsReconcile; Preference m_bPickExtraStage; // DDR Extreme-style extra stage support. Preference m_bComboContinuesBetweenSongs; Preference m_fLongVerSongSeconds; Preference m_fMarathonVerSongSeconds; enum Maybe { ASK = -1, NO = 0, YES = 1 }; Preference m_ShowSongOptions; Preference m_bSoloSingle; Preference m_bDancePointsForOni; //DDR-Extreme style dance points instead of max2 percent Preference m_bPercentageScoring; Preference m_fMinPercentageForMachineSongHighScore; Preference m_fMinPercentageForMachineCourseHighScore; Preference m_bDisqualification; Preference m_bShowLyrics; Preference m_bAutogenSteps; Preference m_bAutogenGroupCourses; Preference m_bBreakComboToGetItem; Preference m_bLockCourseDifficulties; enum CharacterOption { CO_OFF = 0, CO_RANDOM = 1, CO_SELECT = 2}; Preference m_ShowDancingCharacters; Preference m_bUseUnlockSystem; Preference m_bAutoMapOnJoyChange; Preference m_fGlobalOffsetSeconds; Preference m_iProgressiveLifebar; Preference m_iProgressiveStageLifebar; Preference m_iProgressiveNonstopLifebar; Preference m_bShowBeginnerHelper; Preference m_bEndlessBreakEnabled; Preference m_iEndlessNumStagesUntilBreak; Preference m_iEndlessBreakLength; Preference m_bDisableScreenSaver; 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. 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; 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; Preference m_fCenterImageAddHeight; enum AttractSoundFrequency { ASF_NEVER, ASF_EVERY_TIME, ASF_EVERY_2_TIMES, ASF_EVERY_3_TIMES, ASF_EVERY_4_TIMES, ASF_EVERY_5_TIMES }; Preference m_AttractSoundFrequency; Preference m_bAllowExtraStage; Preference m_bHideDefaultNoteSkin; Preference m_iMaxHighScoresPerListForMachine; Preference m_iMaxHighScoresPerListForPlayer; Preference m_iMaxRecentScoresForMachine; Preference m_iMaxRecentScoresForPlayer; Preference m_bAllowMultipleHighScoreWithSameName; Preference m_bCelShadeModels; Preference m_bPreferredSortUsesGroups; /* experimental: force a specific update rate. This prevents big * animation jumps on frame skips. */ Preference m_fConstantUpdateDeltaSeconds; // 0 to disable // Number of seconds it takes for a button on the controller to release // after pressed. Preference m_fPadStickSeconds; // Useful for non 4:3 displays and resolutions < 640x480 where texels don't // map directly to pixels. 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. Preference m_bSignProfileData; /* Editor prefs: */ Preference m_bEditorShowBGChangesPlay; // course ranking 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 }; Preference m_ScoringType; enum BoostAppPriority { BOOST_NO, BOOST_YES, BOOST_AUTO }; /* auto = do whatever is appropriate for the arch. */ Preference m_BoostAppPriority; Preference m_sAdditionalSongFolders; Preference m_sAdditionalFolders; Preference m_sLastSeenVideoDriver; Preference m_sLastSeenInputDevices; #if defined(WIN32) Preference m_iLastSeenMemory; #endif 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_sLightsDriver; // "" == default public: Preference m_sMovieDrivers; // "" == default Preference m_sLightsStepsDifficulty; Preference m_bBlinkGameplayButtonLightsOnNote; Preference m_bAllowUnacceleratedRenderer; Preference m_bThreadedInput; Preference m_bThreadedMovieDecode; Preference m_bScreenTestMode; Preference m_bDebugLights; Preference m_bMonkeyInput; Preference m_sMachineName; Preference m_sIgnoredMessageWindows; Preference m_sCoursesToShowRanking; /* Debug: */ Preference m_bLogToDisk; Preference m_bForceLogFlush; Preference m_bShowLogOutput; Preference m_bTimestamping; Preference m_bLogSkips; Preference m_bLogCheckpoints; Preference m_bShowLoadingWindow; /* Game-specific prefs: */ Preference m_sDefaultModifiers; #if defined(XBOX) // Virtual memory preferences 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; void ReadGlobalPrefsFromDisk(); void SaveGlobalPrefsToDisk() const; void ResetToFactoryDefaults(); // // For self-registering prefs // static void Subscribe( IPreference *p ); static void Unsubscribe( IPreference *p ); // Lua void PushSelf( lua_State *L ); protected: void ReadPrefsFromFile( CString sIni ); }; /* This is global, because it can be accessed by crash handlers and error handlers * that are run after PREFSMAN shuts down (and probably don't want to deref tht * pointer anyway). */ extern bool g_bAutoRestart; extern PrefsManager* PREFSMAN; // global and accessable from anywhere in our program #endif /* * (c) 2001-2004 Chris Danford, Chris Gomez * All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the * "Software"), to deal in the Software without restriction, including * without limitation the rights to use, copy, modify, merge, publish, * distribute, and/or sell copies of the Software, and to permit persons to * whom the Software is furnished to do so, provided that the above * copyright notice(s) and this permission notice appear in all copies of * the Software and that both the above copyright notice(s) and this * permission notice appear in supporting documentation. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR HOLDERS * INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR ANY SPECIAL INDIRECT * OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR * OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */