8#include <entt/locator/locator.hpp>
36 auto& lua = entt::locator<sol::state>::value();
38 auto config_type = lua.new_usertype<
Config>(
"Config", sol::no_constructor);
41 config_type[
"set_bool"] = sol::resolve<void(const std::string&, const bool&)>(&
Config::set<bool>);
42 config_type[
"set_int"] = sol::resolve<void(const std::string&, const int&)>(&
Config::set<int>);
43 config_type[
"set_float"] = sol::resolve<void(const std::string&, const float&)>(&
Config::set<float>);
45 config_type[
"set_section_bool"] = sol::resolve<void(const std::string&, const bool&, const std::string&, const std::string&)>(&
Config::set<bool>);
46 config_type[
"set_section_int"] = sol::resolve<void(const std::string&, const int&, const std::string&, const std::string&)>(&
Config::set<int>);
47 config_type[
"set_section_float"] = sol::resolve<void(const std::string&, const float&, const std::string&, const std::string&)>(&
Config::set<float>);
48 config_type[
"set_section_string"] = sol::resolve<void(const std::string&, const std::string&, const std::string&, const std::string&)>(&
Config::set<std::string>);
49 config_type[
"restore_bool"] = sol::resolve<void(const std::string&, const bool&)>(&
Config::restore<bool>);
50 config_type[
"restore_int"] = sol::resolve<void(const std::string&, const int&)>(&
Config::restore<int>);
51 config_type[
"restore_float"] = sol::resolve<void(const std::string&, const float&)>(&
Config::restore<float>);
53 config_type[
"restore_section_bool"] = sol::resolve<void(const std::string&, const bool&, const std::string&, const std::string&)>(&
Config::restore<bool>);
54 config_type[
"restore_section_int"] = sol::resolve<void(const std::string&, const int&, const std::string&, const std::string&)>(&
Config::restore<int>);
55 config_type[
"restore_section_float"] = sol::resolve<void(const std::string&, const float&, const std::string&, const std::string&)>(&
Config::restore<float>);
56 config_type[
"restore_section_string"] = sol::resolve<void(const std::string&, const std::string&, const std::string&, const std::string&)>(&
Config::restore<std::string>);
57 config_type[
"has"] = sol::resolve<bool(const std::string&)>(&
Config::has);
58 config_type[
"has_section"] = sol::resolve<bool(const std::string&, const std::string&, const std::string&)>(&
Config::has);
59 config_type[
"get_bool"] = sol::resolve<std::optional<bool>(
const std::string&)>(&
Config::get<bool>);
60 config_type[
"get_int"] = sol::resolve<std::optional<int>(
const std::string&)>(&
Config::get<int>);
61 config_type[
"get_float"] = sol::resolve<std::optional<float>(
const std::string&)>(&
Config::get<float>);
63 config_type[
"get_section_int"] = sol::resolve<std::optional<int>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<int>);
64 config_type[
"get_section_float"] = sol::resolve<std::optional<float>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<float>);
65 config_type[
"get_section_string"] = sol::resolve<std::optional<std::string>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<std::string>);
66 config_type[
"get_section_bool"] = sol::resolve<std::optional<bool>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<bool>);
109 auto window_type = lua.new_usertype<
Window>(
"Window", sol::no_constructor);
Allows you to read, write and manipulate JSON config files.
void save()
Save the config file. Must be opened first.
void load(std::string_view file)
Loads config json from disk.
std::optional< Value > get(const std::string &key)
Retrieve a root config value.
void restore(const std::string &key, const Value &value) noexcept
Sets a new setting, only if key or value does not already exist.
bool empty() const
Is the config file blank.
void set(const std::string &key, const Value &value) noexcept
Set a new key-value pair for the config.
bool has(const std::string &key) noexcept
Check if the config file actually has a value.
static void inject_core() noexcept
Inject galaxy core services into Lua.
RAII Window. Handles events, input & display.
void set_fullscreen(const bool fullscreen) const noexcept
Toggle fullscreen.
bool is_open() const noexcept
Is the window open or closed.
void raise() const noexcept
Raise the window to be on top of other windows.
void resize(const int width, const int height) const noexcept
Resizes window.
void maximize() const noexcept
Maximize window.
Keyboard & get_keyboard() noexcept
Get keyboard.
void append_title(const std::string &append)
Append to window title.
void close() noexcept
Close window.
void set_taskbar_progress(const float progress) noexcept
Sets the taskbar icon progress overlay.
glm::ivec2 get_pixel_size() noexcept
Get window size in pixels.
void hide() const noexcept
Hide window.
void show() const noexcept
Show window.
void minimize() const noexcept
Minimize window.
Mouse & get_mouse() noexcept
Get mouse cursor.
void set_icon(const std::string &icon) noexcept
Set window icon.
void request_attention() const noexcept
Flash window on taskbar for user attention.
void restore() const noexcept
Restore window to previous *mize state.
std::string assets_path_wrapper() noexcept
std::string root_path_wrapper() noexcept
std::string editor_path_wrapper() noexcept
static auto window_icon() noexcept -> const std::string &
Window icon file in vfs.
static auto root_dir() noexcept -> std::filesystem::path
Current root directory of application, unless it has been changed.
static auto window_height() noexcept -> int
Window creation height.
static auto log_dir() noexcept -> const std::string &
Current root directory of application, unless it has been changed.
static auto fullscreen() noexcept -> bool
Is window started fullscreen.
static auto assets_dir_prefabs() noexcept -> const std::string &
Prefab asset location.
static auto copyright() noexcept -> const std::string &
Copyright message.
static auto assets_dir_texture() noexcept -> const std::string &
Textures asset location.
static auto vsync() noexcept -> bool
Vsync control.
static auto assets_dir_voice() noexcept -> const std::string &
Voice asset location.
static auto window_width() noexcept -> int
Window creation width.
static auto assets_dir_shaders() noexcept -> const std::string &
Shaders asset location.
static auto window_border() noexcept -> bool
Controls if a window has a border around it (including titlebar).
static auto assets_dir_ui() noexcept -> const std::string &
UI asset location.
static auto set_settings_from_config() -> void
Set all our settings using the provided config file.
static auto use_loose_assets() noexcept -> bool
Should asset data be read from pack or assets dir.
static auto assets_dir_animation() noexcept -> const std::string &
Animation data location.
static auto assets_dir_script() noexcept -> const std::string &
Scripts asset location.
static auto assets_dir_music() noexcept -> const std::string &
Music asset location.
static auto window_resizable() noexcept -> bool
Is the window resizable.
static auto identifier() noexcept -> const std::string &
Game identifier i.e. com.galaxy.app.
static auto maximized() noexcept -> bool
Is window started maximized?
static auto title() noexcept -> const std::string &
Game title.
static auto cursor_show() noexcept -> bool
Is the mouse cursor visible or not.
static auto assets_dir() noexcept -> std::filesystem::path
Main data directory.
static auto cursor_hotspot() noexcept -> const glm::ivec2 &
Cursor selector point (hotspot).
static auto asset_pack() noexcept -> const std::string &
Name of packed assets file.
static auto version() noexcept -> const std::string &
Game semver.
static auto audio_freq() noexcept -> int
Set audio frequency to use with SDL.
static auto mouse_grabbed() noexcept -> bool
Is the cursor grabbed.
static auto website() noexcept -> const std::string &
Website URL.
static auto assets_dir_sfx() noexcept -> const std::string &
SFX asset location.
static auto assets_dir_maps() noexcept -> const std::string &
Maps asset location.
static auto set_config_to_default() -> void
Restore all config settings to default.
static auto editor_dir() noexcept -> std::filesystem::path
Directory for editor specific stuff.
static auto assets_dir_video() noexcept -> const std::string &
Video asset location.
static auto cursor_icon() noexcept -> const std::string &
Cursor texture file in vfs.
static auto assets_dir_font() noexcept -> const std::string &
Font asset location.
static auto creator() noexcept -> const std::string &
Owner.