PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
config_manager.h
1 /*
2  * Platformer Game Engine by Wohlstand, a free platform for game making
3  * Copyright (c) 2015 Vitaly Novichkov <admin@wohlnet.ru>
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef CONFIG_MANAGER_H
20 #define CONFIG_MANAGER_H
21 
22 #include "../common_features/app_path.h"
23 #include "../common_features/pge_texture.h"
24 #include "../common_features/simple_animator.h"
25 #include "../common_features/npc_animator.h"
26 #include "../common_features/matrix_animator.h"
27 
28 #include "setup_load_screen.h"
29 #include "setup_wld_scene.h"
30 #include "setup_lvl_scene.h"
31 #include "setup_title_screen.h"
32 #include "setup_credits_screen.h"
33 
34 #include "obj_block.h"
35 #include "obj_bgo.h"
36 #include "obj_npc.h"
37 #include "obj_bg.h"
38 #include "obj_player.h"
39 #include "obj_effect.h"
40 #include "obj_wld_items.h"
41 
42 #include "obj_sound.h"
43 #include "obj_music.h"
44 
45 #include <QMap>
46 #include <QSettings>
47 #include <QFile>
48 
49 #include "custom_data.h"
50 
51 
53 {
54  QString worlds;
55 
56  QString music;
57  QString sounds;
58 
59  QString glevel;
60  QString gworld;
61  QString gplayble;
62 
63  QString gcommon;
64 
65  QString gcustom;
66 };
67 
68 /*****************Fonts********************/
69 struct FontsSetup
70 {
71  bool double_pixled;
72  QString fontname;
73  QString rasterFontsFile;
74 };
75 /******************************************/
76 
77 
78 /**************Cursors*********************/
80 {
81  QString normal;
82  QString rubber;
83 };
84 /******************************************/
85 
87 {
88  QString sprite;
89  int borderWidth;
90  float box_padding;
91  QString font_name;
92  int font_id;
93  QString font_color;
94  GlColor font_rgba;
95 };
96 
98 {
99  QString sprite;
100  int borderWidth;
101  float box_padding;
102  QString title_font_name;
103  int title_font_id;
104  QString title_font_color;
105  GlColor title_font_rgba;
106 };
107 
108 struct MenuSetup
109 {
110  QString selector;
111  QString scrollerUp;
112  QString scrollerDown;
113  int item_height;
114  int font_offset;
115  QString font_name;
116  int font_id;
117 };
118 
120 
122 {
123 public:
124  ConfigManager();
125 
126  static DataFolders dirs;
127  static QString config_id;
128  static QString config_dir;
129  static QString data_dir;
130  static int default_grid;
131 
132  //Common Data
133  static QList<PGE_Texture > common_textures;
134 
135  static unsigned int screen_width;
136  static unsigned int screen_height;
137 
138  enum screenType{
139  SCR_Static=0, //Static / Scalable screen
140  SCR_Dynamic //Dynamic screen
141  };
142  static screenType screen_type;
143 
144  //Fonts
145  static FontsSetup setup_fonts;
146  //curors
147  static MainCursors setup_cursors;
148  //MessageBox setup
149  static MessageBoxSetup setup_message_box;
150  //MenuBox setup
151  static MenuBoxSetup setup_menu_box;
152  //Menu setup
153  static MenuSetup setup_menus;
154 
155 
156  //LoadingScreen
157  friend struct LoadingScreenSetup;
158  static LoadingScreenSetup setup_LoadingScreen;
159 
160  //Title Screen
161  friend struct TitleScreenSetup;
162  static TitleScreenSetup setup_TitleScreen;
163 
164  //World map data
165  friend struct WorldMapSetup;
166  static WorldMapSetup setup_WorldMap;
167 
168  //Level data
169  friend struct LevelSetup;
170  static LevelSetup setup_Level;
171 
172  //Credits Screen
173  friend struct CreditsScreenSetup;
174  static CreditsScreenSetup setup_CreditsScreen;
175 
176 
177  /********Music and sounds*******/
178  static bool loadMusic(QString rootPath, QString iniFile, bool isCustom=false);
179  static bool loadDefaultMusics();
180  static QString getWldMusic(unsigned long musicID, QString customMusic="");
181  static QString getLvlMusic(unsigned long musicID, QString customMusic="");
182  static QString getSpecialMusic(unsigned long musicID);
183 
184  static unsigned long music_custom_id;
185  static unsigned long music_w_custom_id;
186  static QHash<int, obj_music> main_music_lvl;
187  static QHash<int, obj_music> main_music_wld;
188  static QHash<int, obj_music> main_music_spc;
189 
190  static bool loadDefaultSounds();
191  static bool loadSound(QString rootPath, QString iniFile, bool isCustom=false);
192  static QString getSound(unsigned long sndID);
193  static long getSoundByRole(obj_sound_role::roles role);
194  static bool loadSoundRolesTable();
195 
196  static QHash<int, obj_sound > main_sound;
197  static QHash<obj_sound_role::roles, long > main_sound_table;
198  static void buildSoundIndex();
199  static void clearSoundIndex();
200  static QVector<obj_sound_index > main_sfx_index;
201 
202  static bool musicIniChanged();
203  static bool soundIniChanged();
204  static QString music_lastIniFile;
205  static QString sound_lastIniFile;
206  static bool music_lastIniFile_changed;
207  static bool sound_lastIniFile_changed;
208  /********Music and sounds*******/
209 
210 
211  static void setConfigPath(QString p);
212  //Load settings
213  static bool loadBasics();
214  static bool unloadLevelConfigs();
215  static bool unloadWorldConfigs();
216  static void unluadAll();
217 
218  /*================================Level config Data===========================*/
219 
220  /*****Level blocks************/
221  static bool loadLevelBlocks();
222  static long getBlockTexture(long blockID);
223  /*****************************/
224  static QMap<long, obj_block> lvl_block_indexes;
225  static CustomDirManager Dir_Blocks;
226  static QList<SimpleAnimator > Animator_Blocks;
227  /*****Level blocks************/
228 
229  /*****Level BGO************/
230  static bool loadLevelBGO();
231  static long getBgoTexture(long bgoID);
232  /*****************************/
233  static QMap<long, obj_bgo> lvl_bgo_indexes;
234  static CustomDirManager Dir_BGO;
235  static QList<SimpleAnimator > Animator_BGO;
236  /*****Level BGO************/
237 
238  /*****Level NPC************/
239  static bool loadLevelNPC();
240  static void loadNpcTxtConfig(long npcID);
241  static long getNpcTexture(long npcID);
242  /*****************************/
243  static QMap<long, obj_npc> lvl_npc_indexes;
244  static NPC_GlobalSetup marker_npc;
245  static CustomDirManager Dir_NPC;
246  static CustomDirManager Dir_NPCScript;
247  static QList<AdvNpcAnimator > Animator_NPC;
248  /*****Level NPC************/
249 
250 
251 
252 
253  /*****Level Backgrounds************/
254  static bool loadLevelBackG();
255  static bool loadLevelBackground(obj_BG &sbg, QString section, obj_BG *merge_with=0, QString iniFile="", QSettings *setup=0);
256  static long getBGTexture(long bgID, bool isSecond=false);
257  /*****************************/
258  static QMap<long, obj_BG> lvl_bg_indexes;
259  static CustomDirManager Dir_BG;
260  static QList<SimpleAnimator > Animator_BG;
261  /*****Level Backgrounds************/
262  /*================================Level config Data===end=====================*/
263 
264  /*================================World config Data===========================*/
265  /*****World Tiles************/
266  static bool loadWorldTiles();
267  static long getTileTexture(long tileID);
268  /*****************************/
269  static QMap<long, obj_w_tile> wld_tiles;
270  static CustomDirManager Dir_Tiles;
271  static QList<SimpleAnimator > Animator_Tiles;
272  /*****World Tiles************/
273 
274  /*****World Scenery************/
275  static bool loadWorldScenery();
276  static long getSceneryTexture(long sceneryID);
277  /*****************************/
278  static QMap<long, obj_w_scenery> wld_scenery;
279  static CustomDirManager Dir_Scenery;
280  static QList<SimpleAnimator > Animator_Scenery;
281  /*****World Scenery************/
282 
283  /*****World Paths************/
284  static bool loadWorldPaths();
285  static long getWldPathTexture(long pathID);
286  /*****************************/
287  static QMap<long, obj_w_path> wld_paths;
288  static CustomDirManager Dir_WldPaths;
289  static QList<SimpleAnimator > Animator_WldPaths;
290  /*****World Paths************/
291 
292  /*****World Levels************/
293  static bool loadWorldLevels();
294  static long getWldLevelTexture(long levelID);
295  /*****************************/
296  static QMap<long, obj_w_level> wld_levels;
297  static CustomDirManager Dir_WldLevel;
298  static QList<SimpleAnimator > Animator_WldLevel;
299  static wld_levels_Markers marker_wlvl;
300  /*****World Levels************/
301 
302 
303 
304  /*================================World config Data===end=====================*/
305 
306  /*****Level Effects************/
307  static bool loadLevelEffects();
308  static long getEffectTexture(long effectID);
309  /*****************************/
310  static QMap<long, obj_effect> lvl_effects_indexes;
311  static CustomDirManager Dir_EFFECT;
312  /*****Level Effects************/
313 
314 
315  /********Playable characters*******/
316  static long getLvlPlayerTexture(long playerID, int stateID);
317  static long getWldPlayerTexture(long playerID, int stateID);
318  static void resetPlayableTexuresState();
319  static void resetPlayableTexuresStateWld();
320  static bool loadPlayableCharacters();
321  /*****************************/
322  static QHash<int, obj_player > playable_characters;
323  static CustomDirManager Dir_PlayerWld;
324  static CustomDirManager Dir_PlayerLvl;
325  /********Playable characters*******/
326 
327  /***********Texture banks*************/
328  static QList<PGE_Texture > level_textures;
329  static QList<PGE_Texture > world_textures;
330  /***********Texture banks*************/
331 
332  static void addError(QString bug, QtMsgType level=QtWarningMsg);
333 
334  static QStringList errorsList;
335 
336  static QString PathLevelBGO();
337  static QString PathLevelBG();
338  static QString PathLevelBlock();
339  static QString PathLevelNPC();
340  static QString PathLevelNPCScript();
341  static QString PathLevelEffect();
342  static QString PathLevelPlayable();
343 
344  static QString PathCommonGFX();
345 
346  static QString PathScript();
347 
348  static QString PathWorldTiles();
349  static QString PathWorldScenery();
350  static QString PathWorldPaths();
351  static QString PathWorldLevels();
352  static QString PathWorldPlayable();
353 
354  static QString PathWorldMusic();
355  static QString PathWorldSound();
356 
357  static QString clearMusTrack(QString path);
358 
359 private:
360  static void checkForImage(QString &imgPath, QString root);
361 
362  //special paths
363  static QString imgFile, imgFileM;
364  static QString tmpstr;
365  static QStringList tmp;
366 
367  static QString bgoPath;
368  static QString BGPath;
369  static QString blockPath;
370  static QString npcPath;
371  static QString npcScriptPath;
372  static QString effectPath;
373  static QString playerLvlPath;
374  static QString playerWldPath;
375 
376  static QString tilePath;
377  static QString scenePath;
378  static QString pathPath;
379  static QString wlvlPath;
380 
381  static QString commonGPath;
382 
383  static QString scriptPath;
384 
385  static void refreshPaths();
386  static bool loadEngineSettings();
387 };
388 
389 
390 #endif // CONFIG_MANAGER_H
Definition: obj_bg.h:25
Definition: config_manager.h:86
Definition: setup_wld_scene.h:18
Definition: setup_lvl_scene.h:19
Definition: setup_credits_screen.h:36
Definition: setup_title_screen.h:31
Definition: config_manager.h:121
Definition: setup_load_screen.h:36
Definition: obj_wld_items.h:124
Definition: config_manager.h:97
This is a capturer of custom files from level/world custom directories.
Definition: custom_data.h:27
Definition: config_manager.h:69
static void resetPlayableTexuresStateWld()
Same but for world map player images.
Definition: config_textures.cpp:296
static bool loadBasics()
Definition: config_manager.cpp:85
static bool loadPlayableCharacters()
Load lvl_characters.ini file.
Definition: obj_player.cpp:143
Definition: config_manager.h:52
static void resetPlayableTexuresState()
Sets all 'isInit' state to false for all textures for level textutes.
Definition: config_textures.cpp:283
Definition: config_manager.h:108
static QList< AdvNpcAnimator > Animator_NPC
Global NPC Animators (just for a coins, vines, not for activing NPC's!)
Definition: config_manager.h:247
Definition: gl_color.h:7
Definition: obj_npc.h:245
static bool unloadWorldConfigs()
Definition: config_manager.cpp:245
static bool unloadLevelConfigs()
Definition: config_manager.cpp:214
Definition: config_manager.h:79