initial commit, lordsawar source, slightly modified
[lordsawar] / src / Configuration.h
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
7 //
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.
12 //
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.
17 //
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 
21 //  02110-1301, USA.
22
23 #ifndef CONFIGURATION_H
24 #define CONFIGURATION_H
25
26 #include <gtkmm.h>
27 #include <string>
28 #include <sigc++/trackable.h>
29
30 class XML_Helper;
31
32 #include "game-parameters.h"
33
34 // helper for making sure we got the initial configuration stuff up running
35 void initialize_configuration();
36
37 /** \brief The class which holds all configuration options
38   * 
39   * Basically, this class is more of a namespace than a real class. It
40   * provides all global information about directories, settings etc.
41   */
42
43 // TODO: do we really want all this static stuff or rather do a singleton or such?
44
45 class Configuration : public sigc::trackable
46 {
47     public:
48         // CREATORS
49         Configuration();
50         ~Configuration();
51
52         /** \brief Load a configuration file
53           * 
54           * @param fileName     the full name of the config file
55           *
56           * This class loads an xml-style config file and sets the settings
57           * appropriately.
58           */
59         bool loadConfigurationFile(std::string fileName);
60
61         /** \brief Save the configuration file
62           * 
63           * @param fileName     the full name of the config file
64           *
65           * This class saves the current config to an xml-style config file.
66           */
67         static bool saveConfigurationFile(std::string filename);
68
69         static std::string configuration_file_path;
70         
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;
77         
78         //the paths
79         static std::string s_dataPath;
80         static std::string s_savePath;
81
82         // Language setting
83         static std::string s_lang;
84
85         //the maximum size of the graphics cache
86         static guint32 s_cacheSize;
87
88         //zip and obfuscate save files
89         static bool s_zipfiles;
90
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;
95
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;
100
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;
117
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);
122         enum SavingPolicy {
123           NO_SAVING = 0,
124           WRITE_UNNUMBERED_AUTOSAVE_FILE = 1,
125           WRITE_NUMBERED_AUTOSAVE_FILE = 2,
126         };
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);
133     private:
134         /** \brief The callback for the XML_Helper
135           * 
136           * See the XML_Helper documentation for an explanation what the
137           * callback is good for.
138           */
139         bool parseConfiguration(std::string tag, XML_Helper* helper);
140
141         static std::string s_filename;
142 };
143
144 #endif // CONFIGURATION_H