You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.3 KiB
51 lines
1.3 KiB
#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);
|
|
}
|
|
}
|
|
|