PGE Engine
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Macros Pages
global_settings.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 GLOBALSETTINGS_H
20 #define GLOBALSETTINGS_H
21 
22 #include <controls/controller_key_map.h>
23 #include <QList>
24 
25 #define SDL_MAIN_HANDLED
26 #include <SDL2/SDL.h>
27 
28 class QSettings;
29 class Controller;
30 
35 {
36 public:
38  ~GlobalSettings();
42  void initJoysticks();
43 
47  void closeJoysticks();
48 
52  void load();
53 
57  void save();
58 
62  void resetDefaults();
63 
67  void apply();
68 
69 /*Via command line only*/
71  bool debugMode;
74 /*Via command line only. End*/
75 
77  bool fullScreen;
78 
83 
89  bool vsync;
90 
93 
95  bool frameSkip;
96 
101 
107  QList<KeyMap> player1_joysticks;
109  QList<KeyMapJoyCtrls> player1_joysticks_ctrls_ids;
111  QList<KeyMapJoyCtrls> player1_joysticks_ctrls_types;
112 
118  QList<KeyMap> player2_joysticks;
120  QList<KeyMapJoyCtrls> player2_joysticks_ctrls_ids;
122  QList<KeyMapJoyCtrls> player2_joysticks_ctrls_types;
123 
125  QList<SDL_Joystick*> joysticks;
126 
133  void loadKeyMap(KeyMap &map, QSettings &set, QString grp);
134 
141  void saveKeyMap(KeyMap &map, QSettings &set, QString grp);
142 
149  void loadJoyCtrlMapID(KeyMap &map, QSettings &set, QString grp);
150 
157  void saveJoyCtrlMapID(KeyMap &map, QSettings &set, QString grp);
158 
165  void loadJoyCtrlMapType(KeyMap &map, QSettings &set, QString grp);
166 
173  void saveJoyCtrlMapType(KeyMap &map, QSettings &set, QString grp);
174 
180  Controller *openController(int player);
181 
185  void loadJoystickSettings();
186 };
187 
189 extern GlobalSettings g_AppSettings;
190 
191 #endif // GLOBALSETTINGS_H
int player2_controller
Type of controller used by second player (-1 keyboard, >=0 joystick ID)
Definition: global_settings.h:114
Global engine application settings class.
Definition: global_settings.h:34
void saveJoyCtrlMapID(KeyMap &map, QSettings &set, QString grp)
Save settings from specific joysticks control map into opened config file inside specified INI-group...
Definition: global_settings.cpp:261
QList< KeyMapJoyCtrls > player2_joysticks_ctrls_ids
Joystick control ID maps per each joystick ID for a second player.
Definition: global_settings.h:120
int volume_music
Current volume of music (0...128)
Definition: global_settings.h:100
KeyMap player2_keyboard
Keyboard controlls map for a second player.
Definition: global_settings.h:116
Controller * openController(int player)
Constructs controller class for specific player and return a pointer to it.
Definition: global_settings.cpp:319
bool interprocessing
Enable interprocessing mode (Engine will try to find running editor and will ask it for opened file d...
Definition: global_settings.h:73
KeyMap player1_keyboard
Keyboard controlls map for a first player.
Definition: global_settings.h:105
void apply()
Applies all changed preferences.
Definition: global_settings.cpp:193
void loadJoyCtrlMapType(KeyMap &map, QSettings &set, QString grp)
Load settings to specific joysticks control types map through opened config file inside specified INI...
Definition: global_settings.cpp:280
int player1_controller
Type of controller used by first player (-1 keyboard, >=0 joystick ID)
Definition: global_settings.h:103
int ScreenHeight
Current height of screen.
Definition: global_settings.h:82
bool frameSkip
Enable skipping of frames if real time delay is longer than predefined.
Definition: global_settings.h:95
void resetDefaults()
Set all settings to default state.
Definition: global_settings.cpp:157
bool debugMode
Enable debug mode of engine (Allow any cheats and allow showing of any debug information) ...
Definition: global_settings.h:71
void save()
Save settings into config file.
Definition: global_settings.cpp:128
bool vsync
Enable vertical synchronization with monitor refresh rate (not all video cards are supports this feat...
Definition: global_settings.h:89
void loadJoyCtrlMapID(KeyMap &map, QSettings &set, QString grp)
Load settings to specific joysticks control map through opened config file inside specified INI-group...
Definition: global_settings.cpp:242
QList< KeyMapJoyCtrls > player2_joysticks_ctrls_types
Joystick control types (button, axis, hat, ball) maps per each joystick ID for a second player...
Definition: global_settings.h:122
The Controller class provides proxy interface between controllable objects array and physical control...
Definition: controller.h:32
void saveJoyCtrlMapType(KeyMap &map, QSettings &set, QString grp)
Save settings from specific joysticks control types map into opened config file inside specified INI-...
Definition: global_settings.cpp:299
float TicksPerSecond
How much loop steps will be done per second.
Definition: global_settings.h:85
QList< KeyMap > player2_joysticks
Control maps per each joystick ID for a second player.
Definition: global_settings.h:118
int volume_sound
Current volume of SFX-es (0...128)
Definition: global_settings.h:98
void loadJoystickSettings()
Load all joystick control keys maps from engine configuration file.
Definition: global_settings.cpp:98
QList< KeyMapJoyCtrls > player1_joysticks_ctrls_ids
Joystick control ID maps per each joystick ID for a first player.
Definition: global_settings.h:109
int timeOfFrame
Time of one loop step.
Definition: global_settings.h:87
QList< KeyMap > player1_joysticks
Control maps per each joystick ID for a first player.
Definition: global_settings.h:107
void saveKeyMap(KeyMap &map, QSettings &set, QString grp)
Save settings from specific control keys map into opened config file into specified INI-group...
Definition: global_settings.cpp:223
Definition: controller_key_map.h:17
void initJoysticks()
Initialize all plugged joystics which are can be used in game.
Definition: global_settings.cpp:39
void loadKeyMap(KeyMap &map, QSettings &set, QString grp)
Load settings to specific control key map through opened config file inside specified INI-group...
Definition: global_settings.cpp:204
void load()
Load settings from a config file.
Definition: global_settings.cpp:65
QList< SDL_Joystick * > joysticks
List of all available joysticks.
Definition: global_settings.h:125
void closeJoysticks()
Deinitialize all initialized joysticks.
Definition: global_settings.cpp:56
bool fullScreen
Enable full-screen mode.
Definition: global_settings.h:77
int ScreenWidth
Current width of screen.
Definition: global_settings.h:80
bool showDebugInfo
Enable printing of engine debug information.
Definition: global_settings.h:92
QList< KeyMapJoyCtrls > player1_joysticks_ctrls_types
Joystick control types (button, axis, hat, ball) maps per each joystick ID for a first player...
Definition: global_settings.h:111