Drag now show the icon while you're dragging, so now need to work out all of the edge cases for each action.
This commit is contained in:
parent
ca74b817e5
commit
029a0f86ae
3 changed files with 19 additions and 1 deletions
|
@ -115,6 +115,8 @@ namespace gui {
|
|||
if(UISystem::loot_drop($loot_ui.$gui,
|
||||
$status_ui.$gui, $grab_source, data))
|
||||
{
|
||||
$grab_source = std::nullopt;
|
||||
$grab_sprite = nullptr;
|
||||
state(DNDState::END);
|
||||
}
|
||||
break;
|
||||
|
@ -134,11 +136,19 @@ namespace gui {
|
|||
// NOTE: if > 1 items, go to LOOT_OPEN instead
|
||||
auto gui_id = $loot_ui.$gui.entity("item_0");
|
||||
$grab_source = UISystem::loot_grab($loot_ui.$gui, gui_id);
|
||||
if($grab_source) state(DNDState::ITEM_PICKUP);
|
||||
|
||||
if($grab_source) {
|
||||
auto& source = $loot_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
||||
$grab_sprite = source.sprite;
|
||||
// call this once to properly position the sprite
|
||||
handle_mouse(Event::MOUSE_MOVE, $loot_ui.$gui);
|
||||
state(DNDState::ITEM_PICKUP);
|
||||
}
|
||||
} break;
|
||||
case LOOT_OPEN:
|
||||
$loot_ui.active = true;
|
||||
$grab_source = std::nullopt;
|
||||
$grab_sprite = nullptr;
|
||||
state(DNDState::LOOTING);
|
||||
break;
|
||||
default:
|
||||
|
@ -183,4 +193,9 @@ namespace gui {
|
|||
}
|
||||
}
|
||||
|
||||
void DNDLoot::render() {
|
||||
if($grab_source && $grab_sprite) {
|
||||
$window.draw(*$grab_sprite);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ namespace gui {
|
|||
class DNDLoot : public DeadSimpleFSM<DNDState, Event> {
|
||||
public:
|
||||
std::optional<guecs::Entity> $grab_source = std::nullopt;
|
||||
std::shared_ptr<sf::Sprite> $grab_sprite = nullptr;
|
||||
StatusUI& $status_ui;
|
||||
LootUI& $loot_ui;
|
||||
sf::RenderWindow& $window;
|
||||
|
@ -37,6 +38,7 @@ namespace gui {
|
|||
void ITEM_PICKUP(Event ev, std::any data);
|
||||
void handle_mouse(Event ev, guecs::UI& gui);
|
||||
void mouse_action(bool hover);
|
||||
void render();
|
||||
sf::Vector2f mouse_position();
|
||||
};
|
||||
}
|
||||
|
|
|
@ -366,6 +366,7 @@ namespace gui {
|
|||
$combat_ui.render($window);
|
||||
|
||||
if($loot_ui.active) $loot_ui.render($window);
|
||||
$dnd_loot.render();
|
||||
|
||||
if($map_open) {
|
||||
$map_ui.render($window, $main_ui.$compass_dir);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue