1 // Copyright (C) 2002, 2003 Michael Bartl
2 // Copyright (C) 2003, 2004, 2005, 2006 Ulf Lorenz
3 // Copyright (C) 2004, 2005 Andrea Paternesi
4 // Copyright (C) 2005 Josef Spillner
5 // Copyright (C) 2006 Ben Asselstine
6 // Copyright (C) 2007 Ole Laursen
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU Library General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23 #ifndef CONFIGURATION_H
24 #define CONFIGURATION_H
28 #include <sigc++/trackable.h>
32 #include "game-parameters.h"
34 // helper for making sure we got the initial configuration stuff up running
35 void initialize_configuration();
37 /** \brief The class which holds all configuration options
39 * Basically, this class is more of a namespace than a real class. It
40 * provides all global information about directories, settings etc.
43 // TODO: do we really want all this static stuff or rather do a singleton or such?
45 class Configuration : public sigc::trackable
52 /** \brief Load a configuration file
54 * @param fileName the full name of the config file
56 * This class loads an xml-style config file and sets the settings
59 bool loadConfigurationFile(std::string fileName);
61 /** \brief Save the configuration file
63 * @param fileName the full name of the config file
65 * This class saves the current config to an xml-style config file.
67 static bool saveConfigurationFile(std::string filename);
69 static std::string configuration_file_path;
71 // as the name implies
72 static bool s_showNextPlayer;
73 static int s_displaySpeedDelay;
74 static int s_displayFightRoundDelayFast;
75 static int s_displayFightRoundDelaySlow;
76 static bool s_displayCommentator;
79 static std::string s_dataPath;
80 static std::string s_savePath;
83 static std::string s_lang;
85 //the maximum size of the graphics cache
86 static guint32 s_cacheSize;
88 //zip and obfuscate save files
89 static bool s_zipfiles;
91 // when to save autosave files
92 // 0 = never, 1 = once a round overwrting,
93 // 2 = once a round not-overwriting
94 static int s_autosave_policy;
96 // music settings; the cache size is given in pieces instead of memory
97 static bool s_musicenable;
98 static guint32 s_musicvolume;
99 static guint32 s_musiccache;
101 // various default game settings
102 static bool s_see_opponents_stacks;
103 static bool s_see_opponents_production;
104 static GameParameters::QuestPolicy s_play_with_quests;
105 static bool s_hidden_map;
106 static bool s_diplomacy;
107 static GameParameters::NeutralCities s_neutral_cities;
108 static GameParameters::RazingCities s_razing_cities;
109 static bool s_intense_combat;
110 static bool s_military_advisor;
111 static bool s_random_turns;
112 static GameParameters::QuickStartPolicy s_quick_start;
113 static bool s_cusp_of_war;
114 static bool s_decorated;
115 static bool s_remember_recent_games;
116 static guint32 s_double_click_threshold;
118 static GameParameters::NeutralCities neutralCitiesFromString(const std::string str);
119 static std::string neutralCitiesToString(const GameParameters::NeutralCities neutrals);
120 static GameParameters::RazingCities razingCitiesFromString(const std::string str);
121 static std::string razingCitiesToString(const GameParameters::RazingCities razing);
124 WRITE_UNNUMBERED_AUTOSAVE_FILE = 1,
125 WRITE_NUMBERED_AUTOSAVE_FILE = 2,
127 static Configuration::SavingPolicy savingPolicyFromString(const std::string str);
128 static std::string savingPolicyToString(const Configuration::SavingPolicy policy);
129 static GameParameters::QuickStartPolicy quickStartPolicyFromString(const std::string str);
130 static std::string quickStartPolicyToString(const GameParameters::QuickStartPolicy policy);
131 static GameParameters::QuestPolicy questPolicyFromString(std::string str);
132 static std::string questPolicyToString(const GameParameters::QuestPolicy quest);
134 /** \brief The callback for the XML_Helper
136 * See the XML_Helper documentation for an explanation what the
137 * callback is good for.
139 bool parseConfiguration(std::string tag, XML_Helper* helper);
141 static std::string s_filename;
144 #endif // CONFIGURATION_H