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:
parent
efdb0cb119
commit
b6d1ae2700
5 changed files with 24 additions and 24 deletions
|
@ -222,8 +222,6 @@ namespace gui {
|
||||||
{
|
{
|
||||||
if(!source_id) return false;
|
if(!source_id) return false;
|
||||||
auto target_id = std::any_cast<guecs::Entity>(data);
|
auto target_id = std::any_cast<guecs::Entity>(data);
|
||||||
fmt::println("!!!!!!!!!source_id = {} target_id = {}",
|
|
||||||
*source_id, target_id);
|
|
||||||
|
|
||||||
dbc::check(target.has<guecs::DropTarget>(target_id),
|
dbc::check(target.has<guecs::DropTarget>(target_id),
|
||||||
"gui does not have a DropTarget at that slot");
|
"gui does not have a DropTarget at that slot");
|
||||||
|
|
19
gui/fsm.cpp
19
gui/fsm.cpp
|
@ -27,8 +27,7 @@ namespace gui {
|
||||||
$mini_map($level),
|
$mini_map($level),
|
||||||
$loot_ui($level),
|
$loot_ui($level),
|
||||||
$font{FONT_FILE_NAME},
|
$font{FONT_FILE_NAME},
|
||||||
$dnd_loot($status_ui, $loot_ui, $window, $router),
|
$dnd_loot($status_ui, $loot_ui, $window, $router)
|
||||||
$temp_loot($level.world->entity())
|
|
||||||
{
|
{
|
||||||
$window.setPosition({0,0});
|
$window.setPosition({0,0});
|
||||||
}
|
}
|
||||||
|
@ -67,8 +66,6 @@ namespace gui {
|
||||||
$map_ui.log(L"Welcome to the game!");
|
$map_ui.log(L"Welcome to the game!");
|
||||||
$mini_map.init($main_ui.$overlay_ui.$gui);
|
$mini_map.init($main_ui.$overlay_ui.$gui);
|
||||||
|
|
||||||
$level.world->set<inventory::Model>($temp_loot, {});
|
|
||||||
|
|
||||||
run_systems();
|
run_systems();
|
||||||
|
|
||||||
state(State::IDLE);
|
state(State::IDLE);
|
||||||
|
@ -344,7 +341,8 @@ namespace gui {
|
||||||
autowalking = true;
|
autowalking = true;
|
||||||
break;
|
break;
|
||||||
case KEY::L:
|
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();
|
$loot_ui.update();
|
||||||
event(Event::LOOT_OPEN);
|
event(Event::LOOT_OPEN);
|
||||||
break;
|
break;
|
||||||
|
@ -477,15 +475,12 @@ namespace gui {
|
||||||
case eGUI::LOOT_ITEM: {
|
case eGUI::LOOT_ITEM: {
|
||||||
dbc::check(world.has<components::InventoryItem>(entity),
|
dbc::check(world.has<components::InventoryItem>(entity),
|
||||||
"INVALID LOOT_ITEM, that entity has no InventoryItem");
|
"INVALID LOOT_ITEM, that entity has no InventoryItem");
|
||||||
fmt::println("in FSM LOOT_ITEM the entity is {}", entity);
|
$loot_ui.add_loose_item(entity);
|
||||||
System::place_in_container(*$level.world, $temp_loot, "item_0", entity);
|
|
||||||
$loot_ui.set_target($temp_loot);
|
|
||||||
$loot_ui.update();
|
|
||||||
event(Event::LOOT_ITEM);
|
event(Event::LOOT_ITEM);
|
||||||
} break;
|
} break;
|
||||||
case eGUI::LOOT_CONTAINER: {
|
case eGUI::LOOT_CONTAINER: {
|
||||||
dbc::log("YEP container works.");
|
dbc::log("YEP container works.");
|
||||||
$loot_ui.set_target($temp_loot);
|
$loot_ui.set_target($loot_ui.$temp_loot);
|
||||||
$loot_ui.update();
|
$loot_ui.update();
|
||||||
event(Event::LOOT_OPEN);
|
event(Event::LOOT_OPEN);
|
||||||
} break;
|
} break;
|
||||||
|
@ -524,10 +519,6 @@ namespace gui {
|
||||||
$levels.create_level($level.world);
|
$levels.create_level($level.world);
|
||||||
$level = $levels.next();
|
$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);
|
$status_ui.update_level($level);
|
||||||
$map_ui.update_level($level);
|
$map_ui.update_level($level);
|
||||||
$mini_map.update_level($level);
|
$mini_map.update_level($level);
|
||||||
|
|
|
@ -49,7 +49,6 @@ namespace gui {
|
||||||
sf::Font $font;
|
sf::Font $font;
|
||||||
gui::routing::Router $router;
|
gui::routing::Router $router;
|
||||||
DNDLoot $dnd_loot;
|
DNDLoot $dnd_loot;
|
||||||
DinkyECS::Entity $temp_loot;
|
|
||||||
|
|
||||||
FSM();
|
FSM();
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,9 @@ namespace gui {
|
||||||
using namespace guecs;
|
using namespace guecs;
|
||||||
|
|
||||||
LootUI::LootUI(GameLevel level) :
|
LootUI::LootUI(GameLevel level) :
|
||||||
$level(level)
|
$level(level),
|
||||||
|
$temp_loot($level.world->entity()),
|
||||||
|
$target($temp_loot)
|
||||||
{
|
{
|
||||||
$gui.position(RAY_VIEW_X+RAY_VIEW_WIDTH/2-200,
|
$gui.position(RAY_VIEW_X+RAY_VIEW_WIDTH/2-200,
|
||||||
RAY_VIEW_Y+RAY_VIEW_HEIGHT/2-200, 400, 400);
|
RAY_VIEW_Y+RAY_VIEW_HEIGHT/2-200, 400, 400);
|
||||||
|
@ -17,8 +19,10 @@ namespace gui {
|
||||||
"[item_4 | item_5 |item_6 | item_7 ]"
|
"[item_4 | item_5 |item_6 | item_7 ]"
|
||||||
"[item_8 | item_9 |item_10| item_11]"
|
"[item_8 | item_9 |item_10| item_11]"
|
||||||
"[item_12| item_13|item_14|item_15 ]"
|
"[item_12| item_13|item_14|item_15 ]"
|
||||||
"[ =take_all | =close| =destroy]"
|
"[ =take_all | =close| =destroy]");
|
||||||
);
|
|
||||||
|
$level.world->set<inventory::Model>($temp_loot, {});
|
||||||
|
$level.world->make_constant($temp_loot);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LootUI::make_button(const std::string &name, const std::wstring& label, Events::GUI event) {
|
void LootUI::make_button(const std::string &name, const std::wstring& label, Events::GUI event) {
|
||||||
|
@ -58,10 +62,8 @@ namespace gui {
|
||||||
}
|
}
|
||||||
|
|
||||||
void LootUI::update() {
|
void LootUI::update() {
|
||||||
if(!$level.world->has<inventory::Model>($target)) {
|
dbc::check($level.world->has<inventory::Model>($target),
|
||||||
dbc::log("NO INV MODEL?!");
|
"update called but $target isn't in world");
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto& contents = $level.world->get<inventory::Model>($target);
|
auto& contents = $level.world->get<inventory::Model>($target);
|
||||||
|
|
||||||
|
@ -119,7 +121,15 @@ namespace gui {
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LootUI::add_loose_item(DinkyECS::Entity entity) {
|
||||||
|
System::place_in_container(*$level.world, $temp_loot, "item_0", entity);
|
||||||
|
set_target($temp_loot);
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
bool LootUI::mouse(float x, float y, bool hover) {
|
bool LootUI::mouse(float x, float y, bool hover) {
|
||||||
return $gui.mouse(x, y, hover);
|
return $gui.mouse(x, y, hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ namespace gui {
|
||||||
guecs::UI $gui;
|
guecs::UI $gui;
|
||||||
GameLevel $level;
|
GameLevel $level;
|
||||||
std::unordered_map<guecs::Entity, std::string> $slot_to_name;
|
std::unordered_map<guecs::Entity, std::string> $slot_to_name;
|
||||||
|
DinkyECS::Entity $temp_loot;
|
||||||
DinkyECS::Entity $target;
|
DinkyECS::Entity $target;
|
||||||
|
|
||||||
LootUI(GameLevel level);
|
LootUI(GameLevel level);
|
||||||
|
@ -31,5 +32,6 @@ namespace gui {
|
||||||
|
|
||||||
void remove_slot(guecs::Entity slot_id);
|
void remove_slot(guecs::Entity slot_id);
|
||||||
bool place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity);
|
bool place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity);
|
||||||
|
void add_loose_item(DinkyECS::Entity entity);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue