8#include <entt/locator/locator.hpp>
35 auto& lua = entt::locator<sol::state>::value();
37 auto config_type = lua.new_usertype<
Config>(
"Config", sol::no_constructor);
40 config_type[
"set_bool"] = sol::resolve<void(const std::string&, const bool&)>(&
Config::set<bool>);
41 config_type[
"set_int"] = sol::resolve<void(const std::string&, const int&)>(&
Config::set<int>);
42 config_type[
"set_float"] = sol::resolve<void(const std::string&, const float&)>(&
Config::set<float>);
44 config_type[
"set_section_bool"] = sol::resolve<void(const std::string&, const bool&, const std::string&, const std::string&)>(&
Config::set<bool>);
45 config_type[
"set_section_int"] = sol::resolve<void(const std::string&, const int&, const std::string&, const std::string&)>(&
Config::set<int>);
46 config_type[
"set_section_float"] = sol::resolve<void(const std::string&, const float&, const std::string&, const std::string&)>(&
Config::set<float>);
47 config_type[
"set_section_string"] = sol::resolve<void(const std::string&, const std::string&, const std::string&, const std::string&)>(&
Config::set<std::string>);
48 config_type[
"restore_bool"] = sol::resolve<void(const std::string&, const bool&)>(&
Config::restore<bool>);
49 config_type[
"restore_int"] = sol::resolve<void(const std::string&, const int&)>(&
Config::restore<int>);
50 config_type[
"restore_float"] = sol::resolve<void(const std::string&, const float&)>(&
Config::restore<float>);
52 config_type[
"restore_section_bool"] = sol::resolve<void(const std::string&, const bool&, const std::string&, const std::string&)>(&
Config::restore<bool>);
53 config_type[
"restore_section_int"] = sol::resolve<void(const std::string&, const int&, const std::string&, const std::string&)>(&
Config::restore<int>);
54 config_type[
"restore_section_float"] = sol::resolve<void(const std::string&, const float&, const std::string&, const std::string&)>(&
Config::restore<float>);
55 config_type[
"restore_section_string"] = sol::resolve<void(const std::string&, const std::string&, const std::string&, const std::string&)>(&
Config::restore<std::string>);
56 config_type[
"has"] = sol::resolve<bool(const std::string&)>(&
Config::has);
57 config_type[
"has_section"] = sol::resolve<bool(const std::string&, const std::string&, const std::string&)>(&
Config::has);
58 config_type[
"get_bool"] = sol::resolve<std::optional<bool>(
const std::string&)>(&
Config::get<bool>);
59 config_type[
"get_int"] = sol::resolve<std::optional<int>(
const std::string&)>(&
Config::get<int>);
60 config_type[
"get_float"] = sol::resolve<std::optional<float>(
const std::string&)>(&
Config::get<float>);
62 config_type[
"get_section_int"] = sol::resolve<std::optional<int>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<int>);
63 config_type[
"get_section_float"] = sol::resolve<std::optional<float>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<float>);
64 config_type[
"get_section_string"] = sol::resolve<std::optional<std::string>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<std::string>);
65 config_type[
"get_section_bool"] = sol::resolve<std::optional<bool>(
const std::string&,
const std::string&,
const std::string&)>(&
Config::get<bool>);
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.
std::string assets_path_wrapper() noexcept
std::string root_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 assets_dir_texture() noexcept -> const std::string &
Textures asset location.
static auto vsync() noexcept -> bool
Vsync control.
static auto minimized() noexcept -> bool
Is window started minimized?
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 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 maximized() noexcept -> bool
Is window started maximized?
static auto title() noexcept -> const std::string &
Game title.
static auto assets_dir() noexcept -> std::filesystem::path
Main data directory.
static auto ontop() noexcept -> bool
Should the window always be on top.
static auto asset_pack() noexcept -> const std::string &
Name of packed assets file.
static auto borderless_fullscreen() noexcept -> bool
Is window in borderless fullscreen?
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 assets_dir_video() noexcept -> const std::string &
Video asset location.
static auto assets_dir_font() noexcept -> const std::string &
Font asset location.
static auto decoration() noexcept -> bool
Controls if a window has a border around it (including titlebar).