forked from EasyRPG/Player
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame_config.h
188 lines (159 loc) · 7.42 KB
/
game_config.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
/*
* This file is part of EasyRPG Player.
*
* EasyRPG Player is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* EasyRPG Player is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with EasyRPG Player. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef EP_GAME_CONFIG_H
#define EP_GAME_CONFIG_H
/**
* This class manages global engine configuration.
* For game specific settings see Game_ConfigGame.
*
* @see Game_ConfigGame
*/
#include "config_param.h"
#include "filesystem.h"
#include "options.h"
#include "input_buttons.h"
#include "utils.h"
class CmdlineParser;
enum class ScalingMode {
/** Nearest neighbour to fit screen */
Nearest,
/** Like NN but only scales to integers */
Integer,
/** Integer followed by Bilinear downscale to fit screen */
Bilinear,
};
enum class GameResolution {
/** 320x240 */
Original,
/** 416x240 */
Widescreen,
/** 560x240 */
Ultrawide
};
enum class StartupLogos {
None,
Custom,
All
};
struct Game_ConfigPlayer {
StringConfigParam autobattle_algo{ "", "", "", "", "" };
StringConfigParam enemyai_algo{ "", "", "", "", "" };
BoolConfigParam settings_autosave{ "Save settings on exit", "Automatically save the settings on exit", "Player", "SettingsAutosave", false };
BoolConfigParam settings_in_title{ "Show settings on title screen", "Display settings menu item on the title screen", "Player", "SettingsInTitle", false };
BoolConfigParam settings_in_menu{ "Show settings in menu", "Display settings menu item on the menu screen", "Player", "SettingsInMenu", false };
EnumConfigParam<StartupLogos, 3> show_startup_logos{
"Startup Logos", "Logos that are displayed on startup", "Player", "StartupLogos", StartupLogos::Custom,
Utils::MakeSvArray("None", "Custom", "All"),
Utils::MakeSvArray("none", "custom", "all"),
Utils::MakeSvArray("Do not show any additional logos", "Show custom logos bundled with the game", "Show all logos, including the original from RPG Maker")};
void Hide();
};
struct Game_ConfigVideo {
LockedConfigParam<std::string> renderer{ "Renderer", "The rendering engine", "auto" };
BoolConfigParam vsync{ "V-Sync", "Toggle V-Sync mode (Recommended: ON)", "Video", "Vsync", true };
BoolConfigParam fullscreen{ "Fullscreen", "Toggle between fullscreen and window mode", "Video", "Fullscreen", true };
BoolConfigParam show_fps{ "Show FPS", "Toggle display of the FPS counter", "Video", "ShowFps", false };
BoolConfigParam fps_render_window{ "Show FPS in Window", "Show FPS inside the window when in window mode", "Video", "FpsRenderWindow", false };
RangeConfigParam<int> fps_limit{ "Frame Limiter", "Toggle the frames per second limit (Recommended: 60)", "Video", "FpsLimit", DEFAULT_FPS, 0, 99999 };
ConfigParam<int> window_zoom{ "Window Zoom", "Toggle the window zoom level", "Video", "WindowZoom", 2 };
EnumConfigParam<ScalingMode, 3> scaling_mode{ "Scaling method", "How the output is scaled", "Video", "ScalingMode", ScalingMode::Nearest,
Utils::MakeSvArray("Nearest", "Integer", "Bilinear"),
Utils::MakeSvArray("nearest", "integer", "bilinear"),
Utils::MakeSvArray("Scale to screen size (Causes scaling artifacts)", "Scale to multiple of the game resolution", "Like Nearest, but output is blurred to avoid artifacts")};
BoolConfigParam stretch{ "Stretch", "Stretch to the width of the window/screen", "Video", "Stretch", false };
BoolConfigParam touch_ui{ "Touch Ui", "Display the touch ui", "Video", "TouchUi", true };
EnumConfigParam<GameResolution, 3> game_resolution{ "Resolution", "Game resolution. Changes require a restart.", "Video", "GameResolution", GameResolution::Original,
Utils::MakeSvArray("Original (Recommended)", "Widescreen (Experimental)", "Ultrawide (Experimental)"),
Utils::MakeSvArray("original", "widescreen", "ultrawide"),
Utils::MakeSvArray("The default resolution (320x240, 4:3)", "Can cause glitches (416x240, 16:9)", "Can cause glitches (560x240, 21:9)")};
// These are never shown and are used to restore the window to the previous position
ConfigParam<int> window_x{ "", "", "Video", "WindowX", -1 };
ConfigParam<int> window_y{ "", "", "Video", "WindowY", -1 };
ConfigParam<int> window_width{ "", "", "Video", "WindowWidth", -1 };
ConfigParam<int> window_height{ "", "", "Video", "WindowHeight", -1 };
void Hide();
};
struct Game_ConfigAudio {
RangeConfigParam<int> music_volume{ "BGM Volume", "Volume of the background music", "Audio", "MusicVolume", 100, 0, 100 };
RangeConfigParam<int> sound_volume{ "SFX Volume", "Volume of the sound effects", "Audio", "SoundVolume", 100, 0, 100 };
void Hide();
};
struct Game_ConfigInput {
RangeConfigParam<int> speed_modifier_a{ "Fast Forward A: Speed", "Set fast forward A speed", "Input", "SpeedModifierA", 3, 2, 100 };
RangeConfigParam<int> speed_modifier_b{ "Fast Forward B: Speed", "Set fast forward B speed", "Input", "SpeedModifierB", 10, 2, 100 };
BoolConfigParam gamepad_swap_analog{ "Gamepad: Swap Analog Sticks", "Swap left and right stick", "Input", "GamepadSwapAnalog", false };
BoolConfigParam gamepad_swap_dpad_with_buttons{ "Gamepad: Swap D-Pad with buttons", "Swap D-Pad with ABXY-Buttons", "Input", "GamepadSwapDpad", false };
BoolConfigParam gamepad_swap_ab_and_xy{ "Gamepad: Swap AB and XY", "Swap A and B with X and Y", "Input", "GamepadSwapAbxy", false };
Input::ButtonMappingArray buttons;
void Hide();
};
struct Game_Config {
/** Gameplay subsystem options */
Game_ConfigPlayer player;
/** Video subsystem options */
Game_ConfigVideo video;
/** Audio subsystem options */
Game_ConfigAudio audio;
/** Input subsystem options */
Game_ConfigInput input;
/**
* Create an application config. This first determines the config file path if any,
* loads the config file, then loads command line arguments.
*/
static Game_Config Create(CmdlineParser& cp);
/** @return config file path from command line args if found */
static std::string GetConfigPath(CmdlineParser& cp);
/**
* Returns the a filesystem view to the global config directory
*/
static FilesystemView GetGlobalConfigFilesystem();
/**
* Returns a handle to the global config file for reading.
* The file is created if it does not exist.
*
* @return handle to the global file
*/
static Filesystem_Stream::InputStream GetGlobalConfigFileInput();
/**
* Returns a handle to the global config file for writing.
* The file is created if it does not exist.
*
* @return handle to the global file
*/
static Filesystem_Stream::OutputStream GetGlobalConfigFileOutput();
/**
* Load configuration values from a stream;
*
* @param is stream to read from.
* @post values of this are updated with values found in the stream.
*/
void LoadFromStream(Filesystem_Stream::InputStream& is);
/**
* Load configuration values from a command line arguments.
*
* @param cp the command line parser to use.
* @post values of this are updated with values found in command line args.
*/
void LoadFromArgs(CmdlineParser& cp);
/**
* Writes our configuration to the given stream.
*
* @param os stream to write to
*/
void WriteToStream(Filesystem_Stream::OutputStream& os) const;
};
#endif