parent
c47526499a
commit
59e75e9403
@ -0,0 +1,33 @@ |
|||||||
|
#include "backend.hpp" |
||||||
|
#include "dbc.hpp" |
||||||
|
|
||||||
|
namespace gui { |
||||||
|
guecs::SpriteTexture Backend::get_sprite(const std::string& file_path) { |
||||||
|
auto texture = std::make_shared<sf::Texture>(); |
||||||
|
bool good = texture->loadFromFile(file_path); |
||||||
|
dbc::check(good, fmt::format("failed to load image {}", file_path)); |
||||||
|
|
||||||
|
texture->setSmooth(false); |
||||||
|
|
||||||
|
auto sprite = std::make_shared<sf::Sprite>(*texture); |
||||||
|
auto size = texture->getSize(); |
||||||
|
return {sprite, texture, {int(size.x), int(size.y)}}; |
||||||
|
} |
||||||
|
|
||||||
|
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; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,14 @@ |
|||||||
|
#pragma once |
||||||
|
#include "guecs/ui.hpp" |
||||||
|
#include "guecs/sfml/backend.hpp" |
||||||
|
#include <string> |
||||||
|
|
||||||
|
namespace gui { |
||||||
|
class Backend : public sfml::Backend { |
||||||
|
int $shaders_version = 0; |
||||||
|
|
||||||
|
public: |
||||||
|
guecs::SpriteTexture get_sprite(const std::string& name) override; |
||||||
|
guecs::Theme theme() override; |
||||||
|
}; |
||||||
|
} |
||||||
Loading…
Reference in new issue