ScummVM API documentation
GameParam.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
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 3 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, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 /*
23  * This code is based on the CRAB engine
24  *
25  * Copyright (c) Arvind Raja Yadav
26  *
27  * Licensed under MIT
28  *
29  */
30 
31 #ifndef CRAB_GAMEPARAM_H
32 #define CRAB_GAMEPARAM_H
33 
34 #include "common/hashmap.h"
35 #include "common/hash-str.h"
36 #include "common/list.h"
37 #include "common/rect.h"
38 #include "common/str.h"
39 #include "crab/loaders.h"
40 #include "crab/rapidxml/rapidxml.hpp"
41 
42 namespace Crab {
43 
44 // The index for all levels in the game
45 struct LevelPath {
46  // The file paths
47  Common::Path _layout, _asset;
48 
49  // The name of the level
50  Common::String _name;
51 
52  LevelPath() {}
53 
54  void load(rapidxml::xml_node<char> *node) {
55  loadStr(_name, "name", node);
56  loadPath(_layout, "layout", node);
57  loadPath(_asset, "res", node);
58  }
59 };
60 
61 // Stores all layout paths for the game
62 struct FilePaths {
63  // Resources common to all levels and states
64  Common::Path _common;
65 
66  // Mod file location, current mod and their extension
67  Common::Path _modPath, _modCur;
68  Common::String _modExt;
69 
70  // Main menu resources
71  Common::Path _mainmenuL, _mainmenuR;
72 
73  // Sounds
74  Common::Path _soundEffect, _soundMusic;
75 
76  // Fonts and window icon file
77  Common::Path _font, _icon;
78 
79  // Save directory and extension
80  Common::Path _saveDir;
81  Common::String _saveExt;
82 
83  // The location of the shader index file
84  Common::Path _shaders;
85 
86  // The location of the color index file
87  Common::Path _colors;
88 
89  // The list of levels in the game
91 
92  // The file path of the current resource file
93  Common::Path _currentR;
94 
95  // The application data path (where saves and settings are stored)
96  Common::Path _appdata;
97 
98  // Has this been loaded?
99  bool _loaded;
100 
101  FilePaths();
102  void load(const Common::Path &filename);
103  void loadLevel(const Common::Path &filename);
104 };
105 
106 // Storage pool used for saving numbers as strings
107 class StringPool {
108  // Store integer strings here
109  // std::unordered_map<int, Common::String> pool_i;
111 
112  // Store floating point strings here
113  struct FloatString {
114  float _val;
115  Common::String _str;
116 
117  FloatString() {
118  _val = 0.0f;
119  }
120  };
121 
122  // std::list<FloatString> pool_f;
124 
125 public:
126  StringPool() {
127  poolI.clear();
128  poolF.clear();
129  }
130 
131  const char *get(const int &num) {
132  if (poolI.contains(num) == false)
133  poolI[num] = numberToString<int>(num);
134 
135  return poolI.getVal(num).c_str();
136  }
137 
138  const char *fGet(const float &num) {
139  for (auto &i : poolF)
140  if (i._val == num)
141  return i._str.c_str();
142 
143  FloatString fs;
144  fs._val = num;
145  fs._str = numberToString<float>(num);
146  poolF.push_back(fs);
147 
148  auto ret = poolF.back();
149  return ret._str.c_str();
150  }
151 };
152 
153 struct TempValue {
154  // Differences between normal mode and iron man mode
155  // save button - iron man saves in existing file
156  // load button - hidden in iron man
157  // exit - saves and exits in iron man
158  // quick save and quick load - operate on the iron man file in iron man mode
159  bool _ironman;
160 
161  // This is the filename a player chose when selecting "new game" + iron man mode
162  Common::String _filename;
163 
164  // We use this to see whether the player is exiting to main menu or to credits
165  bool _credits;
166 
167  TempValue() : _filename("No IronMan") {
168  _ironman = false;
169  _credits = false;
170  }
171 };
172 
173 // Our global objects
174 
175 // Whether to draw debug outlines on polygons
176 extern bool GameDebug;
177 
178 } // End of namespace Crab
179 
180 #endif // CRAB_GAMEPARAM_H
Definition: GameParam.h:45
void clear(bool shrinkArray=0)
Definition: hashmap.h:427
Definition: str.h:59
Val & getVal(const Key &key)
Definition: hashmap.h:633
Definition: GameParam.h:62
Definition: path.h:52
Definition: hashmap.h:85
void clear()
Definition: list.h:206
bool contains(const Key &key) const
Definition: hashmap.h:594
Definition: moveeffect.h:37
Definition: GameParam.h:153
Definition: GameParam.h:107