mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-04 12:33:55 -07:00
[Game][Arrows] Split Arrows into ArrowData and ArrowItem (#6918)
* [Game][Arrows] Split Arrows into ArrowData and ArrowItem Took 13 minutes Took 5 seconds Took 1 minute Took 26 seconds * Address comments. Took 17 minutes Took 9 seconds Took 1 minute * Change check. Took 3 minutes * Pass by const reference. Took 10 minutes * Remove extra method Took 2 minutes --------- Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
This commit is contained in:
parent
bddf9bd818
commit
491d1c9187
15 changed files with 337 additions and 327 deletions
|
|
@ -3,41 +3,21 @@
|
|||
#include "../player/player_logic.h"
|
||||
#include "arrow_item.h"
|
||||
|
||||
ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent)
|
||||
: AbstractGraphicsItem(parent), owner(_owner), beingPointedAt(false)
|
||||
ArrowTarget::ArrowTarget(PlayerLogic *_owner, QGraphicsItem *parent) : AbstractGraphicsItem(parent), owner(_owner)
|
||||
{
|
||||
setFlag(ItemSendsScenePositionChanges);
|
||||
}
|
||||
|
||||
ArrowTarget::~ArrowTarget()
|
||||
{
|
||||
for (int i = 0; i < arrowsFrom.size(); ++i) {
|
||||
arrowsFrom[i]->setStartItem(0);
|
||||
arrowsFrom[i]->delArrow();
|
||||
}
|
||||
for (int i = 0; i < arrowsTo.size(); ++i) {
|
||||
arrowsTo[i]->setTargetItem(0);
|
||||
arrowsTo[i]->delArrow();
|
||||
}
|
||||
}
|
||||
|
||||
void ArrowTarget::setBeingPointedAt(bool _beingPointedAt)
|
||||
{
|
||||
beingPointedAt = _beingPointedAt;
|
||||
update();
|
||||
}
|
||||
|
||||
QVariant ArrowTarget::itemChange(QGraphicsItem::GraphicsItemChange change, const QVariant &value)
|
||||
QVariant ArrowTarget::itemChange(GraphicsItemChange change, const QVariant &value)
|
||||
{
|
||||
if (change == ItemScenePositionHasChanged && scene()) {
|
||||
for (auto *arrow : arrowsFrom) {
|
||||
arrow->updatePath();
|
||||
}
|
||||
|
||||
for (auto *arrow : arrowsTo) {
|
||||
arrow->updatePath();
|
||||
}
|
||||
if (change == ItemScenePositionHasChanged) {
|
||||
emit scenePositionChanged();
|
||||
}
|
||||
|
||||
return QGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
return AbstractGraphicsItem::itemChange(change, value);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue