Worked out the status UI more, setup the color scheme, and fixed various small problems with looting causing a crash.
This commit is contained in:
parent
db60f75bd9
commit
36a49ef768
6 changed files with 48 additions and 40 deletions
|
|
@ -167,16 +167,15 @@ void System::distribute_loot(Position target_pos) {
|
|||
auto loot_entity = world.entity();
|
||||
|
||||
if(inventory_count > 0) {
|
||||
auto& entity_data = config.devices["DEAD_BODY_LOOTABLE"];
|
||||
components::configure_entity(world, loot_entity, entity_data["components"]);
|
||||
// BUG: inventory_count here isn't really used to remove it
|
||||
world.set<InventoryItem>(loot_entity, {inventory_count, entity_data});
|
||||
} else {
|
||||
// this creates a dead body on the ground
|
||||
auto& entity_data = config.devices["DEAD_BODY"];
|
||||
components::configure_entity(world, loot_entity, entity_data["components"]);
|
||||
dbc::log("!!!!!!!!!!!!!!!! ============= LOOTING BODIES NOT READY");
|
||||
}
|
||||
|
||||
// NOTE: refer to the code in raycaster for this
|
||||
|
||||
// this creates a dead body on the ground
|
||||
auto& entity_data = config.devices["DEAD_BODY"];
|
||||
components::configure_entity(world, loot_entity, entity_data["components"]);
|
||||
|
||||
set_position(world, *level.collision, loot_entity, target_pos);
|
||||
level.world->send<game::Event>(game::Event::ENTITY_SPAWN, loot_entity, {});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ namespace gui {
|
|||
dbc::check(world->has<components::Sprite>(item),
|
||||
"item in inventory UI doesn't exist in world. New level?");
|
||||
auto& sprite = world->get<components::Sprite>(item);
|
||||
fmt::println("!!!!!!!!!!! trying to load {}", sprite.name);
|
||||
$gui.set_init<guecs::Icon>(id, {sprite.name});
|
||||
|
||||
guecs::GrabSource grabber{
|
||||
|
|
|
|||
|
|
@ -18,12 +18,13 @@ namespace gui {
|
|||
$gui.init();
|
||||
}
|
||||
|
||||
inline void make_clickable_area(guecs::UI &gui, const std::string &name) {
|
||||
inline void make_clickable_area(guecs::UI &gui, const std::string name) {
|
||||
auto area = gui.entity(name);
|
||||
|
||||
gui.set<Clickable>(area, {
|
||||
[&](auto) {
|
||||
[=](auto) {
|
||||
auto world = GameDB::current_world();
|
||||
fmt::println("CLICK {}", name);
|
||||
world->send<game::Event>(game::Event::AIM_CLICK, area, {});
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -16,8 +16,16 @@ namespace gui {
|
|||
{
|
||||
$gui.position(x, y, width, height);
|
||||
$gui.layout(
|
||||
"[=slot1]"
|
||||
"[=slot2]"
|
||||
"[=body_head]"
|
||||
"[=body_chest]"
|
||||
"[=body_right_arm]"
|
||||
"[=body_left_arm]"
|
||||
"[=body_stomach]"
|
||||
"[=body_left_leg]"
|
||||
"[=body_right_leg]"
|
||||
"[=inv0|=inv1|=inv2]"
|
||||
"[=inv3|=inv4|=inv5]"
|
||||
"[=inv6|=inv7|=inv8]"
|
||||
"[=hand_r]"
|
||||
"[=pocket_l]");
|
||||
}
|
||||
|
|
@ -28,17 +36,22 @@ namespace gui {
|
|||
for(auto& [name, cell] : $gui.cells()) {
|
||||
auto gui_id = $gui.entity(name);
|
||||
|
||||
$gui.set<Rectangle>(gui_id, {});
|
||||
|
||||
$gui.set<Text>(gui_id, {guecs::to_wstring(name)});
|
||||
$gui.set<Clickable>(gui_id, {
|
||||
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
|
||||
});
|
||||
$gui.set<DropTarget>(gui_id, {
|
||||
.commit=[&, gui_id](DinkyECS::Entity world_target) -> bool {
|
||||
return place_slot(gui_id, world_target);
|
||||
}
|
||||
});
|
||||
|
||||
if(name.starts_with("body_")) {
|
||||
$gui.set<Meter>(gui_id, {});
|
||||
} else {
|
||||
$gui.set<Rectangle>(gui_id, {});
|
||||
$gui.set<Clickable>(gui_id, {
|
||||
guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id})
|
||||
});
|
||||
$gui.set<DropTarget>(gui_id, {
|
||||
.commit=[&, gui_id](DinkyECS::Entity world_target) -> bool {
|
||||
return place_slot(gui_id, world_target);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$gui.init();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue