mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
game: Automatic update of arrow position (#5729)
Currently, zones must keep track of which cards they move in order to manually call `updatePath` on arrows. This patch sets the `ItemSendsScenePositionChanges` flag on `ArrowTarget`s to automatically update arrow positions without requiring zones to keep track of that information.
This commit is contained in:
parent
c99afe7956
commit
4ada011632
6 changed files with 19 additions and 32 deletions
|
|
@ -6,6 +6,7 @@
|
|||
ArrowTarget::ArrowTarget(Player *_owner, QGraphicsItem *parent)
|
||||
: AbstractGraphicsItem(parent), owner(_owner), beingPointedAt(false)
|
||||
{
|
||||
setFlag(ItemSendsScenePositionChanges);
|
||||
}
|
||||
|
||||
ArrowTarget::~ArrowTarget()
|
||||
|
|
@ -25,3 +26,16 @@ void ArrowTarget::setBeingPointedAt(bool _beingPointedAt)
|
|||
beingPointedAt = _beingPointedAt;
|
||||
update();
|
||||
}
|
||||
|
||||
QVariant ArrowTarget::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemScenePositionHasChanged && scene()) {
|
||||
for (auto *arrow : arrowsFrom)
|
||||
arrow->updatePath();
|
||||
|
||||
for (auto *arrow : arrowsTo)
|
||||
arrow->updatePath();
|
||||
}
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue