| [1531] | 1 | /* | 
|---|
 | 2 |  *   ORXONOX - the hottest 3D action shooter ever to exist | 
|---|
 | 3 |  *                    > www.orxonox.net < | 
|---|
 | 4 |  * | 
|---|
 | 5 |  * | 
|---|
 | 6 |  *   License notice: | 
|---|
 | 7 |  * | 
|---|
 | 8 |  *   This program is free software; you can redistribute it and/or | 
|---|
 | 9 |  *   modify it under the terms of the GNU General Public License | 
|---|
 | 10 |  *   as published by the Free Software Foundation; either version 2 | 
|---|
 | 11 |  *   of the License, or (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 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  02110-1301, USA. | 
|---|
 | 21 |  * | 
|---|
 | 22 |  *   Author: | 
|---|
 | 23 |  *      Reto Grieder | 
|---|
 | 24 |  *   Co-authors: | 
|---|
 | 25 |  *      ... | 
|---|
 | 26 |  * | 
|---|
 | 27 |  */ | 
|---|
 | 28 |  | 
|---|
 | 29 | /** | 
|---|
 | 30 |     @file Core.h | 
|---|
| [1755] | 31 |     @brief Declaration of the Settings class. | 
|---|
| [1531] | 32 |  | 
|---|
 | 33 |     The static Settings class is only used to configure some variables | 
|---|
 | 34 |     through the config-file. | 
|---|
 | 35 | */ | 
|---|
 | 36 |  | 
|---|
 | 37 | #ifndef _Settings_H__ | 
|---|
 | 38 | #define _Settings_H__ | 
|---|
 | 39 |  | 
|---|
 | 40 | #include "OrxonoxPrereqs.h" | 
|---|
| [1532] | 41 | #include <string> | 
|---|
 | 42 | #include "core/OrxonoxClass.h" | 
|---|
| [1755] | 43 | #include "util/Debug.h" | 
|---|
 | 44 | #include "util/MultiType.h" | 
|---|
| [1531] | 45 |  | 
|---|
 | 46 | namespace orxonox | 
|---|
 | 47 | { | 
|---|
| [1755] | 48 |     class _OrxonoxExport Settings : public OrxonoxClass | 
|---|
 | 49 |     { | 
|---|
 | 50 |         friend class ClassIdentifier<Settings>; | 
|---|
 | 51 |         friend class GSRoot; | 
|---|
 | 52 |         friend class GSGraphics; | 
|---|
 | 53 |         friend class GSServer; | 
|---|
| [1907] | 54 |         friend class GSClient; | 
|---|
| [1755] | 55 |         friend class GSDedicated; | 
|---|
 | 56 |  | 
|---|
| [1531] | 57 |     public: | 
|---|
| [1755] | 58 |         static const std::string& getDataPath() | 
|---|
 | 59 |         { assert(singletonRef_s); return singletonRef_s->dataPath_; } | 
|---|
 | 60 |         static void tsetDataPath(const std::string& path) | 
|---|
 | 61 |         { assert(singletonRef_s); singletonRef_s->_tsetDataPath(path); } | 
|---|
| [1531] | 62 |  | 
|---|
| [1755] | 63 |         // an alternative to a global game mode variable | 
|---|
 | 64 |         static bool showsGraphics() { assert(singletonRef_s); return singletonRef_s->bShowsGraphics_; } | 
|---|
 | 65 |         static bool hasServer()     { assert(singletonRef_s); return singletonRef_s->bHasServer_; } | 
|---|
| [1907] | 66 |         static bool isClient()      { assert(singletonRef_s); return singletonRef_s->bIsClient_; } | 
|---|
| [1531] | 67 |  | 
|---|
 | 68 |     private: | 
|---|
| [1755] | 69 |         // GSRoot has access to these | 
|---|
 | 70 |         static void setShowsGraphics(bool val) { assert(singletonRef_s); singletonRef_s->bShowsGraphics_ = val; } | 
|---|
 | 71 |         static void setHasServer    (bool val) { assert(singletonRef_s); singletonRef_s->bHasServer_     = val; } | 
|---|
| [1907] | 72 |         static void setIsClient     (bool val) { assert(singletonRef_s); singletonRef_s->bIsClient_      = val; } | 
|---|
| [1531] | 73 |  | 
|---|
| [1755] | 74 |         Settings(); | 
|---|
 | 75 |         Settings(const Settings& instance); | 
|---|
 | 76 |         ~Settings() { singletonRef_s = 0; } | 
|---|
| [1531] | 77 |  | 
|---|
| [1755] | 78 |         static Settings& _getInstance() { assert(singletonRef_s); return *singletonRef_s; } | 
|---|
 | 79 |         void _tsetDataPath(const std::string& path); | 
|---|
 | 80 |         void dataPathChanged(); | 
|---|
 | 81 |  | 
|---|
 | 82 |         void setConfigValues(); | 
|---|
 | 83 |  | 
|---|
 | 84 |         bool bShowsGraphics_;                                  //!< global variable that tells whether to show graphics | 
|---|
 | 85 |         bool bHasServer_;                                      //!< global variable that tells whether this is a server | 
|---|
| [1907] | 86 |         bool bIsClient_; | 
|---|
| [1755] | 87 |  | 
|---|
 | 88 |         std::string dataPath_;                                 //!< Path to the game data | 
|---|
 | 89 |  | 
|---|
 | 90 |         static Settings* singletonRef_s;                       //!< Static pointer to the only instance. | 
|---|
 | 91 |     }; | 
|---|
 | 92 |  | 
|---|
| [1531] | 93 | } | 
|---|
 | 94 |  | 
|---|
 | 95 | #endif /* _Settings_H__ */ | 
|---|