I think that's all the edge cases handled. You can more loot around fairly arbitrarily.
This commit is contained in:
parent
6ff1919587
commit
689bb150c6
2 changed files with 18 additions and 7 deletions
|
@ -61,8 +61,8 @@ namespace gui {
|
||||||
END(Event::CLOSE);
|
END(Event::CLOSE);
|
||||||
break;
|
break;
|
||||||
case LOOT_SELECT:
|
case LOOT_SELECT:
|
||||||
$grab_source = start_grab($loot_ui.$gui, data);
|
commit_move($loot_ui.$gui, $grab_source, data);
|
||||||
if($grab_source) state(DNDState::LOOTING);
|
state(DNDState::LOOTING);
|
||||||
break;
|
break;
|
||||||
case INV_SELECT:
|
case INV_SELECT:
|
||||||
if(commit_drop($loot_ui.$gui,
|
if(commit_drop($loot_ui.$gui,
|
||||||
|
@ -91,7 +91,8 @@ namespace gui {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case INV_SELECT:
|
case INV_SELECT:
|
||||||
$grab_source = start_grab($status_ui.$gui, data);
|
// BUG: should I do a bool here and not transition?
|
||||||
|
commit_move($status_ui.$gui, $grab_source, data);
|
||||||
state(DNDState::LOOTING);
|
state(DNDState::LOOTING);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -195,15 +196,19 @@ namespace gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNDLoot::open() {
|
// BUG: should I do this in the commit_ functions or in the FSM?
|
||||||
|
void DNDLoot::clear_grab() {
|
||||||
$grab_source = std::nullopt;
|
$grab_source = std::nullopt;
|
||||||
$grab_sprite = nullptr;
|
$grab_sprite = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DNDLoot::open() {
|
||||||
|
clear_grab();
|
||||||
$loot_ui.active = true;
|
$loot_ui.active = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DNDLoot::close() {
|
void DNDLoot::close() {
|
||||||
$grab_source = std::nullopt;
|
clear_grab();
|
||||||
$grab_sprite = nullptr;
|
|
||||||
$loot_ui.active = false;
|
$loot_ui.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -242,6 +247,7 @@ namespace gui {
|
||||||
|
|
||||||
if(drop.commit(grab.world_entity)) {
|
if(drop.commit(grab.world_entity)) {
|
||||||
grab.commit();
|
grab.commit();
|
||||||
|
clear_grab();
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -256,6 +262,7 @@ namespace gui {
|
||||||
auto& drop = gui.get<guecs::DropTarget>(drop_id);
|
auto& drop = gui.get<guecs::DropTarget>(drop_id);
|
||||||
drop.commit(grab.world_entity);
|
drop.commit(grab.world_entity);
|
||||||
|
|
||||||
|
clear_grab();
|
||||||
// BUG: if the drop fails then need to put the grab back?
|
// BUG: if the drop fails then need to put the grab back?
|
||||||
// How to confirm the drop will work before doing it?
|
// How to confirm the drop will work before doing it?
|
||||||
// Or, maybe save the commit?
|
// Or, maybe save the commit?
|
||||||
|
@ -269,6 +276,8 @@ namespace gui {
|
||||||
dbc::check($grab_source != std::nullopt, "attempt to commit_drop but no grab_source set");
|
dbc::check($grab_source != std::nullopt, "attempt to commit_drop but no grab_source set");
|
||||||
auto& grab = $status_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
auto& grab = $status_ui.$gui.get<guecs::GrabSource>(*$grab_source);
|
||||||
grab.commit();
|
grab.commit();
|
||||||
return $status_ui.drop_item(grab.world_entity);
|
bool result = $status_ui.drop_item(grab.world_entity);
|
||||||
|
clear_grab();
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace gui {
|
||||||
|
|
||||||
bool throw_on_floor();
|
bool throw_on_floor();
|
||||||
|
|
||||||
|
void clear_grab();
|
||||||
|
|
||||||
sf::Vector2f mouse_position();
|
sf::Vector2f mouse_position();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue