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>);
71 lua.set_function(
"settings_requested_width", &Settings::requested_width);
72 lua.set_function(
"settings_requested_height", &Settings::requested_height);
73 lua.set_function(
"settings_virtual_width", &Settings::virtual_width);
74 lua.set_function(
"settings_virtual_height", &Settings::virtual_height);
75 lua.set_function(
"settings_window_icon", &Settings::icon);
76 lua.set_function(
"settings_fullscreen", &Settings::fullscreen);
77 lua.set_function(
"settings_maximized", &Settings::maximized);
79 lua.set_function(
"settings_window_resizable", &Settings::window_resizable);
80 lua.set_function(
"settings_mouse_grabbed", &Settings::mouse_grabbed);
115 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.
Handles events, input & display.
void set_fullscreen(const bool fullscreen) const noexcept
Toggle fullscreen.
int screen_width() const noexcept
Return the current drawable width in pixels.
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.
int virtual_screen_height() const noexcept
Return the configured logical screen height.
int virtual_screen_width() const noexcept
Return the configured logical screen width.
void append_title(const std::string &append)
Append to window title from the settings.
void close() noexcept
Close window.
void set_taskbar_progress(const float progress) noexcept
Sets the taskbar icon progress overlay.
void hide() const noexcept
Hide window.
void show() const noexcept
Show window.
float get_display_scale() const noexcept
Get display content scale.
void minimize() const noexcept
Minimize window.
int screen_height() const noexcept
Return the current drawable height in pixels.
void set_icon(const std::string &icon) noexcept
Set window icon.
void set_title(const std::string &title)
Set window title.
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 root_dir() noexcept -> std::filesystem::path
Current root directory of application, unless it has been changed.
static auto logs_dir() noexcept -> const std::string &
Current root directory of application, unless it has been changed.
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 assets_dir_shaders() noexcept -> const std::string &
Shaders asset location.
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 identifier() noexcept -> const std::string &
Game identifier i.e. com.galaxy.app.
static auto title() noexcept -> const std::string &
Game title.
static auto assets_dir() noexcept -> std::filesystem::path
Main data directory.
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 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 assets_dir_font() noexcept -> const std::string &
Font asset location.
static auto creator() noexcept -> const std::string &
Owner.