|
|
@ -3,6 +3,7 @@ |
|
|
|
#include "sound.hpp" |
|
|
|
#include "sound.hpp" |
|
|
|
#include "textures.hpp" |
|
|
|
#include "textures.hpp" |
|
|
|
#include "config.hpp" |
|
|
|
#include "config.hpp" |
|
|
|
|
|
|
|
#include "palette.hpp" |
|
|
|
|
|
|
|
|
|
|
|
namespace sfml { |
|
|
|
namespace sfml { |
|
|
|
using namespace nlohmann; |
|
|
|
using namespace nlohmann; |
|
|
@ -39,46 +40,32 @@ namespace sfml { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
inline sf::Color to_color(json& config, const std::string& name) { |
|
|
|
|
|
|
|
json& val = config[name]; |
|
|
|
|
|
|
|
if(val.type() == json::value_t::array) { |
|
|
|
|
|
|
|
return sf::Color{val[0], val[1], val[2], val[3]}; |
|
|
|
|
|
|
|
} else if(val.type() == json::value_t::string) { |
|
|
|
|
|
|
|
json& array = config[val]; |
|
|
|
|
|
|
|
return sf::Color{array[0], array[1], array[2], array[3]}; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
dbc::sentinel(fmt::format( |
|
|
|
|
|
|
|
"theme config {} has invalid color setting," |
|
|
|
|
|
|
|
"either use an array of 4 ints or a string" |
|
|
|
|
|
|
|
"referencing another config with 4 ints.", name)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
guecs::Theme Backend::theme() { |
|
|
|
guecs::Theme Backend::theme() { |
|
|
|
|
|
|
|
palette::init(); |
|
|
|
auto config = Config("assets/config.json")["theme"]; |
|
|
|
auto config = Config("assets/config.json")["theme"]; |
|
|
|
|
|
|
|
|
|
|
|
guecs::Theme theme { |
|
|
|
guecs::Theme theme { |
|
|
|
.BLACK=to_color(config, "black"), |
|
|
|
.BLACK=palette::get("gui/theme:black"), |
|
|
|
.DARK_DARK=to_color(config, "dark_dark"), |
|
|
|
.DARK_DARK=palette::get("gui/theme:dark_dark"), |
|
|
|
.DARK_MID=to_color(config, "dark_mid"), |
|
|
|
.DARK_MID=palette::get("gui/theme:dark_mid"), |
|
|
|
.DARK_LIGHT=to_color(config, "dark_light"), |
|
|
|
.DARK_LIGHT=palette::get("gui/theme:dark_light"), |
|
|
|
.MID=to_color(config, "mid"), |
|
|
|
.MID=palette::get("gui/theme:mid"), |
|
|
|
.LIGHT_DARK=to_color(config, "light_dark"), |
|
|
|
.LIGHT_DARK=palette::get("gui/theme:light_dark"), |
|
|
|
.LIGHT_MID=to_color(config, "light_mid"), |
|
|
|
.LIGHT_MID=palette::get("gui/theme:light_mid"), |
|
|
|
.LIGHT_LIGHT=to_color(config, "light_light"), |
|
|
|
.LIGHT_LIGHT=palette::get("gui/theme:light_light"), |
|
|
|
.WHITE=to_color(config, "white"), |
|
|
|
.WHITE=palette::get("gui/theme:white"), |
|
|
|
.TRANSPARENT = sf::Color::Transparent |
|
|
|
.TRANSPARENT = palette::get("color:transparent") |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
theme.PADDING = config["padding"]; |
|
|
|
theme.PADDING = config["padding"]; |
|
|
|
theme.BORDER_PX = config["border_px"]; |
|
|
|
theme.BORDER_PX = config["border_px"]; |
|
|
|
theme.TEXT_SIZE = config["text_size"]; |
|
|
|
theme.TEXT_SIZE = config["text_size"]; |
|
|
|
theme.LABEL_SIZE = config["label_size"]; |
|
|
|
theme.LABEL_SIZE = config["label_size"]; |
|
|
|
theme.FILL_COLOR = to_color(config, "fill_color"); |
|
|
|
theme.FILL_COLOR = palette::get("gui/theme:fill_color"); |
|
|
|
theme.TEXT_COLOR = to_color(config, "text_color"); |
|
|
|
theme.TEXT_COLOR = palette::get("gui/theme:text_color"); |
|
|
|
theme.BG_COLOR = to_color(config, "bg_color"); |
|
|
|
theme.BG_COLOR = palette::get("gui/theme:bg_color"); |
|
|
|
theme.BORDER_COLOR = to_color(config, "border_color"); |
|
|
|
theme.BORDER_COLOR = palette::get("gui/theme:border_color"); |
|
|
|
theme.BG_COLOR_DARK = to_color(config, "bg_color_dark"); |
|
|
|
theme.BG_COLOR_DARK = palette::get("gui/theme:bg_color_dark"); |
|
|
|
theme.FONT_FILE_NAME = Config::path_to(config["font_file_name"]).string(); |
|
|
|
theme.FONT_FILE_NAME = Config::path_to(config["font_file_name"]).string(); |
|
|
|
|
|
|
|
|
|
|
|
return theme; |
|
|
|
return theme; |
|
|
|