mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-14 06:22:15 -07:00
[Fix-Warnings] Replace types with auto for game/board files
This commit is contained in:
parent
9ece4bfd9b
commit
6a717e1044
5 changed files with 19 additions and 19 deletions
|
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
static const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
|
static const float CARD_WIDTH_HALF = CARD_WIDTH / 2;
|
||||||
static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
|
static const float CARD_HEIGHT_HALF = CARD_HEIGHT / 2;
|
||||||
const QColor GHOST_MASK = QColor(255, 255, 255, 50);
|
constexpr auto GHOST_MASK = QColor(255, 255, 255, 50);
|
||||||
|
|
||||||
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
|
AbstractCardDragItem::AbstractCardDragItem(AbstractCardItem *_item,
|
||||||
const QPointF &_hotSpot,
|
const QPointF &_hotSpot,
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ AbstractCounter::AbstractCounter(Player *_player,
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
menu->addSeparator();
|
menu->addSeparator();
|
||||||
} else {
|
} else {
|
||||||
QAction *aIncrement = new QAction(QString(i < 0 ? "%1" : "+%1").arg(i), this);
|
auto *aIncrement = new QAction(QString(i < 0 ? "%1" : "+%1").arg(i), this);
|
||||||
if (i == -1)
|
if (i == -1)
|
||||||
aDec = aIncrement;
|
aDec = aIncrement;
|
||||||
else if (i == 1)
|
else if (i == 1)
|
||||||
|
|
@ -215,7 +215,7 @@ bool AbstractCounterDialog::eventFilter(QObject *obj, QEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(obj);
|
Q_UNUSED(obj);
|
||||||
if (event->type() == QEvent::KeyPress) {
|
if (event->type() == QEvent::KeyPress) {
|
||||||
QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
|
auto *keyEvent = static_cast<QKeyEvent *>(event);
|
||||||
switch (keyEvent->key()) {
|
switch (keyEvent->key()) {
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
changeValue(+1);
|
changeValue(+1);
|
||||||
|
|
|
||||||
|
|
@ -217,8 +217,8 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
CardZoneLogic *startZone = static_cast<CardItem *>(startItem)->getZone();
|
CardZoneLogic *startZone = static_cast<CardItem *>(startItem)->getZone();
|
||||||
// For now, we can safely assume that the start item is always a card.
|
// For now, we can safely assume that the start item is always a card.
|
||||||
// The target item can be a player as well.
|
// The target item can be a player as well.
|
||||||
CardItem *startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
auto *startCard = qgraphicsitem_cast<CardItem *>(startItem);
|
||||||
CardItem *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
auto *targetCard = qgraphicsitem_cast<CardItem *>(targetItem);
|
||||||
|
|
||||||
Command_CreateArrow cmd;
|
Command_CreateArrow cmd;
|
||||||
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(color));
|
cmd.mutable_arrow_color()->CopyFrom(convertQColorToColor(color));
|
||||||
|
|
@ -232,7 +232,7 @@ void ArrowDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
cmd.set_target_zone(targetZone->getName().toStdString());
|
cmd.set_target_zone(targetZone->getName().toStdString());
|
||||||
cmd.set_target_card_id(targetCard->getId());
|
cmd.set_target_card_id(targetCard->getId());
|
||||||
} else { // failed to cast target to card, this means it's a player
|
} else { // failed to cast target to card, this means it's a player
|
||||||
PlayerTarget *targetPlayer = qgraphicsitem_cast<PlayerTarget *>(targetItem);
|
auto *targetPlayer = qgraphicsitem_cast<PlayerTarget *>(targetItem);
|
||||||
cmd.set_target_player_id(targetPlayer->getOwner()->getPlayerInfo()->getId());
|
cmd.set_target_player_id(targetPlayer->getOwner()->getPlayerInfo()->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
||||||
CardZone *cardZone = 0;
|
CardZone *cardZone = 0;
|
||||||
ZoneViewZone *zoneViewZone = 0;
|
ZoneViewZone *zoneViewZone = 0;
|
||||||
for (int i = colliding.size() - 1; i >= 0; i--) {
|
for (int i = colliding.size() - 1; i >= 0; i--) {
|
||||||
CardZone *temp = qgraphicsitem_cast<CardZone *>(colliding.at(i));
|
auto *temp = qgraphicsitem_cast<CardZone *>(colliding.at(i));
|
||||||
if (!cardZone)
|
if (!cardZone)
|
||||||
cardZone = temp;
|
cardZone = temp;
|
||||||
if (!zoneViewZone)
|
if (!zoneViewZone)
|
||||||
|
|
@ -75,7 +75,7 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
||||||
// For other zones (where we do display the card under the cursor), we use
|
// For other zones (where we do display the card under the cursor), we use
|
||||||
// the hotspot to feel like the card was dragged at the corresponding
|
// the hotspot to feel like the card was dragged at the corresponding
|
||||||
// position.
|
// position.
|
||||||
TableZone *tableZone = qobject_cast<TableZone *>(cursorZone);
|
auto *tableZone = qobject_cast<TableZone *>(cursorZone);
|
||||||
QPointF closestGridPoint;
|
QPointF closestGridPoint;
|
||||||
if (tableZone)
|
if (tableZone)
|
||||||
closestGridPoint = tableZone->closestGridPoint(cursorPosInZone);
|
closestGridPoint = tableZone->closestGridPoint(cursorPosInZone);
|
||||||
|
|
@ -90,7 +90,7 @@ void CardDragItem::updatePosition(const QPointF &cursorScenePos)
|
||||||
setPos(newPos);
|
setPos(newPos);
|
||||||
|
|
||||||
bool newOccupied = false;
|
bool newOccupied = false;
|
||||||
TableZone *table = qobject_cast<TableZone *>(cursorZone);
|
auto *table = qobject_cast<TableZone *>(cursorZone);
|
||||||
if (table)
|
if (table)
|
||||||
if (table->getCardFromCoords(closestGridPoint))
|
if (table->getCardFromCoords(closestGridPoint))
|
||||||
newOccupied = true;
|
newOccupied = true;
|
||||||
|
|
@ -116,7 +116,7 @@ void CardDragItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < childDrags.size(); i++) {
|
for (int i = 0; i < childDrags.size(); i++) {
|
||||||
CardDragItem *c = static_cast<CardDragItem *>(childDrags[i]);
|
auto *c = static_cast<CardDragItem *>(childDrags[i]);
|
||||||
if (!occupied &&
|
if (!occupied &&
|
||||||
!(static_cast<CardItem *>(c->item)->getAttachedTo() && (startZone == currentZone->getLogic())) &&
|
!(static_cast<CardItem *>(c->item)->getAttachedTo() && (startZone == currentZone->getLogic())) &&
|
||||||
!c->occupied) {
|
!c->occupied) {
|
||||||
|
|
|
||||||
|
|
@ -283,18 +283,18 @@ void CardItem::drawArrow(const QColor &arrowColor)
|
||||||
int currentPhase = game->getGameState()->getCurrentPhase();
|
int currentPhase = game->getGameState()->getCurrentPhase();
|
||||||
phase = Phases::getLastSubphase(currentPhase) + 1;
|
phase = Phases::getLastSubphase(currentPhase) + 1;
|
||||||
}
|
}
|
||||||
ArrowDragItem *arrow = new ArrowDragItem(arrowOwner, this, arrowColor, phase);
|
auto *arrow = new ArrowDragItem(arrowOwner, this, arrowColor, phase);
|
||||||
scene()->addItem(arrow);
|
scene()->addItem(arrow);
|
||||||
arrow->grabMouse();
|
arrow->grabMouse();
|
||||||
|
|
||||||
for (const auto &item : scene()->selectedItems()) {
|
for (const auto &item : scene()->selectedItems()) {
|
||||||
CardItem *card = qgraphicsitem_cast<CardItem *>(item);
|
auto *card = qgraphicsitem_cast<CardItem *>(item);
|
||||||
if (card == nullptr || card == this)
|
if (card == nullptr || card == this)
|
||||||
continue;
|
continue;
|
||||||
if (card->getZone() != zone)
|
if (card->getZone() != zone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ArrowDragItem *childArrow = new ArrowDragItem(arrowOwner, card, arrowColor, phase);
|
auto *childArrow = new ArrowDragItem(arrowOwner, card, arrowColor, phase);
|
||||||
scene()->addItem(childArrow);
|
scene()->addItem(childArrow);
|
||||||
arrow->addChildArrow(childArrow);
|
arrow->addChildArrow(childArrow);
|
||||||
}
|
}
|
||||||
|
|
@ -310,13 +310,13 @@ void CardItem::drawAttachArrow()
|
||||||
arrow->grabMouse();
|
arrow->grabMouse();
|
||||||
|
|
||||||
for (const auto &item : scene()->selectedItems()) {
|
for (const auto &item : scene()->selectedItems()) {
|
||||||
CardItem *card = qgraphicsitem_cast<CardItem *>(item);
|
auto *card = qgraphicsitem_cast<CardItem *>(item);
|
||||||
if (card == nullptr)
|
if (card == nullptr)
|
||||||
continue;
|
continue;
|
||||||
if (card->getZone() != zone)
|
if (card->getZone() != zone)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ArrowAttachItem *childArrow = new ArrowAttachItem(card);
|
auto *childArrow = new ArrowAttachItem(card);
|
||||||
scene()->addItem(childArrow);
|
scene()->addItem(childArrow);
|
||||||
arrow->addChildArrow(childArrow);
|
arrow->addChildArrow(childArrow);
|
||||||
}
|
}
|
||||||
|
|
@ -342,7 +342,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() <
|
if ((event->screenPos() - event->buttonDownScreenPos(Qt::LeftButton)).manhattanLength() <
|
||||||
2 * QApplication::startDragDistance())
|
2 * QApplication::startDragDistance())
|
||||||
return;
|
return;
|
||||||
if (const ZoneViewZoneLogic *view = qobject_cast<const ZoneViewZoneLogic *>(zone)) {
|
if (const auto *view = qobject_cast<const ZoneViewZoneLogic *>(zone)) {
|
||||||
if (view->getRevealZone() && !view->getWriteableRevealZone())
|
if (view->getRevealZone() && !view->getWriteableRevealZone())
|
||||||
return;
|
return;
|
||||||
} else if (!owner->getPlayerInfo()->getLocalOrJudge())
|
} else if (!owner->getPlayerInfo()->getLocalOrJudge())
|
||||||
|
|
@ -357,7 +357,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
|
|
||||||
int childIndex = 0;
|
int childIndex = 0;
|
||||||
for (const auto &item : scene()->selectedItems()) {
|
for (const auto &item : scene()->selectedItems()) {
|
||||||
CardItem *card = static_cast<CardItem *>(item);
|
auto *card = static_cast<CardItem *>(item);
|
||||||
if ((card == this) || (card->getZone() != zone))
|
if ((card == this) || (card->getZone() != zone))
|
||||||
continue;
|
continue;
|
||||||
++childIndex;
|
++childIndex;
|
||||||
|
|
@ -366,7 +366,7 @@ void CardItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
|
||||||
childPos = card->pos() - pos();
|
childPos = card->pos() - pos();
|
||||||
else
|
else
|
||||||
childPos = QPointF(childIndex * CARD_WIDTH / 2, 0);
|
childPos = QPointF(childIndex * CARD_WIDTH / 2, 0);
|
||||||
CardDragItem *drag =
|
auto *drag =
|
||||||
new CardDragItem(card, card->getId(), childPos, card->getFaceDown() || forceFaceDown, dragItem);
|
new CardDragItem(card, card->getId(), childPos, card->getFaceDown() || forceFaceDown, dragItem);
|
||||||
drag->setPos(dragItem->pos() + childPos);
|
drag->setPos(dragItem->pos() + childPos);
|
||||||
scene()->addItem(drag);
|
scene()->addItem(drag);
|
||||||
|
|
@ -381,7 +381,7 @@ void CardItem::playCard(bool faceDown)
|
||||||
if (!owner->getPlayerInfo()->getLocalOrJudge())
|
if (!owner->getPlayerInfo()->getLocalOrJudge())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TableZoneLogic *tz = qobject_cast<TableZoneLogic *>(zone);
|
auto *tz = qobject_cast<TableZoneLogic *>(zone);
|
||||||
if (tz)
|
if (tz)
|
||||||
emit tz->toggleTapped();
|
emit tz->toggleTapped();
|
||||||
else {
|
else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue