lel-guecs/src/guecs/sfml/backend.cpp

59 lines
1.4 KiB
C++

#include "guecs/sfml/backend.hpp"
#include "guecs/sfml/shaders.hpp"
#include "guecs/sfml/sound.hpp"
#include "guecs/sfml/textures.hpp"
namespace sfml {
guecs::SpriteTexture Backend::get_sprite(const string& name) {
auto sp = textures::get(name);
return {sp.sprite, sp.texture, sp.frame_size};
}
guecs::SpriteTexture Backend::get_icon(const string& name) {
return get_sprite(name);
}
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::get_shader(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() {
guecs::Theme theme;
theme.PADDING = 3;
theme.BORDER_PX = 1;
theme.TEXT_SIZE = 30;
theme.LABEL_SIZE = 20;
theme.FILL_COLOR = theme.DARK_MID;
theme.TEXT_COLOR = theme.LIGHT_LIGHT;
theme.BG_COLOR = theme.DARK_DARK;
theme.BORDER_COLOR = theme.DARK_LIGHT;
theme.BG_COLOR_DARK = theme.BLACK;
theme.FONT_FILE_NAME = "assets/text.otf";
return theme;
}
}