diff --git a/assets/devices.json b/assets/devices.json index 89e02eb..dc35b77 100644 --- a/assets/devices.json +++ b/assets/devices.json @@ -57,7 +57,7 @@ "foreground": [150, 100, 189], "background": [150, 100, 189] }, - {"_type": "Device", "config": {}, "events": ["LOOT_OPEN"]}, + {"_type": "Device", "config": {}, "events": ["LOOT_CONTAINER"]}, {"_type": "Sprite", "name": "barrel_small", "width": 256, "height": 256, "scale": 1.0}, {"_type": "Sound", "attack": "pickup", "death": "blank"} ], @@ -73,7 +73,7 @@ "foreground": [32, 123, 164], "background": [24, 205, 189] }, - {"_type": "Device", "config": {}, "events": ["LOOT_OPEN"]}, + {"_type": "Device", "config": {}, "events": ["LOOT_CONTAINER"]}, {"_type": "Sprite", "name": "grave_stone", "width": 256, "height": 256, "scale": 1.0}, {"_type": "Sound", "attack": "pickup", "death": "blank"} ] diff --git a/events.hpp b/events.hpp index 99d25e0..4e224c3 100644 --- a/events.hpp +++ b/events.hpp @@ -2,10 +2,11 @@ namespace Events { enum GUI { - START, COMBAT, LOOT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP, + START, COMBAT, DEATH, STAIRS_UP, STAIRS_DOWN, TRAP, COMBAT_START, NO_NEIGHBORS, HP_STATUS, ATTACK, BLOCK, EVADE, NEW_RITUAL, UPDATE_SPRITE, ENEMY_SPAWN, NOOP, + LOOT_ITEM, LOOT_CONTAINER, LOOT_CLOSE, LOOT_SELECT, INV_SELECT, AIM_CLICK }; @@ -32,14 +33,15 @@ namespace gui { STOP_COMBAT = 12, STAIRS_DOWN = 13, LOOT_OPEN=14, - LOOT_SELECT=15, - INV_SELECT=16, - QUIT = 17, - MOUSE_CLICK=18, - MOUSE_MOVE=19, - MOUSE_DRAG=20, - MOUSE_DRAG_START=21, - MOUSE_DROP=22, - KEY_PRESS=23 + LOOT_ITEM=15, + LOOT_SELECT=16, + INV_SELECT=17, + QUIT = 18, + MOUSE_CLICK=19, + MOUSE_MOVE=20, + MOUSE_DRAG=21, + MOUSE_DRAG_START=22, + MOUSE_DROP=23, + KEY_PRESS=24 }; } diff --git a/gui/fsm.cpp b/gui/fsm.cpp index 0111515..5e2b58d 100644 --- a/gui/fsm.cpp +++ b/gui/fsm.cpp @@ -575,14 +575,19 @@ namespace gui { dbc::log("there's no thing there!"); } break; - case eGUI::LOOT: { - if(world.has(entity)) { - auto gui_id = $loot_ui.$gui.entity("item_0"); - $loot_ui.contents.insert_or_assign(gui_id, entity); - $loot_ui.update(); - } else { - dbc::log("unhandled loot event."); - } + case eGUI::LOOT_ITEM: { + dbc::check(world.has(entity), + "INVALID LOOT_ITEM, that entity has no InventoryItem"); + auto gui_id = $loot_ui.$gui.entity("item_0"); + $loot_ui.contents.insert_or_assign(gui_id, entity); + $loot_ui.update(); + event(Event::LOOT_OPEN); + } break; + case eGUI::LOOT_CONTAINER: { + dbc::check(world.has(entity), + "INVALID LOOT_ITEM, that entity has no InventoryItem"); + + dbc::log("everything is empty for now"); event(Event::LOOT_OPEN); } break; case eGUI::HP_STATUS: diff --git a/systems.cpp b/systems.cpp index 3219576..9478853 100644 --- a/systems.cpp +++ b/systems.cpp @@ -335,7 +335,7 @@ void System::pickup(GameLevel &level, DinkyECS::Entity entity) { // NOTE: chests are different from say a torch, maybe 2 events or the // GUI figures out which it is, then when you click either pick it up // and move it or show the loot container UI - world.send(Events::GUI::LOOT, entity, item); + world.send(Events::GUI::LOOT_ITEM, entity, item); } } else if(world.has(entity)) { System::device(world, player.entity, entity); @@ -354,8 +354,8 @@ void System::device(DinkyECS::World &world, DinkyECS::Entity actor, DinkyECS::En world.send(Events::GUI::STAIRS_UP, actor, device); } else if(event == "TRAP") { world.send(Events::GUI::TRAP, actor, device); - } else if(event == "LOOT_OPEN") { - world.send(Events::GUI::LOOT, actor, device); + } else if(event == "LOOT_CONTAINER") { + world.send(Events::GUI::LOOT_CONTAINER, actor, device); } else { dbc::log(fmt::format( "INVALID EVENT {} for device {}",