galaxy 1.0.0
Real-Time C++23 Game Programming Framework. Built on data-driven design principles and agile software engineering.
Loading...
Searching...
No Matches
Settings.cpp
Go to the documentation of this file.
1
7
8#include <entt/locator/locator.hpp>
9
12
13#include "Settings.hpp"
14
15#ifdef GALAXY_WIN_PLATFORM
19#endif
20
21namespace galaxy
22{
24 {
25 auto& config = entt::locator<Config>::value();
26
27 // config.restore<int>("width", 1920, "window");
28 // config.restore<int>("height", 1080, "window");
29 // config.restore<std::string>("icon", "", "window");
30 // config.restore<bool>("fullscreen", false, "window");
31 // config.restore<bool>("maximized", true, "window");
32 // config.restore<bool>("resizable", true, "window");
33 // config.restore<bool>("border", true, "window");
34
35 // config.restore<bool>("mouse_grabbed", false, "mouse");
36 // config.restore<bool>("cursor_show", true, "mouse");
37 // config.restore<std::string>("cursor_icon", "", "mouse");
38 // config.restore<int>("x", 0, "mouse.cursor_hotspot");
39 // config.restore<int>("y", 0, "mouse.cursor_hotspot");
40
41 // config.restore<int>("ansiotrophy", 16, "graphics");
42 // config.restore<bool>("mipmap", true, "graphics");
43 // config.restore<std::string>("texture_filter", "NEAREST", "graphics");
44 // config.restore<int>("max_quads", 250, "graphics");
45
46 config.restore<bool>("vsync", false, "window");
47 config.restore<int>("audio_freq", 44100, "audio");
48
49 config.restore<std::string>("title", "galaxy app", "meta");
50 config.restore<std::string>("version", "1.0", "meta");
51 config.restore<std::string>("identifier", "com.galaxy.app", "meta");
52 config.restore<std::string>("creator", "reworks", "meta");
53 config.restore<std::string>("copyright", "2025+ reworks", "meta");
54 config.restore<std::string>("website", "https://reworks-org.github.io/galaxy/", "meta");
55
56 config.restore<std::string>("logs_dir", "logs/", "fs");
57 config.restore<std::string>("assets_dir", "assets/", "fs");
58 config.restore<std::string>("editor_dir", "editor/", "fs");
59 config.restore<std::string>("asset_pack", "assets.galaxy", "fs");
60 config.restore<bool>("use_loose_assets", true, "fs");
61 config.restore<std::string>("assets_music", "music/", "fs");
62 config.restore<std::string>("assets_sfx", "sfx/", "fs");
63 config.restore<std::string>("assets_voice", "voice/", "fs");
64 config.restore<std::string>("assets_font", "fonts/", "fs");
65 config.restore<std::string>("assets_script", "scripts/", "fs");
66 config.restore<std::string>("assets_shaders", "shaders/", "fs");
67 config.restore<std::string>("assets_animation", "animations/", "fs");
68 config.restore<std::string>("assets_texture", "textures/", "fs");
69 config.restore<std::string>("assets_prefabs", "prefabs/", "fs");
70 config.restore<std::string>("assets_maps", "maps/", "fs");
71 config.restore<std::string>("assets_video", "video/", "fs");
72 config.restore<std::string>("assets_ui", "ui/", "fs");
73
74 config.save();
75 }
76
78 {
79 auto& config = entt::locator<Config>::value();
80
81 // s_window_width = *config.get<int>("width", "window");
82 // s_window_height = *config.get<int>("height", "window");
83 // s_window_icon = *config.get<std::string>("icon", "window");
84 // s_fullscreen = *config.get<bool>("fullscreen", "window");
85 // s_maximized = *config.get<bool>("maximized", "window");
86 // s_resizable = *config.get<bool>("resizable", "window");
87 // s_border = *config.get<bool>("border", "window");
88
89 // s_mouse_grabbed = *config.get<bool>("mouse_grabbed", "mouse");
90 // s_cursor_show = *config.get<bool>("cursor_show", "mouse");
91 // s_cursor_icon = *config.get<std::string>("cursor_icon", "mouse");
92 // s_cursor_hotspot.x = *config.get<int>("x", "mouse.cursor_hotspot");
93 // s_cursor_hotspot.y = *config.get<int>("y", "mouse.cursor_hotspot");
94
95 // s_ansio = *config.get<int>("ansiotrophy", "graphics");
96 // s_mipmap = *config.get<bool>("mipmap", "graphics");
97 // s_filtering = *config.get<std::string>("texture_filter", "graphics").and_then([](std::string_view filter) {
98 // return magic_enum::enum_cast<GLTextureFilter>(filter);
99 // });
100 // s_max_quads = *config.get<int>("max_quads", "graphics");
101
102 s_vsync = *config.get<bool>("vsync", "window");
103 s_audio_freq = *config.get<int>("audio_freq", "audio");
104
105 s_title = *config.get<std::string>("title", "meta");
106 s_version = *config.get<std::string>("version", "meta");
107 s_identifier = *config.get<std::string>("identifier", "meta");
108 s_creator = *config.get<std::string>("creator", "meta");
109 s_copyright = *config.get<std::string>("copyright", "meta");
110 s_website = *config.get<std::string>("website", "meta");
111
112 s_logs_dir = *config.get<std::string>("logs_dir", "fs");
113 s_assets_dir = *config.get<std::string>("assets_dir", "fs");
114 s_editor_dir = *config.get<std::string>("editor_dir", "fs");
115 s_asset_pack = *config.get<std::string>("asset_pack", "fs");
116 s_use_loose_assets = *config.get<bool>("use_loose_assets", "fs");
117 s_assets_music = *config.get<std::string>("assets_music", "fs");
118 s_assets_sfx = *config.get<std::string>("assets_sfx", "fs");
119 s_assets_voice = *config.get<std::string>("assets_voice", "fs");
120 s_assets_font = *config.get<std::string>("assets_font", "fs");
121 s_assets_script = *config.get<std::string>("assets_script", "fs");
122 s_assets_shaders = *config.get<std::string>("assets_shaders", "fs");
123 s_assets_animation = *config.get<std::string>("assets_animation", "fs");
124 s_assets_texture = *config.get<std::string>("assets_texture", "fs");
125 s_assets_prefabs = *config.get<std::string>("assets_prefabs", "fs");
126 s_assets_maps = *config.get<std::string>("assets_maps", "fs");
127 s_assets_video = *config.get<std::string>("assets_video", "fs");
128 s_assets_ui = *config.get<std::string>("assets_ui", "fs");
129 }
130
131 auto Settings::vsync() noexcept -> bool
132 {
133 return s_vsync;
134 }
135
136 auto Settings::audio_freq() noexcept -> int
137 {
138 return s_audio_freq;
139 }
140
141 auto Settings::title() noexcept -> const std::string&
142 {
143 return s_title;
144 }
145
146 auto Settings::version() noexcept -> const std::string&
147 {
148 return s_version;
149 }
150
151 auto Settings::identifier() noexcept -> const std::string&
152 {
153 return s_identifier;
154 }
155
156 auto Settings::creator() noexcept -> const std::string&
157 {
158 return s_creator;
159 }
160
161 auto Settings::copyright() noexcept -> const std::string&
162 {
163 return s_copyright;
164 }
165
166 auto Settings::website() noexcept -> const std::string&
167 {
168 return s_website;
169 }
170
171 auto Settings::logs_dir() noexcept -> const std::string&
172 {
173 return s_logs_dir;
174 }
175
176 auto Settings::root_dir() noexcept -> std::filesystem::path
177 {
178 return std::filesystem::current_path();
179 }
180
181 auto Settings::assets_dir() noexcept -> std::filesystem::path
182 {
183 return s_assets_dir;
184 }
185
186 auto Settings::editor_dir() noexcept -> std::filesystem::path
187 {
188 return s_editor_dir;
189 }
190
191 auto Settings::asset_pack() noexcept -> const std::string&
192 {
193 return s_asset_pack;
194 }
195
196 auto Settings::use_loose_assets() noexcept -> bool
197 {
198 return s_use_loose_assets;
199 }
200
201 auto Settings::assets_dir_music() noexcept -> const std::string&
202 {
203 return s_assets_music;
204 }
205
206 auto Settings::assets_dir_sfx() noexcept -> const std::string&
207 {
208 return s_assets_sfx;
209 }
210
211 auto Settings::assets_dir_voice() noexcept -> const std::string&
212 {
213 return s_assets_voice;
214 }
215
216 auto Settings::assets_dir_font() noexcept -> const std::string&
217 {
218 return s_assets_font;
219 }
220
221 auto Settings::assets_dir_script() noexcept -> const std::string&
222 {
223 return s_assets_script;
224 }
225
226 auto Settings::assets_dir_shaders() noexcept -> const std::string&
227 {
228 return s_assets_shaders;
229 }
230
231 auto Settings::assets_dir_animation() noexcept -> const std::string&
232 {
233 return s_assets_animation;
234 }
235
236 auto Settings::assets_dir_texture() noexcept -> const std::string&
237 {
238 return s_assets_texture;
239 }
240
241 auto Settings::assets_dir_prefabs() noexcept -> const std::string&
242 {
243 return s_assets_prefabs;
244 }
245
246 auto Settings::assets_dir_maps() noexcept -> const std::string&
247 {
248 return s_assets_maps;
249 }
250
251 auto Settings::assets_dir_video() noexcept -> const std::string&
252 {
253 return s_assets_video;
254 }
255
256 auto Settings::assets_dir_ui() noexcept -> const std::string&
257 {
258 return s_assets_ui;
259 }
260} // namespace galaxy
261
262#ifdef GALAXY_WIN_PLATFORM
264#endif
265
266/*
267auto Settings::window_width() noexcept -> int
268 {
269 return s_window_width;
270 }
271
272 auto Settings::window_height() noexcept -> int
273 {
274 return s_window_height;
275 }
276
277 auto Settings::window_icon() noexcept -> const std::string&
278 {
279 return s_window_icon;
280 }
281
282 auto Settings::fullscreen() noexcept -> bool
283 {
284 return s_fullscreen;
285 }
286
287 auto Settings::maximized() noexcept -> bool
288 {
289 return s_maximized;
290 }
291
292
293
294 auto Settings::window_resizable() noexcept -> bool
295 {
296 return s_resizable;
297 }
298
299 auto Settings::window_border() noexcept -> bool
300 {
301 return s_border;
302 }
303
304 auto Settings::mouse_grabbed() noexcept -> bool
305 {
306 return s_mouse_grabbed;
307 }
308
309 auto Settings::cursor_show() noexcept -> bool
310 {
311 return s_cursor_show;
312 }
313
314 auto Settings::cursor_icon() noexcept -> const std::string&
315 {
316 return s_cursor_icon;
317 }
318
319 auto Settings::cursor_hotspot() noexcept -> const glm::ivec2&
320 {
321 return s_cursor_hotspot;
322 }
323
324
325 auto Settings::ansiotrophy() noexcept -> int
326 {
327 return s_ansio;
328 }
329
330 auto Settings::mipmap() noexcept -> bool
331 {
332 return s_mipmap;
333 }
334
335 auto Settings::texture_filter() noexcept -> GLTextureFilter
336 {
337 return s_filtering;
338 }
339
340 auto Settings::max_quads() noexcept -> int
341 {
342 return s_max_quads;
343 }
344
345
346
347*/
#define GALAXY_DISABLE_WARNING_POP
Definition Pragma.hpp:62
#define GALAXY_DISABLE_WARNING(x)
Definition Pragma.hpp:63
#define GALAXY_DISABLE_WARNING_PUSH
Macro for windows platform detection.
Definition Pragma.hpp:61
Application.hpp galaxy.
STL namespace.
static bool s_vsync
Definition Settings.hpp:242
static std::string s_asset_pack
Definition Settings.hpp:255
static auto root_dir() noexcept -> std::filesystem::path
Current root directory of application, unless it has been changed.
Definition Settings.cpp:176
static std::string s_title
Definition Settings.hpp:245
static std::string s_assets_video
Definition Settings.hpp:267
static std::string s_assets_prefabs
Definition Settings.hpp:265
static std::string s_assets_music
Definition Settings.hpp:257
static auto logs_dir() noexcept -> const std::string &
Current root directory of application, unless it has been changed.
Definition Settings.cpp:171
static auto assets_dir_prefabs() noexcept -> const std::string &
Prefab asset location.
Definition Settings.cpp:241
static std::string s_logs_dir
Definition Settings.hpp:252
static auto copyright() noexcept -> const std::string &
Copyright message.
Definition Settings.cpp:161
static auto assets_dir_texture() noexcept -> const std::string &
Textures asset location.
Definition Settings.cpp:236
static auto vsync() noexcept -> bool
Vsync control.
Definition Settings.cpp:131
static auto assets_dir_voice() noexcept -> const std::string &
Voice asset location.
Definition Settings.cpp:211
static bool s_use_loose_assets
Definition Settings.hpp:256
static auto assets_dir_shaders() noexcept -> const std::string &
Shaders asset location.
Definition Settings.cpp:226
static std::string s_assets_sfx
Definition Settings.hpp:258
static std::string s_copyright
Definition Settings.hpp:249
static std::string s_assets_script
Definition Settings.hpp:261
static auto assets_dir_ui() noexcept -> const std::string &
UI asset location.
Definition Settings.cpp:256
static auto set_settings_from_config() -> void
Set all our settings using the provided config file.
Definition Settings.cpp:77
static auto use_loose_assets() noexcept -> bool
Should asset data be read from pack or assets dir.
Definition Settings.cpp:196
static std::string s_assets_texture
Definition Settings.hpp:264
static auto assets_dir_animation() noexcept -> const std::string &
Animation data location.
Definition Settings.cpp:231
static auto assets_dir_script() noexcept -> const std::string &
Scripts asset location.
Definition Settings.cpp:221
static auto assets_dir_music() noexcept -> const std::string &
Music asset location.
Definition Settings.cpp:201
static auto identifier() noexcept -> const std::string &
Game identifier i.e. com.galaxy.app.
Definition Settings.cpp:151
static auto title() noexcept -> const std::string &
Game title.
Definition Settings.cpp:141
static std::string s_creator
Definition Settings.hpp:248
static std::string s_assets_voice
Definition Settings.hpp:259
static auto assets_dir() noexcept -> std::filesystem::path
Main data directory.
Definition Settings.cpp:181
static auto asset_pack() noexcept -> const std::string &
Name of packed assets file.
Definition Settings.cpp:191
static std::filesystem::path s_assets_dir
Definition Settings.hpp:253
static auto version() noexcept -> const std::string &
Game semver.
Definition Settings.cpp:146
static auto audio_freq() noexcept -> int
Set audio frequency to use with SDL.
Definition Settings.cpp:136
static std::string s_assets_maps
Definition Settings.hpp:266
static auto website() noexcept -> const std::string &
Website URL.
Definition Settings.cpp:166
static auto assets_dir_sfx() noexcept -> const std::string &
SFX asset location.
Definition Settings.cpp:206
static auto assets_dir_maps() noexcept -> const std::string &
Maps asset location.
Definition Settings.cpp:246
static std::string s_assets_shaders
Definition Settings.hpp:262
static std::string s_assets_animation
Definition Settings.hpp:263
static std::filesystem::path s_editor_dir
Definition Settings.hpp:254
static auto set_config_to_default() -> void
Restore all config settings to default.
Definition Settings.cpp:23
static std::string s_assets_font
Definition Settings.hpp:260
static std::string s_assets_ui
Definition Settings.hpp:268
static auto editor_dir() noexcept -> std::filesystem::path
Directory for editor specific stuff.
Definition Settings.cpp:186
static std::string s_website
Definition Settings.hpp:250
static auto assets_dir_video() noexcept -> const std::string &
Video asset location.
Definition Settings.cpp:251
static std::string s_version
Definition Settings.hpp:246
static auto assets_dir_font() noexcept -> const std::string &
Font asset location.
Definition Settings.cpp:216
static auto creator() noexcept -> const std::string &
Owner.
Definition Settings.cpp:156
static int s_audio_freq
Definition Settings.hpp:243
static std::string s_identifier
Definition Settings.hpp:247