Clang-format (#3028)

* 1/3 Add .clang-format file and travis compilation check

* 2/3 Run clang-format

* 3/3 Fix compilation problems due to include reordering

* 3bis/3 AfterControlStatement: false
This commit is contained in:
ctrlaltca 2018-01-27 10:41:32 +01:00 committed by GitHub
parent 8dbdd24c8e
commit b29bd9e070
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
272 changed files with 13378 additions and 9535 deletions

View file

@ -1,8 +1,8 @@
#include <QAction>
#include <QDebug>
#include <QPainter>
#include <QPen>
#include <QTimer>
#include <QDebug>
#include <cmath>
#ifdef _WIN32
#include "round.h"
@ -10,13 +10,14 @@
#include "phasestoolbar.h"
#include "pixmapgenerator.h"
#include "pb/command_set_active_phase.pb.h"
#include "pb/command_next_turn.pb.h"
#include "pb/command_set_card_attr.pb.h"
#include "pb/command_draw_cards.pb.h"
#include "pb/command_next_turn.pb.h"
#include "pb/command_set_active_phase.pb.h"
#include "pb/command_set_card_attr.pb.h"
PhaseButton::PhaseButton(const QString &_name, QGraphicsItem *parent, QAction *_doubleClickAction, bool _highlightable)
: QObject(), QGraphicsItem(parent), name(_name), active(false), highlightable(_highlightable), activeAnimationCounter(0), doubleClickAction(_doubleClickAction), width(50)
: QObject(), QGraphicsItem(parent), name(_name), active(false), highlightable(_highlightable),
activeAnimationCounter(0), doubleClickAction(_doubleClickAction), width(50)
{
if (highlightable) {
activeAnimationTimer = new QTimer(this);
@ -24,7 +25,7 @@ PhaseButton::PhaseButton(const QString &_name, QGraphicsItem *parent, QAction *_
activeAnimationTimer->setSingleShot(false);
} else
activeAnimationCounter = 9.0;
setCacheMode(DeviceCoordinateCache);
}
@ -39,15 +40,17 @@ void PhaseButton::paint(QPainter *painter, const QStyleOptionGraphicsItem * /*op
QRectF translatedIconRect = painter->combinedTransform().mapRect(iconRect);
qreal scaleFactor = translatedIconRect.width() / iconRect.width();
QPixmap iconPixmap = PhasePixmapGenerator::generatePixmap(round(translatedIconRect.height()), name);
painter->setBrush(QColor(220 * (activeAnimationCounter / 10.0), 220 * (activeAnimationCounter / 10.0), 220 * (activeAnimationCounter / 10.0)));
painter->setBrush(QColor(220 * (activeAnimationCounter / 10.0), 220 * (activeAnimationCounter / 10.0),
220 * (activeAnimationCounter / 10.0)));
painter->setPen(Qt::gray);
painter->drawRect(0, 0, width - 1, width - 1);
painter->save();
painter->resetTransform();
painter->drawPixmap(iconPixmap.rect().translated(round(3 * scaleFactor), round(3 * scaleFactor)), iconPixmap, iconPixmap.rect());
painter->drawPixmap(iconPixmap.rect().translated(round(3 * scaleFactor), round(3 * scaleFactor)), iconPixmap,
iconPixmap.rect());
painter->restore();
painter->setBrush(QColor(0, 0, 0, 255 * ((10 - activeAnimationCounter) / 15.0)));
painter->setPen(Qt::gray);
painter->drawRect(0, 0, width - 1, width - 1);
@ -63,7 +66,7 @@ void PhaseButton::setActive(bool _active)
{
if ((active == _active) || !highlightable)
return;
active = _active;
activeAnimationTimer->start(25);
}
@ -72,7 +75,7 @@ void PhaseButton::updateAnimation()
{
if (!highlightable)
return;
if (active) {
if (++activeAnimationCounter >= 10)
activeAnimationTimer->stop();
@ -106,7 +109,7 @@ PhasesToolbar::PhasesToolbar(QGraphicsItem *parent)
connect(aUntapAll, SIGNAL(triggered()), this, SLOT(actUntapAll()));
QAction *aDrawCard = new QAction(this);
connect(aDrawCard, SIGNAL(triggered()), this, SLOT(actDrawCard()));
PhaseButton *untapButton = new PhaseButton("untap", this, aUntapAll);
PhaseButton *upkeepButton = new PhaseButton("upkeep", this);
PhaseButton *drawButton = new PhaseButton("draw", this, aDrawCard);
@ -118,19 +121,18 @@ PhasesToolbar::PhasesToolbar(QGraphicsItem *parent)
PhaseButton *combatEndButton = new PhaseButton("combat_end", this);
PhaseButton *main2Button = new PhaseButton("main2", this);
PhaseButton *cleanupButton = new PhaseButton("cleanup", this);
buttonList << untapButton << upkeepButton << drawButton << main1Button << combatStartButton
<< combatAttackersButton << combatBlockersButton << combatDamageButton << combatEndButton
<< main2Button << cleanupButton;
buttonList << untapButton << upkeepButton << drawButton << main1Button << combatStartButton << combatAttackersButton
<< combatBlockersButton << combatDamageButton << combatEndButton << main2Button << cleanupButton;
for (int i = 0; i < buttonList.size(); ++i)
connect(buttonList[i], SIGNAL(clicked()), this, SLOT(phaseButtonClicked()));
nextTurnButton = new PhaseButton("nextturn", this, 0, false);
connect(nextTurnButton, SIGNAL(clicked()), this, SLOT(actNextTurn()));
rearrangeButtons();
retranslateUi();
}
@ -148,18 +150,30 @@ void PhasesToolbar::retranslateUi()
QString PhasesToolbar::getLongPhaseName(int phase) const
{
switch (phase) {
case 0: return tr("Untap step");
case 1: return tr("Upkeep step");
case 2: return tr("Draw step");
case 3: return tr("First main phase");
case 4: return tr("Beginning of combat step");
case 5: return tr("Declare attackers step");
case 6: return tr("Declare blockers step");
case 7: return tr("Combat damage step");
case 8: return tr("End of combat step");
case 9: return tr("Second main phase");
case 10: return tr("End of turn step");
default: return QString();
case 0:
return tr("Untap step");
case 1:
return tr("Upkeep step");
case 2:
return tr("Draw step");
case 3:
return tr("First main phase");
case 4:
return tr("Beginning of combat step");
case 5:
return tr("Declare attackers step");
case 6:
return tr("Declare blockers step");
case 7:
return tr("Combat damage step");
case 8:
return tr("End of combat step");
case 9:
return tr("Second main phase");
case 10:
return tr("End of turn step");
default:
return QString();
}
}
@ -175,7 +189,7 @@ void PhasesToolbar::rearrangeButtons()
for (int i = 0; i < buttonList.size(); ++i)
buttonList[i]->setWidth(symbolSize);
nextTurnButton->setWidth(symbolSize);
double y = marginSize;
buttonList[0]->setPos(marginSize, y);
buttonList[1]->setPos(marginSize, y += symbolSize);
@ -200,12 +214,12 @@ void PhasesToolbar::rearrangeButtons()
void PhasesToolbar::setHeight(double _height)
{
prepareGeometryChange();
height = _height;
ySpacing = (height - 2 * marginSize) / (buttonCount * 5 + spaceCount);
symbolSize = ySpacing * 5;
width = symbolSize + 2 * marginSize;
rearrangeButtons();
}
@ -213,7 +227,7 @@ void PhasesToolbar::setActivePhase(int phase)
{
if (phase >= buttonList.size())
return;
for (int i = 0; i < buttonList.size(); ++i)
buttonList[i]->setActive(i == phase);
}
@ -223,10 +237,10 @@ void PhasesToolbar::phaseButtonClicked()
PhaseButton *button = qobject_cast<PhaseButton *>(sender());
if (button->getActive())
button->triggerDoubleClickAction();
Command_SetActivePhase cmd;
cmd.set_phase(buttonList.indexOf(button));
emit sendGameCommand(cmd, -1);
}
@ -241,7 +255,7 @@ void PhasesToolbar::actUntapAll()
cmd.set_zone("table");
cmd.set_attribute(AttrTapped);
cmd.set_attr_value("0");
emit sendGameCommand(cmd, -1);
}
@ -249,6 +263,6 @@ void PhasesToolbar::actDrawCard()
{
Command_DrawCards cmd;
cmd.set_number(1);
emit sendGameCommand(cmd, -1);
}