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
18#endif
19
20namespace galaxy
21{
23 {
24 auto& config = entt::locator<Config>::value();
25
26 /*config.restore<double>("ups", 60.0f, "physics");
27
28 config.restore<int>("width", 1920, "window");
29 config.restore<int>("height", 1080, "window");
30 config.restore<int>("view_width", 1280, "window");
31 config.restore<int>("view_height", 720, "window");
32 config.restore<std::string>("title", "galaxy", "window");
33 config.restore<std::string>("icon", "", "window");
34 config.restore<bool>("fullscreen", false, "window");
35 config.restore<bool>("key_repeat", true, "window");
36 config.restore<bool>("vsync", false, "window");
37 config.restore<bool>("msaa", false, "window");
38
39 config.restore<bool>("visible", true, "cursor");
40 config.restore<bool>("grab", false, "cursor");
41 config.restore<std::string>("icon", "", "cursor");
42 config.restore<int>("x", 0, "cursor.icon_size");
43 config.restore<int>("y", 0, "cursor.icon_size");
44 config.restore<int>("x", 0, "cursor.hotspot");
45 config.restore<int>("y", 0, "cursor.hotspot");*/
46
47 config.restore<std::string>("assets_dir", "assets/", "fs");
48 config.restore<std::string>("editor_dir", "editor/", "fs");
49 config.restore<std::string>("asset_pack", "assets.galaxy", "fs");
50 config.restore<bool>("use_loose_assets", true, "fs");
51 config.restore<std::string>("assets_music", "music/", "fs");
52 config.restore<std::string>("assets_sfx", "sfx/", "fs");
53 config.restore<std::string>("assets_voice", "voice/", "fs");
54 config.restore<std::string>("assets_font", "fonts/", "fs");
55 config.restore<std::string>("assets_script", "scripts/", "fs");
56 config.restore<std::string>("assets_shaders", "shaders/", "fs");
57 config.restore<std::string>("assets_animation", "animations/", "fs");
58 config.restore<std::string>("assets_texture", "textures/", "fs");
59 config.restore<std::string>("assets_prefabs", "prefabs/", "fs");
60 config.restore<std::string>("assets_maps", "maps/", "fs");
61 config.restore<std::string>("assets_video", "video/", "fs");
62 config.restore<std::string>("assets_ui", "ui/", "fs");
63
64 config.save();
65 }
66
68 {
69 auto& config = entt::locator<Config>::value();
70
71 // s_ups = config.get<double>("ups", "physics");
72
73 // s_window_width = config.get<int>("width", "window");
74 // s_window_height = config.get<int>("height", "window");
75 // s_view_width = config.get<int>("view_width", "window");
76 // s_view_height = config.get<int>("view_height", "window");
77 // s_title = config.get<std::string>("title", "window");
78 // s_icon = config.get<std::string>("icon", "window");
79 // s_fullscreen = config.get<bool>("fullscreen", "window");
80 // s_key_repeat = config.get<bool>("key_repeat", "window");
81 // s_vsync = config.get<bool>("vsync", "window");
82 // s_msaa = config.get<bool>("msaa", "window");
83
84 // s_cursor_visible = config.get<bool>("visible", "cursor");
85 // s_cursor_grabbed = config.get<bool>("grab", "cursor");
86 // s_cursor_icon = config.get<std::string>("icon", "cursor");
87 // s_cursor_icon_size.x = config.get<int>("x", "cursor.icon_size");
88 // s_cursor_icon_size.y = config.get<int>("y", "cursor.icon_size");
89 // s_cursor_hotspot.x = config.get<int>("x", "cursor.hotspot");
90 // s_cursor_hotspot.y = config.get<int>("y", "cursor.hotspot");
91
92 s_assets_dir = config.get<std::string>("assets_dir", "fs").value();
93 s_editor_dir = config.get<std::string>("editor_dir", "fs").value();
94 s_asset_pack = config.get<std::string>("asset_pack", "fs").value();
95 s_use_loose_assets = config.get<bool>("use_loose_assets", "fs").value();
96 s_assets_music = config.get<std::string>("assets_music", "fs").value();
97 s_assets_sfx = config.get<std::string>("assets_sfx", "fs").value();
98 s_assets_voice = config.get<std::string>("assets_voice", "fs").value();
99 s_assets_font = config.get<std::string>("assets_font", "fs").value();
100 s_assets_script = config.get<std::string>("assets_script", "fs").value();
101 s_assets_shaders = config.get<std::string>("assets_shaders", "fs").value();
102 s_assets_animation = config.get<std::string>("assets_animation", "fs").value();
103 s_assets_texture = config.get<std::string>("assets_texture", "fs").value();
104 s_assets_prefabs = config.get<std::string>("assets_prefabs", "fs").value();
105 s_assets_maps = config.get<std::string>("assets_maps", "fs").value();
106 s_assets_video = config.get<std::string>("assets_video", "fs").value();
107 s_assets_ui = config.get<std::string>("assets_ui", "fs").value();
108 }
109
110 /*auto settings::set_delta_time(const double dt) noexcept -> void
111 {
112 s_delta_time = dt;
113 }
114
115 auto settings::dt() noexcept -> double
116 {
117 return s_delta_time;
118 }
119
120 auto settings::ups() noexcept -> double
121 {
122 return s_ups;
123 }
124
125 auto settings::window_width() noexcept -> int
126 {
127 return s_window_width;
128 }
129
130 auto settings::window_height() noexcept -> int
131 {
132 return s_window_height;
133 }
134
135 auto settings::view_width() noexcept -> int
136 {
137 return s_view_width;
138 }
139
140 auto settings::view_height() noexcept -> int
141 {
142 return s_view_height;
143 }
144
145 auto settings::window_title() noexcept -> const std::string&
146 {
147 return s_title;
148 }
149
150 auto settings::window_icon() noexcept -> const std::string&
151 {
152 return s_icon;
153 }
154
155 auto settings::fullscreen() noexcept -> bool
156 {
157 return s_fullscreen;
158 }
159
160 auto settings::key_repeat() noexcept -> bool
161 {
162 return s_key_repeat;
163 }
164
165 auto settings::vsync() noexcept -> bool
166 {
167 return s_vsync;
168 }
169
170 auto settings::msaa() noexcept -> bool
171 {
172 return s_msaa;
173 }
174
175 auto settings::cursor_visible() noexcept -> bool
176 {
177 return s_cursor_visible;
178 }
179
180 auto settings::cursor_grabbed() noexcept -> bool
181 {
182 return s_cursor_grabbed;
183 }
184
185 auto settings::cursor_icon() noexcept -> const std::string&
186 {
187 return s_cursor_icon;
188 }
189
190 auto settings::cursor_icon_size() noexcept -> const sf::Vector2u&
191 {
192 return s_cursor_icon_size;
193 }
194
195 auto settings::cursor_hotspot() noexcept -> const sf::Vector2u&
196 {
197 return s_cursor_hotspot;
198 }*/
199
200 auto settings::root_dir() noexcept -> std::filesystem::path
201 {
202 return std::filesystem::current_path();
203 }
204
205 auto settings::assets_dir() noexcept -> std::filesystem::path
206 {
207 return s_assets_dir;
208 }
209
210 auto settings::editor_dir() noexcept -> std::filesystem::path
211 {
212 return s_editor_dir;
213 }
214
215 auto settings::asset_pack() noexcept -> const std::string&
216 {
217 return s_asset_pack;
218 }
219
220 auto settings::use_loose_assets() noexcept -> bool
221 {
222 return s_use_loose_assets;
223 }
224
225 auto settings::assets_dir_music() noexcept -> const std::string&
226 {
227 return s_assets_music;
228 }
229
230 auto settings::assets_dir_sfx() noexcept -> const std::string&
231 {
232 return s_assets_sfx;
233 }
234
235 auto settings::assets_dir_voice() noexcept -> const std::string&
236 {
237 return s_assets_voice;
238 }
239
240 auto settings::assets_dir_font() noexcept -> const std::string&
241 {
242 return s_assets_font;
243 }
244
245 auto settings::assets_dir_script() noexcept -> const std::string&
246 {
247 return s_assets_script;
248 }
249
250 auto settings::assets_dir_shaders() noexcept -> const std::string&
251 {
252 return s_assets_shaders;
253 }
254
255 auto settings::assets_dir_animation() noexcept -> const std::string&
256 {
257 return s_assets_animation;
258 }
259
260 auto settings::assets_dir_texture() noexcept -> const std::string&
261 {
262 return s_assets_texture;
263 }
264
265 auto settings::assets_dir_prefabs() noexcept -> const std::string&
266 {
267 return s_assets_prefabs;
268 }
269
270 auto settings::assets_dir_maps() noexcept -> const std::string&
271 {
272 return s_assets_maps;
273 }
274
275 auto settings::assets_dir_video() noexcept -> const std::string&
276 {
277 return s_assets_video;
278 }
279
280 auto settings::assets_dir_ui() noexcept -> const std::string&
281 {
282 return s_assets_ui;
283 }
284} // namespace galaxy
285
286#ifdef GALAXY_WIN_PLATFORM
288#endif
#define GALAXY_DISABLE_WARNING_POP
Definition Pragma.hpp:59
#define GALAXY_DISABLE_WARNING(x)
Definition Pragma.hpp:60
#define GALAXY_DISABLE_WARNING_PUSH
Macro for windows platform detection.
Definition Pragma.hpp:58
Timer.hpp galaxy.
Definition Timer.cpp:18
STL namespace.
static std::filesystem::path s_assets_dir
Definition Settings.hpp:266
static auto assets_dir_video() noexcept -> const std::string &
Video asset location.
Definition Settings.cpp:275
static auto assets_dir_voice() noexcept -> const std::string &
Voice asset location.
Definition Settings.cpp:235
static bool s_use_loose_assets
Definition Settings.hpp:269
static auto set_settings_from_config() -> void
Set all our settings using the provided config file.
Definition Settings.cpp:67
static auto assets_dir_script() noexcept -> const std::string &
Scripts asset location.
Definition Settings.cpp:245
static std::string s_assets_animation
Definition Settings.hpp:276
static std::string s_assets_voice
Definition Settings.hpp:272
static std::filesystem::path s_editor_dir
Definition Settings.hpp:267
static auto asset_pack() noexcept -> const std::string &
Name of packed assets file.
Definition Settings.cpp:215
static auto root_dir() noexcept -> std::filesystem::path
Current root directory of application, unless it has been changed.
Definition Settings.cpp:200
static auto assets_dir_prefabs() noexcept -> const std::string &
Prefab asset location.
Definition Settings.cpp:265
static auto assets_dir_shaders() noexcept -> const std::string &
Shaders asset location.
Definition Settings.cpp:250
static auto assets_dir_animation() noexcept -> const std::string &
Animation data location.
Definition Settings.cpp:255
static std::string s_assets_prefabs
Definition Settings.hpp:278
static std::string s_assets_texture
Definition Settings.hpp:277
static auto editor_dir() noexcept -> std::filesystem::path
Directory for editor specific stuff.
Definition Settings.cpp:210
static std::string s_assets_music
Definition Settings.hpp:270
static std::string s_assets_sfx
Definition Settings.hpp:271
static auto assets_dir_font() noexcept -> const std::string &
Font asset location.
Definition Settings.cpp:240
static auto assets_dir_maps() noexcept -> const std::string &
Maps asset location.
Definition Settings.cpp:270
static std::string s_assets_video
Definition Settings.hpp:280
static std::string s_assets_ui
Definition Settings.hpp:281
static auto assets_dir() noexcept -> std::filesystem::path
Main data directory.
Definition Settings.cpp:205
static std::string s_asset_pack
Definition Settings.hpp:268
static auto assets_dir_texture() noexcept -> const std::string &
Textures asset location.
Definition Settings.cpp:260
static auto use_loose_assets() noexcept -> bool
Should asset data be read from pack or assets dir.
Definition Settings.cpp:220
static auto assets_dir_music() noexcept -> const std::string &
Music asset location.
Definition Settings.cpp:225
static auto set_config_to_default() -> void
Restore all config settings to default.
Definition Settings.cpp:22
static auto assets_dir_sfx() noexcept -> const std::string &
SFX asset location.
Definition Settings.cpp:230
static std::string s_assets_maps
Definition Settings.hpp:279
static std::string s_assets_shaders
Definition Settings.hpp:275
static auto assets_dir_ui() noexcept -> const std::string &
UI asset location.
Definition Settings.cpp:280
static std::string s_assets_font
Definition Settings.hpp:273
static std::string s_assets_script
Definition Settings.hpp:274