diff --git a/src/gui/body_ui.cpp b/src/gui/body_ui.cpp new file mode 100644 index 0000000..0786c8f --- /dev/null +++ b/src/gui/body_ui.cpp @@ -0,0 +1,52 @@ +#include "gui/body_ui.hpp" +#include "game/components.hpp" +#include +#include "algos/rand.hpp" +#include +#include "gui/guecstra.hpp" +#include "game/systems.hpp" +#include "game/inventory.hpp" +#include "game/level.hpp" + +namespace gui { + using namespace guecs; + using std::any, std::any_cast, std::string, std::make_any; + + void BodyUI::init(size_t x, size_t y, size_t width, size_t height) { + $gui.position(x, y, width, height); + $gui.layout( + "[body_head]" + "[body_chest]" + "[body_right_arm]" + "[body_left_arm]" + "[body_stomach]" + "[body_left_leg]" + "[body_right_leg]"); + + $gui.set($gui.MAIN, {$gui.$parser, }); + + for(auto& [name, cell] : $gui.cells()) { + auto gui_id = $gui.entity(name); + + $gui.set(gui_id, {guecs::to_wstring(name)}); + $gui.set(gui_id, {1.0f, THEME.DARK_MID, {}}); + } + + $gui.init(); + update(); + } + + bool BodyUI::mouse(float x, float y, guecs::Modifiers mods) { + return $gui.mouse(x, y, mods); + } + + void BodyUI::update() { + auto world = GameDB::current_world(); + auto player = world->get_the(); + } + + void BodyUI::render(sf::RenderWindow &window) { + $gui.render(window); + // $gui.debug_layout(window); + } +} diff --git a/src/gui/body_ui.hpp b/src/gui/body_ui.hpp new file mode 100644 index 0000000..99b048e --- /dev/null +++ b/src/gui/body_ui.hpp @@ -0,0 +1,18 @@ +#pragma once +#include "constants.hpp" +#include +#include "graphics/textures.hpp" +#include +#include "gui/guecstra.hpp" + +namespace gui { + class BodyUI { + public: + guecs::UI $gui{}; + + void init(size_t x, size_t y, size_t width, size_t height); + void render(sf::RenderWindow &window); + void update(); + bool mouse(float x, float y, guecs::Modifiers mods); + }; +} diff --git a/src/gui/status_ui.cpp b/src/gui/status_ui.cpp index 7dd689e..f028de2 100644 --- a/src/gui/status_ui.cpp +++ b/src/gui/status_ui.cpp @@ -16,13 +16,8 @@ namespace gui { { $gui.position(x, y, width, height); $gui.layout( - "[=body_head]" - "[=body_chest]" - "[=body_right_arm]" - "[=body_left_arm]" - "[=body_stomach]" - "[=body_left_leg]" - "[=body_right_leg]" + "[*%(100, 200)body_ui]" + "[_]" "[=inv0|=inv1|=inv2]" "[=inv3|=inv4|=inv5]" "[=inv6|=inv7|=inv8]" @@ -36,11 +31,11 @@ namespace gui { for(auto& [name, cell] : $gui.cells()) { auto gui_id = $gui.entity(name); - $gui.set(gui_id, {guecs::to_wstring(name)}); if(name.starts_with("body_")) { - $gui.set(gui_id, {}); + auto& cell = $gui.cell_for(name); + $body_ui.init(cell.x, cell.y, cell.w, cell.h); } else { $gui.set(gui_id, {}); $gui.set(gui_id, { @@ -67,6 +62,8 @@ namespace gui { auto player = world->get_the(); auto& inventory = world->get(player.entity); + $body_ui.update(); + for(const auto& [slot, cell] : $gui.cells()) { if(inventory.has(slot)) { @@ -92,6 +89,7 @@ namespace gui { void StatusUI::render(sf::RenderWindow &window) { $gui.render(window); + $body_ui.render(window); // $gui.debug_layout(window); } diff --git a/src/gui/status_ui.hpp b/src/gui/status_ui.hpp index b64ebcf..233191b 100644 --- a/src/gui/status_ui.hpp +++ b/src/gui/status_ui.hpp @@ -4,11 +4,13 @@ #include "graphics/textures.hpp" #include #include "gui/guecstra.hpp" +#include "gui/body_ui.hpp" namespace gui { class StatusUI { public: - guecs::UI $gui; + guecs::UI $gui{}; + BodyUI $body_ui{}; explicit StatusUI(size_t x, size_t y, size_t width, size_t height); diff --git a/src/meson.build b/src/meson.build index 35ec50d..8017508 100644 --- a/src/meson.build +++ b/src/meson.build @@ -19,6 +19,7 @@ sources = files( 'gui/status_ui.cpp', 'gui/main_ui.cpp', 'gui/overlay_ui.cpp', + 'gui/body_ui.cpp', # graphics 'graphics/animation.cpp',