mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-25 08:03:54 -07:00
added drawArrow context menu item
This commit is contained in:
parent
6a77e765a7
commit
add47315d5
13 changed files with 799 additions and 723 deletions
|
|
@ -34,6 +34,8 @@ CardItem::CardItem(Player *_owner, const QString &_name, int _cardid, bool _reve
|
|||
connect(aAttach, SIGNAL(triggered()), this, SLOT(actAttach()));
|
||||
aUnattach = new QAction(this);
|
||||
connect(aUnattach, SIGNAL(triggered()), this, SLOT(actUnattach()));
|
||||
aDrawArrow = new QAction(this);
|
||||
connect(aDrawArrow, SIGNAL(triggered()), this, SLOT(actDrawArrow()));
|
||||
aIncP = new QAction(this);
|
||||
connect(aIncP, SIGNAL(triggered()), this, SLOT(actIncP()));
|
||||
aDecP = new QAction(this);
|
||||
|
|
@ -172,6 +174,7 @@ void CardItem::updateCardMenu()
|
|||
cardMenu->addAction(aAttach);
|
||||
if (attachedTo)
|
||||
cardMenu->addAction(aUnattach);
|
||||
cardMenu->addAction(aDrawArrow);
|
||||
cardMenu->addSeparator();
|
||||
cardMenu->addMenu(ptMenu);
|
||||
cardMenu->addAction(aSetAnnotation);
|
||||
|
|
@ -186,6 +189,9 @@ void CardItem::updateCardMenu()
|
|||
cardMenu->addAction(aSetCounter[i]);
|
||||
}
|
||||
cardMenu->addSeparator();
|
||||
} else if (zone->getName() == "stack") {
|
||||
cardMenu->addAction(aDrawArrow);
|
||||
cardMenu->addMenu(moveMenu);
|
||||
} else {
|
||||
cardMenu->addAction(aPlay);
|
||||
cardMenu->addMenu(moveMenu);
|
||||
|
|
@ -209,6 +215,7 @@ void CardItem::retranslateUi()
|
|||
aAttach->setText(tr("&Attach to card..."));
|
||||
aAttach->setShortcut(tr("Ctrl+A"));
|
||||
aUnattach->setText(tr("Unattac&h"));
|
||||
aDrawArrow->setText(tr("&Draw arrow..."));
|
||||
ptMenu->setTitle(tr("&Power / toughness"));
|
||||
aIncP->setText(tr("&Increase power"));
|
||||
aIncP->setShortcut(tr("Ctrl++"));
|
||||
|
|
@ -399,13 +406,35 @@ void CardItem::deleteDragItem()
|
|||
dragItem = NULL;
|
||||
}
|
||||
|
||||
void CardItem::drawArrow(const QColor &arrowColor)
|
||||
{
|
||||
if (static_cast<TabGame *>(owner->parent())->getSpectator())
|
||||
return;
|
||||
|
||||
Player *arrowOwner = static_cast<TabGame *>(owner->parent())->getActiveLocalPlayer();
|
||||
ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor);
|
||||
scene()->addItem(arrow);
|
||||
arrow->grabMouse();
|
||||
|
||||
QListIterator<QGraphicsItem *> itemIterator(scene()->selectedItems());
|
||||
while (itemIterator.hasNext()) {
|
||||
CardItem *c = qgraphicsitem_cast<CardItem *>(itemIterator.next());
|
||||
if (!c || (c == this))
|
||||
continue;
|
||||
if (c->getZone() != zone)
|
||||
continue;
|
||||
|
||||
ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, c, arrowColor);
|
||||
scene()->addItem(childArrow);
|
||||
arrow->addChildArrow(childArrow);
|
||||
}
|
||||
}
|
||||
|
||||
void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||
{
|
||||
if (event->buttons().testFlag(Qt::RightButton)) {
|
||||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::RightButton)).manhattanLength() < 2 * QApplication::startDragDistance())
|
||||
return;
|
||||
if (static_cast<TabGame *>(owner->parent())->getSpectator())
|
||||
return;
|
||||
|
||||
QColor arrowColor = Qt::red;
|
||||
if (event->modifiers().testFlag(Qt::ControlModifier))
|
||||
|
|
@ -415,23 +444,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
|||
else if (event->modifiers().testFlag(Qt::ShiftModifier))
|
||||
arrowColor = Qt::green;
|
||||
|
||||
Player *arrowOwner = static_cast<TabGame *>(owner->parent())->getActiveLocalPlayer();
|
||||
ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor);
|
||||
scene()->addItem(arrow);
|
||||
arrow->grabMouse();
|
||||
|
||||
QListIterator<QGraphicsItem *> itemIterator(scene()->selectedItems());
|
||||
while (itemIterator.hasNext()) {
|
||||
CardItem *c = qgraphicsitem_cast<CardItem *>(itemIterator.next());
|
||||
if (!c || (c == this))
|
||||
continue;
|
||||
if (c->getZone() != zone)
|
||||
continue;
|
||||
|
||||
ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, c, arrowColor);
|
||||
scene()->addItem(childArrow);
|
||||
arrow->addChildArrow(childArrow);
|
||||
}
|
||||
drawArrow(arrowColor);
|
||||
} else if (event->buttons().testFlag(Qt::LeftButton)) {
|
||||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() < 2 * QApplication::startDragDistance())
|
||||
return;
|
||||
|
|
@ -547,6 +560,11 @@ void CardItem::actUnattach()
|
|||
owner->actUnattach(static_cast<QAction *>(sender()));
|
||||
}
|
||||
|
||||
void CardItem::actDrawArrow()
|
||||
{
|
||||
drawArrow(Qt::red);
|
||||
}
|
||||
|
||||
void CardItem::actIncP()
|
||||
{
|
||||
owner->actIncPT(1, 0);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue