AI is now moved.
This commit is contained in:
parent
1d4ae911b9
commit
13ec422aae
25 changed files with 65 additions and 48 deletions
78
src/gui/backend.cpp
Normal file
78
src/gui/backend.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
#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::get_sprite(const string& name) {
|
||||
auto sp = textures::get_sprite(name);
|
||||
return {sp.sprite, sp.texture, sp.frame_size};
|
||||
}
|
||||
|
||||
guecs::SpriteTexture Backend::get_icon(const string& name) {
|
||||
auto sp = textures::get_icon(name);
|
||||
return {sp.sprite, sp.texture, sp.frame_size};
|
||||
}
|
||||
|
||||
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() {
|
||||
palette::init();
|
||||
auto config = settings::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 = settings::Config::path_to(config["font_file_name"]).string();
|
||||
|
||||
return theme;
|
||||
}
|
||||
}
|
||||
20
src/gui/backend.hpp
Normal file
20
src/gui/backend.hpp
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
#include "guecs/ui.hpp"
|
||||
|
||||
namespace sfml {
|
||||
using std::string;
|
||||
|
||||
class Backend : public guecs::Backend {
|
||||
int $shaders_version = 0;
|
||||
|
||||
public:
|
||||
|
||||
Backend();
|
||||
guecs::SpriteTexture get_sprite(const string& name);
|
||||
guecs::SpriteTexture get_icon(const string& name);
|
||||
void sound_play(const string& name);
|
||||
void sound_stop(const string& name);
|
||||
std::shared_ptr<sf::Shader> get_shader(const std::string& name);
|
||||
bool shader_updated();
|
||||
guecs::Theme theme();
|
||||
};
|
||||
}
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
#include "animation.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "game_level.hpp"
|
||||
#include "ai.hpp"
|
||||
#include "ai/ai.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace components;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue