|
|
@ -47,7 +47,6 @@ namespace gui { |
|
|
|
for(int i = 0; i < INV_SLOTS; i++) { |
|
|
|
for(int i = 0; i < INV_SLOTS; i++) { |
|
|
|
auto name = fmt::format("item_{}", i); |
|
|
|
auto name = fmt::format("item_{}", i); |
|
|
|
auto id = $gui.entity(name); |
|
|
|
auto id = $gui.entity(name); |
|
|
|
$slot_to_name.insert_or_assign(id, name); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$gui.set<guecs::Rectangle>(id, {THEME.PADDING, |
|
|
|
$gui.set<guecs::Rectangle>(id, {THEME.PADDING, |
|
|
|
THEME.TRANSPARENT, THEME.LIGHT_MID }); |
|
|
|
THEME.TRANSPARENT, THEME.LIGHT_MID }); |
|
|
@ -69,7 +68,7 @@ namespace gui { |
|
|
|
|
|
|
|
|
|
|
|
for(size_t i = 0; i < INV_SLOTS; i++) { |
|
|
|
for(size_t i = 0; i < INV_SLOTS; i++) { |
|
|
|
auto id = $gui.entity("item_", int(i)); |
|
|
|
auto id = $gui.entity("item_", int(i)); |
|
|
|
auto& slot_name = $slot_to_name.at(id); |
|
|
|
auto& slot_name = $gui.name_for(id); |
|
|
|
|
|
|
|
|
|
|
|
if(contents.has(slot_name)) { |
|
|
|
if(contents.has(slot_name)) { |
|
|
|
auto item = contents.get(slot_name); |
|
|
|
auto item = contents.get(slot_name); |
|
|
@ -97,7 +96,7 @@ namespace gui { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void LootUI::remove_slot(guecs::Entity slot_id) { |
|
|
|
void LootUI::remove_slot(guecs::Entity slot_id) { |
|
|
|
auto& name = $slot_to_name.at(slot_id); |
|
|
|
auto& name = $gui.name_for(slot_id); |
|
|
|
fmt::println("LootUI remove slot inv::Model id={} slot={}", $target, name); |
|
|
|
fmt::println("LootUI remove slot inv::Model id={} slot={}", $target, name); |
|
|
|
System::remove_from_container(*$level.world, $target, name); |
|
|
|
System::remove_from_container(*$level.world, $target, name); |
|
|
|
update(); |
|
|
|
update(); |
|
|
@ -106,7 +105,8 @@ namespace gui { |
|
|
|
bool LootUI::place_slot(guecs::Entity id, DinkyECS::Entity world_entity) { |
|
|
|
bool LootUI::place_slot(guecs::Entity id, DinkyECS::Entity world_entity) { |
|
|
|
fmt::println("LootUI target={} placing world entity {} in slot id {}", |
|
|
|
fmt::println("LootUI target={} placing world entity {} in slot id {}", |
|
|
|
$target, id, world_entity); |
|
|
|
$target, id, world_entity); |
|
|
|
auto& name = $slot_to_name.at(id); |
|
|
|
auto& name = $gui.name_for(id); |
|
|
|
|
|
|
|
|
|
|
|
bool worked = System::place_in_container(*$level.world, $target, name, world_entity); |
|
|
|
bool worked = System::place_in_container(*$level.world, $target, name, world_entity); |
|
|
|
if(worked) update(); |
|
|
|
if(worked) update(); |
|
|
|
return worked; |
|
|
|
return worked; |
|
|
@ -136,4 +136,18 @@ namespace gui { |
|
|
|
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); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool LootUI::occupied(guecs::Entity slot) { |
|
|
|
|
|
|
|
return System::inventory_occupied($level, $target, $gui.name_for(slot)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void LootUI::swap(guecs::Entity gui_a, guecs::Entity gui_b) { |
|
|
|
|
|
|
|
if(gui_a != gui_b) { |
|
|
|
|
|
|
|
auto& a_name = $gui.name_for(gui_a); |
|
|
|
|
|
|
|
auto& b_name = $gui.name_for(gui_b); |
|
|
|
|
|
|
|
System::inventory_swap($level, $target, a_name, b_name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
update(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|