diff --git a/src/events.hpp b/src/events.hpp index 55efbb3..c1e13b4 100644 --- a/src/events.hpp +++ b/src/events.hpp @@ -33,7 +33,6 @@ namespace game { MOVE_LEFT=__LINE__, MOVE_RIGHT=__LINE__, NEW_RITUAL=__LINE__, - NOOP=__LINE__, NO_NEIGHBORS=__LINE__, QUIT=__LINE__, ROTATE_LEFT=__LINE__, diff --git a/src/gui/fsm.cpp b/src/gui/fsm.cpp index 4d32bcf..87ddd2c 100644 --- a/src/gui/fsm.cpp +++ b/src/gui/fsm.cpp @@ -194,7 +194,7 @@ namespace gui { if($boss_scene->playing()) { if(ev == game::Event::MOUSE_CLICK) { dbc::log("exiting cut scene"); - $boss_scene->mouse(0,0, 0); + $boss_scene->mouse(0,0, $router.mouse_mods); state(State::BOSS_FIGHT); } } else { @@ -398,21 +398,8 @@ namespace gui { // HERE: this has to go, unify these events and just use them in the state machine directly switch(evt) { - case eGUI::COMBAT: { - auto &damage = std::any_cast(data); - - if(damage.enemy_did > 0) { - $map_ui.log($F(L"Enemy HIT YOU for {} damage!", damage.enemy_did)); - } else { - $map_ui.log(L"Enemy MISSED YOU."); - } - - if(damage.player_did > 0) { - $map_ui.log($F(L"You HIT enemy for {} damage!", damage.player_did)); - } else { - $map_ui.log(L"You MISSED the enemy."); - } - } + case eGUI::COMBAT: + $map_ui.log(std::any_cast(data)); break; case eGUI::COMBAT_START: $main_ui.show_combat(); @@ -421,19 +408,6 @@ namespace gui { case eGUI::NO_NEIGHBORS: $main_ui.close_combat(); break; - case eGUI::ENTITY_SPAWN: { - auto& sprite = world->get(entity); - $main_ui.$rayview->update_sprite(entity, sprite); - $main_ui.dirty(); - run_systems(); - } break; - case eGUI::INV_SELECT: { - if($router.left_button) { - event(Event::INV_SELECT, data); - } else { - event(Event::USE_ITEM, data); - } - } break; case eGUI::STAIRS_DOWN: event(Event::BOSS_START); break; @@ -462,14 +436,8 @@ namespace gui { dbc::log("NEED TO HANDLE PLAYER DYING."); } } break; - case eGUI::NOOP: { - if(data.type() == typeid(std::string)) { - auto name = std::any_cast(data); - $map_ui.log($F(L"NOOP EVENT! {},{}", evt, entity)); - } - } break; - - + case eGUI::INV_SELECT: + case eGUI::USE_ITEM: case eGUI::AIM_CLICK: case eGUI::LOOT_SELECT: case eGUI::LOOT_CLOSE: diff --git a/src/gui/guecstra.cpp b/src/gui/guecstra.cpp index ab3953f..942e979 100644 --- a/src/gui/guecstra.cpp +++ b/src/gui/guecstra.cpp @@ -13,8 +13,17 @@ namespace guecs { }}; } + Clickable make_action(guecs::Entity gui_id, game::Event left, game::Event right, std::any data, const std::source_location location) { + return {[&, gui_id, left, right, data, location](guecs::Modifiers mods){ + game::Event event = mods.test(guecs::ModBit::left) ? left : right; + auto world = GameDB::current_world(); + dbc::log($F("SENDING EVENT: {}", magic_enum::enum_name(event)), location); + world->send(event, gui_id, data); + }}; + } + Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data, const std::source_location location) { - return {[&, event, data, location](auto){ + return {[&, gui_id, event, data, location](auto){ auto world = GameDB::current_world(); dbc::log($F("SENDING EVENT: {}", magic_enum::enum_name(event)), location); world->send(event, gui_id, data); diff --git a/src/gui/guecstra.hpp b/src/gui/guecstra.hpp index 935b95e..2ee28d7 100644 --- a/src/gui/guecstra.hpp +++ b/src/gui/guecstra.hpp @@ -7,9 +7,13 @@ namespace guecs { Clickable make_action(guecs::Entity gui_id, game::Event event, const std::source_location location = std::source_location::current()); + Clickable make_action(guecs::Entity gui_id, game::Event event, std::any data, const std::source_location location = std::source_location::current()); + Clickable make_action(guecs::Entity gui_id, game::Event left, game::Event right, std::any data, + const std::source_location location = std::source_location::current()); + struct GrabSource { DinkyECS::Entity world_entity; std::function commit; diff --git a/src/gui/map_view.cpp b/src/gui/map_view.cpp index 8b21214..d91868f 100644 --- a/src/gui/map_view.cpp +++ b/src/gui/map_view.cpp @@ -72,4 +72,19 @@ namespace gui { } update(); } + + + void MapViewUI::log(components::CombatResult& damage) { + if(damage.enemy_did > 0) { + log($F(L"Enemy HIT YOU for {} damage!", damage.enemy_did)); + } else { + log(L"Enemy MISSED YOU."); + } + + if(damage.player_did > 0) { + log($F(L"You HIT enemy for {} damage!", damage.player_did)); + } else { + log(L"You MISSED the enemy."); + } + } } diff --git a/src/gui/map_view.hpp b/src/gui/map_view.hpp index 8d64e35..0e045ed 100644 --- a/src/gui/map_view.hpp +++ b/src/gui/map_view.hpp @@ -22,6 +22,7 @@ namespace gui { void init(); void render(sf::RenderWindow &window, int compass_dir); void log(std::wstring msg); + void log(components::CombatResult& damage); void update(); }; } diff --git a/src/gui/status_ui.cpp b/src/gui/status_ui.cpp index a7befdf..5d603b9 100644 --- a/src/gui/status_ui.cpp +++ b/src/gui/status_ui.cpp @@ -44,7 +44,7 @@ namespace gui { } else { $gui.set(gui_id, {guecs::to_wstring(name)}); $gui.set(gui_id, { - guecs::make_action(gui_id, game::Event::INV_SELECT, {gui_id}) + guecs::make_action(gui_id, game::Event::INV_SELECT, game::Event::USE_ITEM, {gui_id}) }); $gui.set(gui_id, { .commit=[&, gui_id](DinkyECS::Entity world_target) -> bool {