All of the UIs should be cleared out, and that just leaves the tests.
This commit is contained in:
parent
d5ff57e025
commit
564f9842a2
23 changed files with 126 additions and 145 deletions
|
@ -2,13 +2,13 @@
|
|||
#include "constants.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
#include "systems.hpp"
|
||||
#include "game_level.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace guecs;
|
||||
|
||||
LootUI::LootUI(GameLevel level) :
|
||||
$level(level),
|
||||
$temp_loot($level.world->entity()),
|
||||
LootUI::LootUI() :
|
||||
$temp_loot(Game::current_world()->entity()),
|
||||
$target($temp_loot)
|
||||
{
|
||||
$gui.position(RAY_VIEW_X+RAY_VIEW_WIDTH/2-200,
|
||||
|
@ -21,8 +21,9 @@ namespace gui {
|
|||
"[=item_12| =item_13|=item_14|=item_15 ]"
|
||||
"[ =take_all | =close| =destroy]");
|
||||
|
||||
$level.world->set<inventory::Model>($temp_loot, {});
|
||||
$level.world->make_constant($temp_loot);
|
||||
auto world = Game::current_world();
|
||||
world->set<inventory::Model>($temp_loot, {});
|
||||
world->make_constant($temp_loot);
|
||||
}
|
||||
|
||||
void LootUI::make_button(const std::string &name, const std::wstring& label, Events::GUI event) {
|
||||
|
@ -31,7 +32,7 @@ namespace gui {
|
|||
$gui.set<guecs::Rectangle>(button, {});
|
||||
$gui.set<guecs::Text>(button, {label});
|
||||
$gui.set<guecs::Clickable>(button,
|
||||
guecs::make_action($level, button, event));
|
||||
guecs::make_action(button, event));
|
||||
}
|
||||
|
||||
void LootUI::init() {
|
||||
|
@ -52,7 +53,7 @@ namespace gui {
|
|||
THEME.TRANSPARENT, THEME.LIGHT_MID });
|
||||
$gui.set<guecs::Effect>(id, {0.4f, "ui_shader"});
|
||||
$gui.set<guecs::Clickable>(id, {
|
||||
guecs::make_action($level, id, Events::GUI::LOOT_SELECT, {id})
|
||||
guecs::make_action(id, Events::GUI::LOOT_SELECT, {id})
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -61,10 +62,12 @@ namespace gui {
|
|||
}
|
||||
|
||||
void LootUI::update() {
|
||||
dbc::check($level.world->has<inventory::Model>($target),
|
||||
auto world = Game::current_world();
|
||||
|
||||
dbc::check(world->has<inventory::Model>($target),
|
||||
"update called but $target isn't in world");
|
||||
|
||||
auto& contents = $level.world->get<inventory::Model>($target);
|
||||
auto& contents = world->get<inventory::Model>($target);
|
||||
|
||||
for(size_t i = 0; i < INV_SLOTS; i++) {
|
||||
auto id = $gui.entity("item_", int(i));
|
||||
|
@ -72,9 +75,9 @@ namespace gui {
|
|||
|
||||
if(contents.has(slot_name)) {
|
||||
auto item = contents.get(slot_name);
|
||||
dbc::check($level.world->has<components::Sprite>(item),
|
||||
dbc::check(world->has<components::Sprite>(item),
|
||||
"item in inventory UI doesn't exist in world. New level?");
|
||||
auto& sprite = $level.world->get<components::Sprite>(item);
|
||||
auto& sprite = world->get<components::Sprite>(item);
|
||||
$gui.set_init<guecs::Icon>(id, {sprite.name});
|
||||
|
||||
guecs::GrabSource grabber{
|
||||
|
@ -98,7 +101,7 @@ namespace gui {
|
|||
void LootUI::remove_slot(guecs::Entity slot_id) {
|
||||
auto& name = $gui.name_for(slot_id);
|
||||
fmt::println("LootUI remove slot inv::Model id={} slot={}", $target, name);
|
||||
System::remove_from_container(*$level.world, $target, name);
|
||||
System::remove_from_container($target, name);
|
||||
update();
|
||||
}
|
||||
|
||||
|
@ -107,7 +110,7 @@ namespace gui {
|
|||
$target, id, world_entity);
|
||||
auto& name = $gui.name_for(id);
|
||||
|
||||
bool worked = System::place_in_container(*$level.world, $target, name, world_entity);
|
||||
bool worked = System::place_in_container($target, name, world_entity);
|
||||
if(worked) update();
|
||||
return worked;
|
||||
}
|
||||
|
@ -116,13 +119,12 @@ namespace gui {
|
|||
$gui.render(window);
|
||||
}
|
||||
|
||||
void LootUI::update_level(GameLevel &level) {
|
||||
$level = level;
|
||||
void LootUI::update_level() {
|
||||
init();
|
||||
}
|
||||
|
||||
void LootUI::add_loose_item(DinkyECS::Entity entity) {
|
||||
System::place_in_container(*$level.world, $temp_loot, "item_0", entity);
|
||||
System::place_in_container($temp_loot, "item_0", entity);
|
||||
set_target($temp_loot);
|
||||
update();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue