A retro style homage to 80s dungeon crawlers hand crafted in C++.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
raycaster/backend.cpp

73 lines
2.1 KiB

#include "backend.hpp"
#include "shaders.hpp"
#include "sound.hpp"
#include "textures.hpp"
#include "config.hpp"
#include "palette.hpp"
namespace sfml {
using namespace nlohmann;
guecs::SpriteTexture Backend::texture_get(const string& name) {
auto sp = textures::get(name);
return {sp.sprite, sp.texture};
}
Backend::Backend() {
sound::init();
shaders::init();
textures::init();
}
void Backend::sound_play(const string& name) {
sound::play(name);
}
void Backend::sound_stop(const string& name) {
sound::stop(name);
}
std::shared_ptr<sf::Shader> Backend::shader_get(const std::string& name) {
return shaders::get(name);
}
bool Backend::shader_updated() {
if(shaders::updated($shaders_version)) {
$shaders_version = shaders::version();
return true;
} else {
return false;
}
}
guecs::Theme Backend::theme() {
palette::init();
auto config = Config("assets/config.json")["theme"];
guecs::Theme theme {
.BLACK=palette::get("gui/theme:black"),
.DARK_DARK=palette::get("gui/theme:dark_dark"),
.DARK_MID=palette::get("gui/theme:dark_mid"),
.DARK_LIGHT=palette::get("gui/theme:dark_light"),
.MID=palette::get("gui/theme:mid"),
.LIGHT_DARK=palette::get("gui/theme:light_dark"),
.LIGHT_MID=palette::get("gui/theme:light_mid"),
.LIGHT_LIGHT=palette::get("gui/theme:light_light"),
.WHITE=palette::get("gui/theme:white"),
.TRANSPARENT = palette::get("color:transparent")
};
theme.PADDING = config["padding"];
theme.BORDER_PX = config["border_px"];
theme.TEXT_SIZE = config["text_size"];
theme.LABEL_SIZE = config["label_size"];
theme.FILL_COLOR = palette::get("gui/theme:fill_color");
theme.TEXT_COLOR = palette::get("gui/theme:text_color");
theme.BG_COLOR = palette::get("gui/theme:bg_color");
theme.BORDER_COLOR = palette::get("gui/theme:border_color");
theme.BG_COLOR_DARK = palette::get("gui/theme:bg_color_dark");
theme.FONT_FILE_NAME = Config::path_to(config["font_file_name"]).string();
return theme;
}
}