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,15 +1,21 @@
#ifndef PLAYER_H
#define PLAYER_H
#include <QInputDialog>
#include <QPoint>
#include <QMap>
#include "abstractgraphicsitem.h"
#include "carddatabase.h"
#include "pb/game_event.pb.h"
#include "pb/card_attributes.pb.h"
#include "pb/game_event.pb.h"
#include <QInputDialog>
#include <QMap>
#include <QPoint>
namespace google { namespace protobuf { class Message; } }
namespace google
{
namespace protobuf
{
class Message;
}
} // namespace google
class CardDatabase;
class DeckLoader;
class QMenu;
@ -59,25 +65,37 @@ class PendingCommand;
const int MAX_TOKENS_PER_DIALOG = 99;
class PlayerArea : public QObject, public QGraphicsItem {
class PlayerArea : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
private:
QRectF bRect;
private slots:
void updateBg();
public:
enum { Type = typeOther };
int type() const { return Type; }
enum
{
Type = typeOther
};
int type() const
{
return Type;
}
PlayerArea(QGraphicsItem *parent = 0);
QRectF boundingRect() const { return bRect; }
QRectF boundingRect() const
{
return bRect;
}
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void setSize(qreal width, qreal height);
};
class Player : public QObject, public QGraphicsItem {
class Player : public QObject, public QGraphicsItem
{
Q_OBJECT
Q_INTERFACES(QGraphicsItem)
signals:
@ -87,7 +105,12 @@ signals:
void logSay(Player *player, QString message);
void logShuffle(Player *player, CardZone *zone);
void logRollDie(Player *player, int sides, int roll);
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard, bool _playerTarget);
void logCreateArrow(Player *player,
Player *startPlayer,
QString startCard,
Player *targetPlayer,
QString targetCard,
bool _playerTarget);
void logCreateToken(Player *player, QString cardName, QString pt);
void logDrawCards(Player *player, int number);
void logUndoDraw(Player *player, QString cardName);
@ -104,9 +127,10 @@ signals:
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
void logDumpZone(Player *player, CardZone *zone, int numberCards);
void logStopDumpZone(Player *player, CardZone *zone);
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
void
logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
void sizeChanged();
void gameConceded();
public slots:
@ -132,16 +156,16 @@ public slots:
void actRevealRandomGraveyardCard();
void actViewRfg();
void actViewSideboard();
void actSayMessage();
private slots:
void addPlayer(Player *player);
void removePlayer(Player *player);
void playerListActionTriggered();
void updateBoundingRect();
void rearrangeZones();
void actOpenDeckInDeckEditor();
void actCreatePredefinedToken();
void actCreateRelatedCard();
@ -168,24 +192,23 @@ private slots:
private:
TabGame *game;
QMenu *playerMenu, *handMenu, *moveHandMenu, *graveMenu, *moveGraveMenu, *rfgMenu, *moveRfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu,
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard;
QMenu *playerMenu, *handMenu, *moveHandMenu, *graveMenu, *moveGraveMenu, *rfgMenu, *moveRfgMenu, *libraryMenu,
*sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu, *mRevealLibrary, *mRevealTopCard, *mRevealHand,
*mRevealRandomHandCard, *mRevealRandomGraveyardCard;
QList<QMenu *> playerLists;
QList<QAction *> allPlayersActions;
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
*aViewLibrary, *aViewTopCards, *aAlwaysRevealTopCard, *aOpenDeckInDeckEditor, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
*aViewGraveyard, *aViewRfg, *aViewSideboard,
*aDrawCard, *aDrawCards, *aUndoDraw, *aMulligan, *aShuffle, *aMoveTopToPlayFaceDown,
*aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken,
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg, *aMoveRfgToTopLibrary,
*aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave, *aViewLibrary, *aViewTopCards,
*aAlwaysRevealTopCard, *aOpenDeckInDeckEditor, *aMoveTopCardsToGrave, *aMoveTopCardsToExile,
*aMoveTopCardToBottom, *aViewGraveyard, *aViewRfg, *aViewSideboard, *aDrawCard, *aDrawCards, *aUndoDraw,
*aMulligan, *aShuffle, *aMoveTopToPlayFaceDown, *aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken,
*aCardMenu, *aMoveBottomCardToGrave;
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
QAction *aPlay, *aPlayFacedown,
*aHide,
*aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary;
QAction *aPlay, *aPlayFacedown, *aHide, *aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP,
*aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone, *aMoveToTopLibrary,
*aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary;
bool shortcutsActive;
int defaultNumberTopCards;
@ -200,22 +223,26 @@ private:
bool mirrored;
bool handVisible;
bool conceded;
bool dialogSemaphore;
bool clearCardsToDelete();
QList<CardItem *> cardsToDelete;
DeckLoader *deck;
QStringList predefinedTokens;
PlayerArea *playerArea;
QMap<QString, CardZone *> zones;
StackZone *stack;
TableZone *table;
HandZone *hand;
PlayerTarget *playerTarget;
void setCardAttrHelper(const GameEventContext &context, CardItem *card, CardAttribute attribute, const QString &avalue, bool allCards);
void setCardAttrHelper(const GameEventContext &context,
CardItem *card,
CardAttribute attribute,
const QString &avalue,
bool allCards);
void addRelatedCardActions(const CardItem *card, QMenu *cardMenu);
void createCard(const CardItem *sourceCard, const QString &dbCardName, bool attach = false);
void createAttachedCard(const CardItem *sourceCard, const QString &dbCardName);
@ -227,9 +254,9 @@ private:
QMap<int, AbstractCounter *> counters;
QMap<int, ArrowItem *> arrows;
void rearrangeCounters();
void initSayMenu();
void eventConnectionStateChanged(const Event_ConnectionStateChanged &event);
void eventGameSay(const Event_GameSay &event);
void eventShuffle(const Event_Shuffle &event);
@ -251,16 +278,39 @@ private:
void eventDrawCards(const Event_DrawCards &event);
void eventRevealCards(const Event_RevealCards &event);
void eventChangeZoneProperties(const Event_ChangeZoneProperties &event);
public:
static const int counterAreaWidth = 55;
enum CardMenuActionType { cmTap, cmUntap, cmDoesntUntap, cmFlip, cmPeek, cmClone, cmMoveToTopLibrary, cmMoveToBottomLibrary, cmMoveToHand, cmMoveToGraveyard, cmMoveToExile };
enum CardsToReveal {RANDOM_CARD_FROM_ZONE = -2};
enum CardMenuActionType
{
cmTap,
cmUntap,
cmDoesntUntap,
cmFlip,
cmPeek,
cmClone,
cmMoveToTopLibrary,
cmMoveToBottomLibrary,
cmMoveToHand,
cmMoveToGraveyard,
cmMoveToExile
};
enum CardsToReveal
{
RANDOM_CARD_FROM_ZONE = -2
};
enum { Type = typeOther };
int type() const { return Type; }
enum
{
Type = typeOther
};
int type() const
{
return Type;
}
QRectF boundingRect() const;
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
void playCard(CardItem *c, bool faceDown, bool tapped);
void addCard(CardItem *c);
void deleteCard(CardItem *c);
@ -270,53 +320,86 @@ public:
AbstractCounter *addCounter(int counterId, const QString &name, QColor color, int radius, int value);
void delCounter(int counterId);
void clearCounters();
ArrowItem *addArrow(const ServerInfo_Arrow &arrow);
ArrowItem *addArrow(int arrowId, CardItem *startCard, ArrowTarget *targetItem, const QColor &color);
void delArrow(int arrowId);
void removeArrow(ArrowItem *arrow);
void clearArrows();
PlayerTarget *getPlayerTarget() const { return playerTarget; }
PlayerTarget *getPlayerTarget() const
{
return playerTarget;
}
Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent);
~Player();
void retranslateUi();
void clear();
TabGame *getGame() const { return game; }
TabGame *getGame() const
{
return game;
}
void setDeck(const DeckLoader &_deck);
QMenu *getPlayerMenu() const { return playerMenu; }
int getId() const { return id; }
QMenu *getPlayerMenu() const
{
return playerMenu;
}
int getId() const
{
return id;
}
QString getName() const;
ServerInfo_User *getUserInfo() const { return userInfo; }
bool getLocal() const { return local; }
bool getMirrored() const { return mirrored; }
const QMap<QString, CardZone *> &getZones() const { return zones; }
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
ServerInfo_User *getUserInfo() const
{
return userInfo;
}
bool getLocal() const
{
return local;
}
bool getMirrored() const
{
return mirrored;
}
const QMap<QString, CardZone *> &getZones() const
{
return zones;
}
const QMap<int, ArrowItem *> &getArrows() const
{
return arrows;
}
void setCardMenu(QMenu *menu);
QMenu *getCardMenu() const;
void updateCardMenu(const CardItem *card);
bool getActive() const { return active; }
bool getActive() const
{
return active;
}
void setActive(bool _active);
void setShortcutsActive();
void setShortcutsInactive();
void updateZones();
void setConceded(bool _conceded);
bool getConceded() const { return conceded; }
bool getConceded() const
{
return conceded;
}
void setGameStarted();
qreal getMinimumWidth() const;
void setMirrored(bool _mirrored);
void processSceneSizeChange(int newPlayerWidth);
void processPlayerInfo(const ServerInfo_Player &info);
void processCardAttachment(const ServerInfo_Player &info);
void processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context);
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
PendingCommand *prepareGameCommand(const QList<const ::google::protobuf::Message *> &cmdList);
void sendGameCommand(PendingCommand *pend);
void sendGameCommand(const google::protobuf::Message &command);