Move the management of the 'fake loose items container' into the loot_ui.cpp rather than get rid of it. Closes #34.

This commit is contained in:
Zed A. Shaw 2025-07-01 14:26:39 -04:00
parent efdb0cb119
commit b6d1ae2700
5 changed files with 24 additions and 24 deletions

View file

@ -27,8 +27,7 @@ namespace gui {
$mini_map($level),
$loot_ui($level),
$font{FONT_FILE_NAME},
$dnd_loot($status_ui, $loot_ui, $window, $router),
$temp_loot($level.world->entity())
$dnd_loot($status_ui, $loot_ui, $window, $router)
{
$window.setPosition({0,0});
}
@ -67,8 +66,6 @@ namespace gui {
$map_ui.log(L"Welcome to the game!");
$mini_map.init($main_ui.$overlay_ui.$gui);
$level.world->set<inventory::Model>($temp_loot, {});
run_systems();
state(State::IDLE);
@ -344,7 +341,8 @@ namespace gui {
autowalking = true;
break;
case KEY::L:
$loot_ui.set_target($temp_loot);
// This will go away as soon as containers work
$loot_ui.set_target($loot_ui.$temp_loot);
$loot_ui.update();
event(Event::LOOT_OPEN);
break;
@ -477,15 +475,12 @@ namespace gui {
case eGUI::LOOT_ITEM: {
dbc::check(world.has<components::InventoryItem>(entity),
"INVALID LOOT_ITEM, that entity has no InventoryItem");
fmt::println("in FSM LOOT_ITEM the entity is {}", entity);
System::place_in_container(*$level.world, $temp_loot, "item_0", entity);
$loot_ui.set_target($temp_loot);
$loot_ui.update();
$loot_ui.add_loose_item(entity);
event(Event::LOOT_ITEM);
} break;
case eGUI::LOOT_CONTAINER: {
dbc::log("YEP container works.");
$loot_ui.set_target($temp_loot);
$loot_ui.set_target($loot_ui.$temp_loot);
$loot_ui.update();
event(Event::LOOT_OPEN);
} break;
@ -524,10 +519,6 @@ namespace gui {
$levels.create_level($level.world);
$level = $levels.next();
// this has to go away, but clear out the inventory
$temp_loot = $level.world->entity();
$level.world->set<inventory::Model>($temp_loot, {});
$status_ui.update_level($level);
$map_ui.update_level($level);
$mini_map.update_level($level);