Simple Loot UI started.
This commit is contained in:
parent
8a3046e141
commit
8545b8cf1d
23 changed files with 139 additions and 29 deletions
51
gui/loot_ui.cpp
Normal file
51
gui/loot_ui.cpp
Normal file
|
@ -0,0 +1,51 @@
|
|||
#include "gui/loot_ui.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "color.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
#include "guecstra.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace guecs;
|
||||
|
||||
LootUI::LootUI(GameLevel level) :
|
||||
$level(level)
|
||||
{
|
||||
$gui.position(RAY_VIEW_X+RAY_VIEW_WIDTH/2-200,
|
||||
RAY_VIEW_Y+RAY_VIEW_HEIGHT/2-200, 400, 400);
|
||||
|
||||
$gui.layout(
|
||||
"[button_0 | button_1|button_2 | button_3]"
|
||||
"[button_4 | button_5|button_6 | button_7]"
|
||||
"[button_8 | button_9|button_10 | button_11]"
|
||||
"[button_12 | button_13|button_14 | button_15]"
|
||||
);
|
||||
}
|
||||
|
||||
void LootUI::init() {
|
||||
$gui.set<Background>($gui.MAIN, {$gui.$parser, ColorValue::DARK_MID});
|
||||
for(auto [name, cell] : $gui.cells()) {
|
||||
auto id = $gui.entity(name);
|
||||
$gui.set<guecs::Rectangle>(id, {});
|
||||
if(id < 4) {
|
||||
$gui.set<guecs::Clickable>(id, {
|
||||
[=](auto, auto) { fmt::println("clicked {}", name); }
|
||||
});
|
||||
$gui.set<guecs::Sprite>(id, {"broken_yoyo-64"});
|
||||
}
|
||||
}
|
||||
$gui.init();
|
||||
}
|
||||
|
||||
void LootUI::render(sf::RenderWindow& window) {
|
||||
$gui.render(window);
|
||||
}
|
||||
|
||||
void LootUI::update_level(GameLevel &level) {
|
||||
$level = level;
|
||||
init();
|
||||
}
|
||||
|
||||
bool LootUI::mouse(float x, float y, bool hover) {
|
||||
return $gui.mouse(x, y, hover);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue