Now INV_SELECT and USE_ITEM are moved out.
This commit is contained in:
parent
79dc86809f
commit
0f20f5b6e3
7 changed files with 36 additions and 40 deletions
|
|
@ -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__,
|
||||
|
|
|
|||
|
|
@ -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<components::CombatResult&>(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<components::CombatResult&>(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<components::Sprite>(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<std::string>(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:
|
||||
|
|
|
|||
|
|
@ -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<game::Event>(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<game::Event>(event, gui_id, data);
|
||||
|
|
|
|||
|
|
@ -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<void()> commit;
|
||||
|
|
|
|||
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ namespace gui {
|
|||
} else {
|
||||
$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})
|
||||
guecs::make_action(gui_id, game::Event::INV_SELECT, game::Event::USE_ITEM, {gui_id})
|
||||
});
|
||||
$gui.set<DropTarget>(gui_id, {
|
||||
.commit=[&, gui_id](DinkyECS::Entity world_target) -> bool {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue