src/game/config.h

Go to the documentation of this file.
00001 /******************************************************************************
00002  *  Wormux is a convivial mass murder game.
00003  *  Copyright (C) 2001-2004 Lawrence Azzoug.
00004  *
00005  *  This program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2 of the License, or
00008  *  (at your option) any later version.
00009  *
00010  *  This program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *  GNU General Public License for more details.
00014  *
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with this program; if not, write to the Free Software
00017  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
00018  ******************************************************************************
00019  * Configuration of Wormux : store game config of every tunable variable of Wormux.
00020  * Vars have a default value and can be change with the file configuration.
00021  *****************************************************************************/
00022 
00023 #ifndef CONFIG_H
00024 #define CONFIG_H
00025 //-----------------------------------------------------------------------------
00026 #include <list>
00027 #include <string>
00028 #include "../include/base.h"
00029 #include "../team/team_config.h"
00030 #include "../tool/xml_document.h"
00031 #include "../interface/keyboard.h"
00032 #include "../weapon/weapons_list.h"
00033 //-----------------------------------------------------------------------------
00034 #if defined(WIN32) || defined(__MINGW32__)
00035 #define PATH_SEPARATOR "\\"
00036 #else
00037 #define PATH_SEPARATOR "/"
00038 #endif
00039 
00040 #ifdef __MINGW32__
00041 #undef LoadImage
00042 #endif
00043 //-----------------------------------------------------------------------------
00044 
00045 class Config
00046 {
00047 public:
00048   static const int ALPHA = 0;
00049   static const int COLORKEY = 1;
00050 
00051   // Divers
00052   bool GetExterieurMondeVide() const;
00053   void SetExterieurMondeVide(bool emv);
00054 
00055   bool GetDisplayEnergyCharacter() const;
00056   void SetDisplayEnergyCharacter(bool dec);
00057 
00058   bool GetDisplayNameCharacter() const;
00059   void SetDisplayNameCharacter(bool dnc);
00060 
00061   bool GetDisplayWindParticles() const;
00062   void SetDisplayWindParticles(bool dwp);
00063 
00064   bool GetDefaultMouseCursor() const;
00065   void SetDefaultMouseCursor(bool dmc);
00066 
00067   bool GetScrollOnBorder() const;
00068   void SetScrollOnBorder(bool sob);
00069 
00070   bool IsNetworkActivated() const;
00071 
00072   int GetTransparency() const;
00073 
00074   inline Keyboard * GetKeyboard() { return my_keyboard; }
00075   inline WeaponsList * GetWeaponsList() { return my_weapons_list; }
00076 
00077   std::string GetTtfFilename() const;
00078 
00079   std::string GetDataDir() const;
00080   std::string GetLocaleDir() const;
00081   std::string GetPersonalDir() const;
00082 
00083   // Tempory values (loaded from XML, but may change during running)
00084   struct tmp_xml_config{
00085     struct tmp_xml_net{
00086       bool enable_network;
00087     } network;
00088     struct tmp_xml_screen{
00089       int width,height;
00090       bool fullscreen;
00091     } video;
00092     struct tmp_xml_sound{
00093       bool music;
00094       bool effects;
00095       uint frequency;
00096     } sound;
00097     std::list<struct ConfigTeam> teams;
00098     std::string map_name;
00099   } tmp;
00100 
00101   static Config * GetInstance();
00102 // bool Load();
00103   void Apply();
00104   bool Save();
00105 
00106 protected:
00107   bool LoadXml(xmlpp::Element *xml);
00108   void SetKeyboardConfig();
00109   bool SaveXml();
00110   std::string GetEnv(const std::string & name, const std::string &default_value);
00111 
00112   std::string m_game_mode;
00113   bool m_xml_loaded;
00114   std::string m_filename;
00115 
00116   std::string data_dir, locale_dir, personal_dir;
00117 
00118   bool exterieur_monde_vide;
00119   bool display_energy_character;
00120   bool display_name_character;
00121   bool display_wind_particles;
00122   bool default_mouse_cursor;
00123   bool scroll_on_border;
00124   std::string ttf_filename;
00125 
00126   int transparency;
00127 
00128 private:
00129   Config();
00130   // In french Clavier = keyboard
00131   Keyboard * my_keyboard;
00132   WeaponsList * my_weapons_list;
00133   static Config * singleton;
00134   bool DoLoading(void);
00135 };
00136 #endif

Generated on Mon Jan 1 13:10:56 2007 for Wormux by  doxygen 1.4.7