Can now drag an item out of inventory and drop on the ground, then pick it back up, and put it in a loot container, and then back again. Still buggy but working for now.
This commit is contained in:
parent
68e50342e5
commit
119b3ed11d
7 changed files with 58 additions and 6 deletions
|
@ -114,6 +114,8 @@ namespace gui {
|
|||
case MOUSE_DROP: {
|
||||
auto& grab = $status_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
||||
grab.commit();
|
||||
bool dropped = $status_ui.drop_item(grab.world_entity);
|
||||
dbc::check(dropped, "DROP FAILED!");
|
||||
END(Event::CLOSE);
|
||||
} break;
|
||||
default:
|
||||
|
|
11
gui/fsm.cpp
11
gui/fsm.cpp
|
@ -68,6 +68,8 @@ namespace gui {
|
|||
$mini_map.init($main_ui.$overlay_ui.$gui);
|
||||
|
||||
run_systems();
|
||||
|
||||
this_crap_must_die();
|
||||
state(State::IDLE);
|
||||
}
|
||||
|
||||
|
@ -430,7 +432,8 @@ namespace gui {
|
|||
event(Event::START_COMBAT);
|
||||
break;
|
||||
case eGUI::ENEMY_SPAWN:
|
||||
$main_ui.update_level($level);
|
||||
$main_ui.$rayview.update_level($level);
|
||||
$main_ui.dirty();
|
||||
run_systems();
|
||||
break;
|
||||
case eGUI::NO_NEIGHBORS:
|
||||
|
@ -514,4 +517,10 @@ namespace gui {
|
|||
|
||||
run_systems();
|
||||
}
|
||||
|
||||
void FSM::this_crap_must_die() {
|
||||
auto torch_id = System::spawn_item($level, "TORCH_BAD");
|
||||
auto hand_l = $status_ui.$gui.entity("hand_l");
|
||||
$status_ui.place_slot(hand_l, torch_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,5 +79,6 @@ namespace gui {
|
|||
void handle_world_events();
|
||||
void next_level();
|
||||
void debug_render();
|
||||
void this_crap_must_die();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "rand.hpp"
|
||||
#include <fmt/xchar.h>
|
||||
#include "gui/guecstra.hpp"
|
||||
#include "systems.hpp"
|
||||
|
||||
namespace gui {
|
||||
using namespace guecs;
|
||||
|
@ -85,7 +86,7 @@ namespace gui {
|
|||
init();
|
||||
}
|
||||
|
||||
bool StatusUI::place_slot(DinkyECS::Entity gui_id, DinkyECS::Entity world_entity) {
|
||||
bool StatusUI::place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity) {
|
||||
if($level.world->has<components::Sprite>(world_entity)) {
|
||||
auto& sprite = $level.world->get<components::Sprite>(world_entity);
|
||||
$gui.set_init<guecs::Sprite>(gui_id, {sprite.name});
|
||||
|
@ -101,7 +102,11 @@ namespace gui {
|
|||
}
|
||||
}
|
||||
|
||||
void StatusUI::remove_slot(DinkyECS::Entity slot_id) {
|
||||
bool StatusUI::drop_item(DinkyECS::Entity item_id) {
|
||||
return System::drop_item($level, item_id);
|
||||
}
|
||||
|
||||
void StatusUI::remove_slot(guecs::Entity slot_id) {
|
||||
if(contents.contains(slot_id)) {
|
||||
contents.erase(slot_id);
|
||||
$gui.remove<guecs::GrabSource>(slot_id);
|
||||
|
|
|
@ -12,7 +12,7 @@ namespace gui {
|
|||
public:
|
||||
guecs::UI $gui;
|
||||
GameLevel $level;
|
||||
std::unordered_map<DinkyECS::Entity, DinkyECS::Entity> contents;
|
||||
std::unordered_map<guecs::Entity, DinkyECS::Entity> contents;
|
||||
ritual::UI $ritual_ui;
|
||||
|
||||
StatusUI(GameLevel level);
|
||||
|
@ -23,7 +23,8 @@ namespace gui {
|
|||
void update();
|
||||
bool mouse(float x, float y, bool hover);
|
||||
|
||||
void remove_slot(DinkyECS::Entity slot_id);
|
||||
bool place_slot(DinkyECS::Entity gui_id, DinkyECS::Entity world_entity);
|
||||
void remove_slot(guecs::Entity slot_id);
|
||||
bool place_slot(guecs::Entity gui_id, DinkyECS::Entity world_entity);
|
||||
bool drop_item(DinkyECS::Entity item_id);
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue