1 /*************************************************************************** 2 * Copyright (C) 2009 by Andrey Afletdinov <fheroes2@gmail.com> * 3 * * 4 * Part of the Free Heroes2 Engine: * 5 * http://sourceforge.net/projects/fheroes2 * 6 * * 7 * This program is free software; you can redistribute it and/or modify * 8 * it under the terms of the GNU General Public License as published by * 9 * the Free Software Foundation; either version 2 of the License, or * 10 * (at your option) any later version. * 11 * * 12 * This program is distributed in the hope that it will be useful, * 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 15 * GNU General Public License for more details. * 16 * * 17 * You should have received a copy of the GNU General Public License * 18 * along with this program; if not, write to the * 19 * Free Software Foundation, Inc., * 20 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 21 ***************************************************************************/ 22 23 #ifndef H2SETTINGS_H 24 #define H2SETTINGS_H 25 26 #include "bitmodes.h" 27 #include "dir.h" 28 #include "maps_fileinfo.h" 29 #include "players.h" 30 31 enum : int 32 { 33 SCROLL_SLOW = 1, 34 SCROLL_NORMAL = 2, 35 SCROLL_FAST1 = 3, 36 SCROLL_FAST2 = 4 37 }; 38 39 enum MusicSource 40 { 41 MUSIC_MIDI_ORIGINAL, 42 MUSIC_MIDI_EXPANSION, 43 MUSIC_EXTERNAL 44 }; 45 46 class Settings 47 { 48 public: 49 enum 50 { 51 GAME_AUTOSAVE_BEGIN_DAY = 0x10000010, 52 GAME_REMEMBER_LAST_FOCUS = 0x10000020, 53 GAME_SAVE_REWRITE_CONFIRM = 0x10000040, 54 GAME_SHOW_SYSTEM_INFO = 0x10000100, 55 GAME_AUTOSAVE_ON = 0x10000200, 56 GAME_USE_FADE = 0x10000400, 57 GAME_EVIL_INTERFACE = 0x10001000, 58 GAME_HIDE_INTERFACE = 0x10002000, 59 // UNUSED = 0x10008000, 60 // UNUSED = 0x10010000, 61 GAME_BATTLE_SHOW_DAMAGE = 0x10100000, 62 GAME_CONTINUE_AFTER_VICTORY = 0x10200000, 63 64 /* influence on game balance: save to savefile */ 65 // UNUSED = 0x20000001, 66 // UNUSED = 0x20000002, 67 WORLD_ALLOW_SET_GUARDIAN = 0x20000008, 68 WORLD_ARTIFACT_CRYSTAL_BALL = 0x20000020, 69 WORLD_SCOUTING_EXTENDED = 0x20000040, 70 // UNUSED = 0x20000080, 71 WORLD_EYE_EAGLE_AS_SCHOLAR = 0x20000100, 72 HEROES_BUY_BOOK_FROM_SHRINES = 0x20000200, 73 // UNUSED = 0x20000400, 74 // UNUSED = 0x20000800, 75 // UNUSED = 0x20001000, 76 // UNUSED = 0x20002000, 77 WORLD_SHOW_TERRAIN_PENALTY = 0x20004000, 78 // UNUSED = 0x20008000, 79 // UNUSED = 0x20010000, 80 HEROES_TRANSCRIBING_SCROLLS = 0x20020000, 81 // UNUSED = 0x20040000, 82 CASTLE_ALLOW_GUARDIANS = 0x20080000, 83 HEROES_COST_DEPENDED_FROM_LEVEL = 0x20800000, 84 HEROES_REMEMBER_POINTS_RETREAT = 0x21000000, 85 86 CASTLE_MAGEGUILD_POINTS_TURN = 0x30000001, 87 // UNUSED = 0x30000008, 88 // UNUSED = 0x30000010, 89 WORLD_SCALE_NEUTRAL_ARMIES = 0x30000020, 90 HEROES_ARENA_ANY_SKILLS = 0x30000080, 91 // UNUSED = 0x30000100, 92 WORLD_USE_UNIQUE_ARTIFACTS_RS = 0x30000200, 93 WORLD_USE_UNIQUE_ARTIFACTS_PS = 0x30000400, 94 WORLD_USE_UNIQUE_ARTIFACTS_SS = 0x30000800, 95 WORLD_DISABLE_BARROW_MOUNDS = 0x30001000, 96 WORLD_EXT_OBJECTS_CAPTURED = 0x30004000, 97 // UNUSED = 0x30008000, 98 99 BATTLE_SHOW_ARMY_ORDER = 0x40004000, 100 BATTLE_DETERMINISTIC_RESULT = 0x40008000, 101 BATTLE_SOFT_WAITING = 0x40010000, 102 BATTLE_REVERSE_WAIT_ORDER = 0x40020000 103 }; 104 105 Settings( const Settings & ) = delete; 106 107 Settings & operator=( const Settings & ) = delete; 108 109 static Settings & Get(); 110 111 bool Read( const std::string & ); 112 bool Save( const std::string & ) const; 113 114 std::string String() const; 115 void SetCurrentFileInfo( const Maps::FileInfo & ); 116 const Maps::FileInfo & CurrentFileInfo() const; 117 118 bool isCurrentMapPriceOfLoyalty() const; 119 120 int Debug() const; 121 int HeroesMoveSpeed() const; 122 int AIMoveSpeed() const; 123 int BattleSpeed() const; 124 int ScrollSpeed() const; 125 126 int GameDifficulty() const; 127 128 const std::string & getGameLanguage() const; 129 const std::string & loadedFileLanguage() const; 130 131 const fheroes2::Point & PosRadar() const; 132 const fheroes2::Point & PosButtons() const; 133 const fheroes2::Point & PosIcons() const; 134 const fheroes2::Point & PosStatus() const; 135 136 void SetPosRadar( const fheroes2::Point & ); 137 void SetPosButtons( const fheroes2::Point & ); 138 void SetPosIcons( const fheroes2::Point & ); 139 void SetPosStatus( const fheroes2::Point & ); 140 141 bool FullScreen() const; 142 bool ShowControlPanel() const; 143 bool ShowRadar() const; 144 bool ShowIcons() const; 145 bool ShowButtons() const; 146 bool ShowStatus() const; 147 bool BattleShowGrid() const; 148 bool BattleShowMouseShadow() const; 149 bool BattleShowMoveShadow() const; 150 bool BattleAutoResolve() const; 151 bool BattleAutoSpellcast() const; 152 bool isPriceOfLoyaltySupported() const; 153 bool LoadedGameVersion() const; 154 bool MusicMIDI() const; 155 bool isShowIntro() const; 156 157 bool isVSyncEnabled() const; 158 159 bool isFirstGameRun() const; 160 void resetFirstGameRun(); 161 162 void BinarySave() const; 163 void BinaryLoad(); 164 165 bool CanChangeInGame( u32 ) const; 166 bool ExtModes( u32 ) const; 167 void ExtSetModes( u32 ); 168 void ExtResetModes( u32 ); 169 static std::string ExtName( const uint32_t settingId ); 170 171 bool ExtHeroBuySpellBookFromShrine() const; 172 bool ExtHeroRecruitCostDependedFromLevel() const; 173 bool ExtHeroRememberPointsForRetreating() const; 174 bool ExtHeroAllowTranscribingScroll() const; 175 bool ExtHeroArenaCanChoiseAnySkills() const; 176 bool ExtWorldShowTerrainPenalty() const; 177 bool ExtWorldScouteExtended() const; 178 bool ExtWorldAllowSetGuardian() const; 179 bool ExtWorldArtifactCrystalBall() const; 180 bool ExtWorldEyeEagleAsScholar() const; 181 bool ExtWorldNeutralArmyDifficultyScaling() const; 182 bool ExtWorldUseUniqueArtifactsRS() const; 183 bool ExtWorldUseUniqueArtifactsPS() const; 184 bool ExtWorldUseUniqueArtifactsSS() const; 185 bool ExtWorldExtObjectsCaptured() const; 186 bool ExtWorldDisableBarrowMounds() const; 187 bool ExtCastleAllowGuardians() const; 188 bool ExtCastleGuildRestorePointsTurn() const; 189 bool ExtBattleShowDamage() const; 190 bool ExtBattleShowBattleOrder() const; 191 bool ExtBattleSoftWait() const; 192 bool ExtBattleDeterministicResult() const; 193 bool ExtBattleReverseWaitOrder() const; 194 bool ExtGameRememberLastFocus() const; 195 bool ExtGameContinueAfterVictory() const; 196 bool ExtGameRewriteConfirm() const; 197 bool ExtGameShowSystemInfo() const; 198 bool ExtGameAutosaveBeginOfDay() const; 199 bool ExtGameAutosaveOn() const; 200 bool ExtGameUseFade() const; 201 bool ExtGameEvilInterface() const; 202 bool ExtGameHideInterface() const; 203 204 const fheroes2::Size & VideoMode() const; 205 206 void SetDebug( int ); 207 void EnablePriceOfLoyaltySupport( const bool set ); 208 void SetGameDifficulty( int ); 209 void SetEvilInterface( bool ); 210 void SetHideInterface( bool ); 211 void SetBattleGrid( bool ); 212 void SetBattleMovementShaded( bool ); 213 void SetBattleMouseShaded( bool ); 214 void SetShowPanel( bool ); 215 void SetShowRadar( bool ); 216 void SetShowIcons( bool ); 217 void SetShowButtons( bool ); 218 void SetShowStatus( bool ); 219 void SetAIMoveSpeed( int ); 220 void SetScrollSpeed( int ); 221 void SetHeroesMoveSpeed( int ); 222 void SetBattleSpeed( int ); 223 void setBattleAutoResolve( bool enable ); 224 void setBattleAutoSpellcast( bool enable ); 225 void setFullScreen( const bool enable ); 226 227 void SetSoundVolume( int v ); 228 void SetMusicVolume( int v ); 229 void SetMusicType( int v ); 230 231 bool setGameLanguage( const std::string & language ); 232 233 int SoundVolume() const; 234 int MusicVolume() const; 235 MusicSource MusicType() const; 236 237 bool IsGameType( int type ) const; 238 int GameType() const; 239 void SetGameType( int ); 240 bool isCampaignGameType() const; 241 242 Players & GetPlayers(); 243 const Players & GetPlayers() const; 244 245 int CurrentColor() const; 246 void SetCurrentColor( int ); 247 int PreferablyCountPlayers() const; 248 void SetPreferablyCountPlayers( int ); 249 250 // from maps info 251 bool AllowChangeRace( int ) const; 252 const std::string & MapsFile() const; 253 const std::string & MapsName() const; 254 const std::string & MapsDescription() const; 255 int MapsDifficulty() const; 256 fheroes2::Size MapsSize() const; 257 bool GameStartWithHeroes() const; 258 uint32_t ConditionWins() const; 259 uint32_t ConditionLoss() const; 260 bool WinsCompAlsoWins() const; 261 int WinsFindArtifactID() const; 262 bool WinsFindUltimateArtifact() const; 263 u32 WinsAccumulateGold() const; 264 fheroes2::Point WinsMapsPositionObject() const; 265 fheroes2::Point LossMapsPositionObject() const; 266 u32 LossCountDays() const; 267 int controllerPointerSpeed() const; 268 269 void SetMapsFile( const std::string & file ); 270 GetProgramPath()271 std::string GetProgramPath() const 272 { 273 return path_program; 274 } 275 void SetProgramPath( const char * ); 276 277 static std::string GetVersion(); 278 279 static ListDirs GetRootDirs(); 280 281 static ListFiles FindFiles( const std::string & prefixDir, const std::string & fileNameFilter, const bool exactMatch ); 282 static std::string GetLastFile( const std::string & prefix, const std::string & name ); 283 284 protected: 285 void PostLoad(); 286 287 private: 288 friend StreamBase & operator<<( StreamBase &, const Settings & ); 289 friend StreamBase & operator>>( StreamBase &, Settings & ); 290 291 Settings(); 292 ~Settings(); 293 294 BitModes opt_global; 295 BitModes opt_game; 296 BitModes opt_battle; 297 BitModes opt_world; 298 BitModes opt_addons; 299 300 int debug; 301 fheroes2::Size video_mode; 302 int game_difficulty; 303 304 std::string path_program; 305 306 std::string _gameLanguage; 307 std::string _loadedFileLanguage; // not a part of save or configuration file 308 309 Maps::FileInfo current_maps_file; 310 311 int sound_volume; 312 int music_volume; 313 MusicSource _musicType; 314 int _controllerPointerSpeed; 315 int heroes_speed; 316 int ai_speed; 317 int scroll_speed; 318 int battle_speed; 319 320 int game_type; 321 int preferably_count_players; 322 323 fheroes2::Point pos_radr; 324 fheroes2::Point pos_bttn; 325 fheroes2::Point pos_icon; 326 fheroes2::Point pos_stat; 327 328 Players players; 329 }; 330 331 StreamBase & operator<<( StreamBase &, const Settings & ); 332 StreamBase & operator>>( StreamBase &, Settings & ); 333 334 #endif 335