#include "status_ui.hpp" #include "components.hpp" #include "color.hpp" #include "guecs.hpp" namespace gui { using namespace guecs; StatusUI::StatusUI(GameLevel level) : $level(level) { $gui.position(STATUS_UI_X, STATUS_UI_Y, STATUS_UI_WIDTH, STATUS_UI_HEIGHT); $gui.layout("[log_view]"); } void StatusUI::render(TexturePack &textures) { auto& world = $gui.world(); auto& cell = $gui.cells().at("log_view"); $log_to = $gui.entity("log_view"); world.set($log_to, cell); world.set($log_to, {}); world.set($log_to, {"TEST"}); $gui.init(textures); } void StatusUI::draw(sf::RenderWindow &window) { auto &world = $gui.world(); auto &text = world.get($log_to); std::string log; for(auto msg : $messages) { log += msg + "\n"; } text.label = log; $gui.render(window); } void StatusUI::log(std::string msg) { $messages.push_front(msg); if($messages.size() > MAX_LOG_MESSAGES) { $messages.pop_back(); } } }