Files
itgmania212121/stepmania/src/PrefsManager.h
T

347 lines
13 KiB
C++
Raw Normal View History

2004-06-08 01:24:17 +00:00
/* PrefsManager - Holds user-chosen preferences that are saved between sessions. */
#ifndef PREFSMANAGER_H
#define PREFSMANAGER_H
2002-02-28 19:40:40 +00:00
#include "PlayerNumber.h"
#include "GameConstantsAndTypes.h"
2004-01-20 03:32:48 +00:00
#include "Grade.h" // for NUM_GRADE_TIERS
2004-12-04 08:21:54 +00:00
#include "Preference.h"
2004-09-13 03:58:39 +00:00
class IniFile;
2005-05-06 10:48:32 +00:00
const int MAX_SONGS_PER_PLAY = 7;
2005-11-26 07:22:33 +00:00
#define ASPECT_AUTO -1
2005-05-06 10:48:32 +00:00
2002-02-28 19:40:40 +00:00
class PrefsManager
{
public:
PrefsManager();
~PrefsManager();
2004-12-07 10:04:19 +00:00
IPreference *GetPreferenceByName( const CString &sName );
2002-02-28 19:40:40 +00:00
void Init();
void SetCurrentGame( const CString &sGame );
CString GetCurrentGame() { return m_sCurrentGame; }
protected:
2005-10-27 04:54:45 +00:00
Preference<CString> m_sCurrentGame;
public:
// Game-specific prefs. Copy these off and save them every time the game changes
Preference<CString> m_sAnnouncer;
Preference<CString> m_sTheme;
Preference<CString> m_sDefaultModifiers;
protected:
void StoreGamePrefs();
void RestoreGamePrefs();
struct GamePrefs
{
CString m_sAnnouncer;
CString m_sTheme;
CString m_sDefaultModifiers;
};
map<CString, GamePrefs> m_mapGameNameToGamePrefs;
public:
2004-12-04 08:21:54 +00:00
Preference<bool> m_bWindowed;
Preference<int> m_iDisplayWidth;
Preference<int> m_iDisplayHeight;
Preference<int> m_iDisplayColorDepth;
Preference<int> m_iTextureColorDepth;
Preference<int> m_iMovieColorDepth;
Preference<int> m_iMaxTextureResolution;
Preference<int> m_iRefreshRate;
2005-11-26 07:22:33 +00:00
Preference<float> m_fDisplayAspectRatio; // -1 == auto
2005-11-07 03:59:05 +00:00
Preference<bool> m_bAllowMultitexture;
2004-12-04 08:21:54 +00:00
Preference<bool> m_bShowStats;
Preference<bool> m_bShowBanners;
2002-07-11 19:02:26 +00:00
Preference<bool> m_bSongBackgrounds;
2005-10-29 20:04:57 +00:00
enum RandomBackgroundMode { BGMODE_OFF, BGMODE_ANIMATIONS, BGMODE_RANDOMMOVIES, NUM_RandomBackgroundMode };
Preference<RandomBackgroundMode,int> m_RandomBackgroundMode;
2004-12-04 10:35:50 +00:00
Preference<int> m_iNumBackgrounds;
Preference<float> m_fBGBrightness;
Preference<bool> m_bHiddenSongs;
Preference<bool> m_bVsync;
Preference<bool> m_bInterlaced;
Preference<bool> m_bPAL;
Preference<bool> m_bDelayedTextureDelete;
Preference<bool> m_bDelayedScreenLoad;
Preference<bool> m_bDelayedModelDelete;
2005-04-28 08:27:40 +00:00
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<BannerCache,int> m_BannerCache;
2004-12-04 10:35:50 +00:00
Preference<bool> m_bPalettedBannerCache;
Preference<bool> m_bFastLoad;
2004-01-11 23:33:56 +00:00
2004-12-04 10:35:50 +00:00
Preference<bool> m_bOnlyDedicatedMenuButtons;
Preference<bool> m_bMenuTimer;
Preference<bool> m_bShowDanger;
2004-01-20 07:09:44 +00:00
Preference<float> m_fTimingWindowScale;
Preference<float> m_fTimingWindowAdd; // this is useful for compensating for changes in sampling rate between devices
Preference1D<float> m_fTimingWindowSeconds;
2004-12-04 10:35:50 +00:00
Preference<float> m_fLifeDifficultyScale;
Preference1D<float> m_fLifePercentChange;
2004-01-11 23:33:56 +00:00
// tug meter used in rave
Preference1D<float> m_fTugMeterPercentChange;
2004-01-20 07:09:44 +00:00
// Whoever added these: Please add a comment saying what they do. -Chris
2005-04-27 07:50:38 +00:00
Preference<int> m_iRegenComboAfterFail;
Preference<int> m_iRegenComboAfterMiss;
Preference<int> m_iMaxRegenComboAfterFail;
Preference<int> m_iMaxRegenComboAfterMiss;
Preference<bool> m_bTwoPlayerRecovery;
Preference<bool> m_bMercifulDrain; // negative life deltas are scaled by the players life percentage
2005-06-16 22:09:03 +00:00
Preference<bool> m_bMinimum1FullSongInCourses; // FEoS for 1st song, FailImmediate thereafter
2005-04-27 07:50:38 +00:00
Preference<bool> m_bFailOffInBeginner;
Preference<bool> m_bFailOffForFirstStageEasy;
Preference<bool> m_bMercifulBeginner; // don't subtract from percent score or grade DP, larger W5 window
2004-01-11 23:33:56 +00:00
2004-01-20 07:09:44 +00:00
// percent score (the number that is shown on the screen and saved to memory card)
Preference1D<int> m_iPercentScoreWeight;
2004-01-11 23:33:56 +00:00
2004-01-20 07:09:44 +00:00
// grades are calculated based on a percentage, but might have different weights than the percent score
Preference1D<int> m_iGradeWeight;
2004-01-20 07:09:44 +00:00
2005-04-21 04:27:13 +00:00
// super meter used in rave
Preference1D<float> m_fSuperMeterPercentChange;
2005-04-27 07:50:38 +00:00
Preference<float> m_bMercifulSuperMeter; // negative super deltas are scaled by the players life percentage
2004-01-11 23:33:56 +00:00
2005-04-21 04:27:13 +00:00
// time meter used in survival
Preference1D<float> m_fTimeMeterSecondsChange;
2005-04-21 04:27:13 +00:00
Preference<PlayerController,int> m_AutoPlay;
2005-04-27 07:50:38 +00:00
Preference<bool> m_bDelayedBack;
Preference<bool> m_bShowInstructions;
Preference<bool> m_bShowSelectGroup;
Preference<bool> m_bShowCaution;
2005-04-27 07:50:38 +00:00
Preference<bool> m_bShowNativeLanguage;
Preference<bool> m_bArcadeOptionsNavigation;
enum MusicWheelUsesSections { NEVER, ALWAYS, ABC_ONLY };
Preference<MusicWheelUsesSections,int> m_MusicWheelUsesSections;
2005-04-27 07:50:38 +00:00
Preference<int> m_iMusicWheelSwitchSpeed;
Preference<bool> m_bEasterEggs;
enum AllowW1 { ALLOW_W1_NEVER, ALLOW_W1_COURSES_ONLY, ALLOW_W1_EVERYWHERE };
Preference<AllowW1,int> m_AllowW1;
Preference<bool> m_bEventMode;
2005-04-27 07:50:38 +00:00
Preference<int> m_iCoinsPerCredit;
2005-04-28 08:27:40 +00:00
Preference<int> m_iSongsPerPlay;
// These options have weird interactions depending on m_bEventMode,
2005-05-08 05:18:01 +00:00
// so wrap them in GameState.
Preference<CoinMode,int> m_CoinMode;
Preference<Premium,int> m_Premium;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bDelayedCreditsReconcile;
Preference<bool> m_bPickExtraStage;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bComboContinuesBetweenSongs;
Preference<float> m_fLongVerSongSeconds;
Preference<float> m_fMarathonVerSongSeconds;
2003-04-21 22:36:45 +00:00
enum Maybe { ASK = -1, NO = 0, YES = 1 };
Preference<Maybe,int> m_ShowSongOptions;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bSoloSingle;
Preference<bool> m_bDancePointsForOni;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bPercentageScoring;
Preference<float> m_fMinPercentageForMachineSongHighScore;
Preference<float> m_fMinPercentageForMachineCourseHighScore;
Preference<bool> m_bDisqualification;
Preference<bool> m_bShowLyrics;
Preference<bool> m_bAutogenSteps;
Preference<bool> m_bAutogenGroupCourses;
Preference<bool> m_bBreakComboToGetItem;
Preference<bool> m_bLockCourseDifficulties;
enum ShowDancingCharacters { SDC_Off = 0, SDC_Random = 1, SDC_Select = 2};
Preference<ShowDancingCharacters,int> m_ShowDancingCharacters;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bUseUnlockSystem;
2005-02-22 04:00:14 +00:00
Preference<float> m_fGlobalOffsetSeconds;
2005-04-28 08:27:40 +00:00
Preference<int> m_iProgressiveLifebar;
Preference<int> m_iProgressiveStageLifebar;
Preference<int> m_iProgressiveNonstopLifebar;
Preference<bool> m_bShowBeginnerHelper;
Preference<bool> m_bDisableScreenSaver;
Preference<CString> m_sLanguage;
Preference<CString> m_sMemoryCardProfileSubdir; // the directory on a memory card to look in for a profile
Preference<int> m_iProductID; // Saved in HighScore to track what software version a score came from.
Preference<bool> m_bMemoryCards;
Preference<int> m_iCenterImageTranslateX;
Preference<int> m_iCenterImageTranslateY;
Preference<int> m_fCenterImageAddWidth;
Preference<int> m_fCenterImageAddHeight;
2005-08-18 02:28:54 +00:00
Preference<float> m_fBrightnessAdd;
2005-06-11 10:53:16 +00:00
enum AttractSoundFrequency { ASF_NEVER, ASF_EVERY_TIME, ASF_EVERY_2_TIMES, ASF_EVERY_3_TIMES, ASF_EVERY_4_TIMES, ASF_EVERY_5_TIMES };
Preference<AttractSoundFrequency,int> m_AttractSoundFrequency;
2005-04-28 08:27:40 +00:00
Preference<bool> m_bAllowExtraStage;
Preference<bool> m_bHideDefaultNoteSkin;
Preference<int> m_iMaxHighScoresPerListForMachine;
Preference<int> m_iMaxHighScoresPerListForPlayer;
Preference<int> m_iMaxRecentScoresForMachine;
Preference<int> m_iMaxRecentScoresForPlayer;
Preference<bool> m_bAllowMultipleHighScoreWithSameName;
Preference<bool> m_bCelShadeModels;
2005-05-09 17:33:22 +00:00
Preference<bool> m_bPreferredSortUsesGroups;
2004-07-28 16:04:19 +00:00
/* experimental: force a specific update rate. This prevents big
* animation jumps on frame skips. */
2005-05-16 09:36:32 +00:00
Preference<float> m_fConstantUpdateDeltaSeconds; // 0 to disable
2004-07-28 16:04:19 +00:00
// Number of seconds it takes for a button on the controller to release
// after pressed.
2005-05-16 09:36:32 +00:00
Preference<float> m_fPadStickSeconds;
// Useful for non 4:3 displays and resolutions < 640x480 where texels don't
// map directly to pixels.
2005-05-16 09:36:32 +00:00
Preference<bool> m_bForceMipMaps;
Preference<bool> m_bTrilinearFiltering; // has no effect without mipmaps on
Preference<bool> m_bAnisotropicFiltering; // has no effect without mipmaps on. Not mutually exclusive with trilinear.
2004-04-24 07:54:18 +00:00
// 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.
2005-05-16 09:36:32 +00:00
Preference<bool> m_bSignProfileData;
/* Editor prefs: */
2005-05-16 09:36:32 +00:00
Preference<bool> m_bEditorShowBGChangesPlay;
// course ranking
2005-05-16 09:36:32 +00:00
enum CourseSortOrders { COURSE_SORT_SONGS, COURSE_SORT_METER, COURSE_SORT_METER_SUM, COURSE_SORT_RANK };
Preference<CourseSortOrders,int> m_CourseSortOrder;
2005-05-16 09:36:32 +00:00
Preference<bool> m_bMoveRandomToEnd;
Preference<bool> m_bSubSortByNumSteps;
enum GetRankingName { RANKING_OFF, RANKING_ON, RANKING_LIST };
Preference<GetRankingName,int> m_GetRankingName;
enum ScoringType { SCORING_NEW, SCORING_OLD };
Preference<ScoringType,int> m_ScoringType;
2005-05-16 09:36:32 +00:00
enum BoostAppPriority { BOOST_NO, BOOST_YES, BOOST_AUTO }; /* auto = do whatever is appropriate for the arch. */
Preference<BoostAppPriority,int> m_BoostAppPriority;
2003-01-18 04:26:25 +00:00
2005-05-16 09:36:32 +00:00
Preference<CString> m_sAdditionalSongFolders;
Preference<CString> m_sAdditionalFolders;
2002-05-27 08:23:27 +00:00
2005-05-16 09:36:32 +00:00
Preference<CString> m_sLastSeenVideoDriver;
#if defined(WIN32)
2005-05-16 09:36:32 +00:00
Preference<int> m_iLastSeenMemory;
#endif
2005-05-16 09:36:32 +00:00
Preference<CString> m_sVideoRenderers; // StepMania.cpp sets these on first run based on the card
Preference<bool> m_bSmoothLines;
private:
Preference<CString> m_sSoundDrivers; // "" == default
public:
Preference<float> m_fSoundVolume;
2005-05-16 09:36:32 +00:00
Preference<int> m_iSoundWriteAhead;
Preference<CString> m_iSoundDevice;
2005-10-23 22:11:48 +00:00
Preference<int> m_iSoundPreferredSampleRate;
2005-05-16 09:36:32 +00:00
private:
Preference<CString> m_sInputDrivers; // "" == default
Preference<CString> m_sLightsDriver; // "" == default
public:
2005-05-16 18:07:01 +00:00
Preference<CString> m_sMovieDrivers; // "" == default
2005-05-16 09:36:32 +00:00
Preference<CString> m_sLightsStepsDifficulty;
Preference<bool> m_bBlinkGameplayButtonLightsOnNote;
Preference<bool> m_bAllowUnacceleratedRenderer;
Preference<bool> m_bThreadedInput;
Preference<bool> m_bThreadedMovieDecode;
Preference<bool> m_bScreenTestMode;
Preference<bool> m_bDebugLights;
Preference<bool> m_bMonkeyInput;
2005-05-16 09:36:32 +00:00
Preference<CString> m_sMachineName;
Preference<CString> m_sIgnoredMessageWindows;
Preference<CString> m_sCoursesToShowRanking;
/* Debug: */
2005-05-16 09:36:32 +00:00
Preference<bool> m_bLogToDisk;
Preference<bool> m_bForceLogFlush;
Preference<bool> m_bShowLogOutput;
Preference<bool> m_bLogSkips;
Preference<bool> m_bLogCheckpoints;
Preference<bool> m_bShowLoadingWindow;
2005-08-15 02:10:57 +00:00
#if !defined(WITHOUT_NETWORKING)
Preference<bool> m_bEnableScoreboard; //Alows disabling of scoreboard in network play
#endif
2005-05-16 09:36:32 +00:00
// wrappers
CString GetVideoRenderers();
CString GetSoundDrivers();
float GetSoundVolume();
CString GetInputDrivers();
CString GetMovieDrivers();
CString GetLightsDriver();
void ReadPrefsFromIni( const IniFile &ini, const CString &sSection );
void ReadGamePrefsFromIni( const CString &sIni );
void SavePrefsToIni( IniFile &ini );
2005-02-19 01:59:31 +00:00
2005-10-27 04:54:45 +00:00
void ReadPrefsFromDisk();
void SavePrefsToDisk();
2002-05-27 08:23:27 +00:00
void ResetToFactoryDefaults();
CString GetPreferencesSection() const;
bool MessageIsIgnored( const CString &ID );
void IgnoreMessage( const CString &ID );
//
// For self-registering prefs
//
static void Subscribe( IPreference *p );
static void Unsubscribe( IPreference *p );
2005-10-27 04:54:45 +00:00
2005-02-17 21:35:45 +00:00
// Lua
void PushSelf( lua_State *L );
protected:
void ReadPrefsFromFile( const CString &sIni, const CString &sSection );
2004-09-13 03:58:39 +00:00
2002-02-28 19:40:40 +00:00
};
2004-09-13 03:58:39 +00:00
2003-10-16 08:55:32 +00:00
/* 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;
2002-02-28 19:40:40 +00:00
2002-05-27 08:23:27 +00:00
extern PrefsManager* PREFSMAN; // global and accessable from anywhere in our program
#endif
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.
*/