1 /*
2  * This file is part of EasyRPG Player.
3  *
4  * EasyRPG Player is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * EasyRPG Player is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef EP_GAME_CONFIG_H
19 #define EP_GAME_CONFIG_H
20 
21 #include "config_param.h"
22 #include "options.h"
23 
24 class CmdlineParser;
25 
26 struct Game_ConfigPlayer {
27 	StringConfigParam autobattle_algo{ "RPG_RT" };
28 	StringConfigParam enemyai_algo{ "RPG_RT" };
29 };
30 
31 struct Game_ConfigVideo {
32 	BoolConfigParam vsync{ true };
33 	BoolConfigParam fullscreen{ true };
34 	BoolConfigParam show_fps{ false };
35 	BoolConfigParam fps_render_window{ false };
36 	RangeConfigParam<int> fps_limit{ DEFAULT_FPS, 0, std::numeric_limits<int>::max() };
37 	RangeConfigParam<int> window_zoom{ 2, 1, std::numeric_limits<int>::max() };
38 };
39 
40 struct Game_ConfigAudio {
41 };
42 
43 struct Game_ConfigInput {
44 };
45 
46 struct Game_Config {
47 	/** Path to last config file we read from */
48 	std::string config_path;
49 
50 	/** Gameplay subsystem options */
51 	Game_ConfigPlayer player;
52 
53 	/** Video subsystem options */
54 	Game_ConfigVideo video;
55 
56 	/** Audio subsystem options */
57 	Game_ConfigAudio audio;
58 
59 	/** Input subsystem options */
60 	Game_ConfigAudio input;
61 
62 	/**
63 	 * Create an application config. This first determines the config file path if any,
64 	 * loads the config file, then loads command line arguments.
65 	 */
66 	static Game_Config Create(CmdlineParser& cp);
67 
68 	/** Return config file path from command line args if found */
69 	static std::string GetConfigPath(CmdlineParser& cp);
70 
71 	/**
72 	 * Returns the default config path for your system.
73 	 */
74 	static std::string GetDefaultConfigPath();
75 
76 	/**
77 	 * Load configuration values from a config file.
78 	 *
79 	 * @param path the path to config file.
80 	 * @post values of this are updated with values found in config file.
81 	 */
82 	void LoadFromConfig(const std::string& path);
83 
84 	/**
85 	 * Load configuration values from a command line arguments.
86 	 *
87 	 * @param cp the command line parser to use.
88 	 * @post values of this are updated with values found in command line args.
89 	 */
90 	void LoadFromArgs(CmdlineParser& cp);
91 
92 	/**
93 	 * Writes our configuration to the given config file
94 	 *
95 	 * @param path
96 	 */
97 	void WriteToConfig(const std::string& path) const;
98 };
99 
100 #endif
101