Fix Bad Gameplay (#3034)
This commit is contained in:
parent
d1b95aad16
commit
bc52882ac4
6 changed files with 805 additions and 1302 deletions
|
@ -2740,10 +2740,8 @@ qreal Player::getMinimumWidth() const
|
||||||
|
|
||||||
void Player::setGameStarted()
|
void Player::setGameStarted()
|
||||||
{
|
{
|
||||||
if (local && aAlwaysRevealTopCard)
|
if (local)
|
||||||
{
|
|
||||||
aAlwaysRevealTopCard->setChecked(false);
|
aAlwaysRevealTopCard->setChecked(false);
|
||||||
}
|
|
||||||
setConceded(false);
|
setConceded(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,276 +59,268 @@ class PendingCommand;
|
||||||
|
|
||||||
const int MAX_TOKENS_PER_DIALOG = 99;
|
const int MAX_TOKENS_PER_DIALOG = 99;
|
||||||
|
|
||||||
class PlayerArea : public QObject, public QGraphicsItem
|
class PlayerArea : public QObject, public QGraphicsItem {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
private:
|
private:
|
||||||
QRectF bRect;
|
QRectF bRect;
|
||||||
|
private slots:
|
||||||
private slots:
|
void updateBg();
|
||||||
void updateBg();
|
public:
|
||||||
|
enum { Type = typeOther };
|
||||||
public:
|
int type() const { return Type; }
|
||||||
enum { Type = typeOther };
|
|
||||||
int type() const override
|
PlayerArea(QGraphicsItem *parent = 0);
|
||||||
{ return Type; }
|
QRectF boundingRect() const { return bRect; }
|
||||||
|
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget);
|
||||||
explicit PlayerArea(QGraphicsItem *parent = nullptr);
|
|
||||||
QRectF boundingRect() const override { return bRect; }
|
void setSize(qreal width, qreal height);
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
|
||||||
|
|
||||||
void setSize(qreal width, qreal height);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class Player : public QObject, public QGraphicsItem
|
class Player : public QObject, public QGraphicsItem {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
Q_INTERFACES(QGraphicsItem)
|
Q_INTERFACES(QGraphicsItem)
|
||||||
|
signals:
|
||||||
|
void openDeckEditor(const DeckLoader *deck);
|
||||||
|
void newCardAdded(AbstractCardItem *card);
|
||||||
|
// Log events
|
||||||
|
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 logCreateToken(Player *player, QString cardName, QString pt);
|
||||||
|
void logDrawCards(Player *player, int number);
|
||||||
|
void logUndoDraw(Player *player, QString cardName);
|
||||||
|
void logMoveCard(Player *player, CardItem *card, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
||||||
|
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
||||||
|
void logDestroyCard(Player *player, QString cardName);
|
||||||
|
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
||||||
|
void logUnattachCard(Player *player, QString cardName);
|
||||||
|
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
||||||
|
void logSetTapped(Player *player, CardItem *card, bool tapped);
|
||||||
|
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
||||||
|
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap);
|
||||||
|
void logSetPT(Player *player, CardItem *card, QString newPT);
|
||||||
|
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 logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
||||||
|
|
||||||
|
void sizeChanged();
|
||||||
|
void gameConceded();
|
||||||
|
public slots:
|
||||||
|
void actUntapAll();
|
||||||
|
void actRollDie();
|
||||||
|
void actCreateToken();
|
||||||
|
void actCreateAnotherToken();
|
||||||
|
void actShuffle();
|
||||||
|
void actDrawCard();
|
||||||
|
void actDrawCards();
|
||||||
|
void actUndoDraw();
|
||||||
|
void actMulligan();
|
||||||
|
void actMoveTopCardToPlayFaceDown();
|
||||||
|
void actMoveTopCardsToGrave();
|
||||||
|
void actMoveTopCardsToExile();
|
||||||
|
void actMoveTopCardToBottom();
|
||||||
|
void actMoveBottomCardToGrave();
|
||||||
|
|
||||||
signals:
|
void actViewLibrary();
|
||||||
void openDeckEditor(const DeckLoader *deck);
|
void actViewTopCards();
|
||||||
void newCardAdded(AbstractCardItem *card);
|
void actAlwaysRevealTopCard();
|
||||||
// Log events
|
void actViewGraveyard();
|
||||||
void logSay(Player *player, QString message);
|
void actRevealRandomGraveyardCard();
|
||||||
void logShuffle(Player *player, CardZone *zone);
|
void actViewRfg();
|
||||||
void logRollDie(Player *player, int sides, int roll);
|
void actViewSideboard();
|
||||||
void logCreateArrow(Player *player, Player *startPlayer, QString startCard, Player *targetPlayer, QString targetCard, bool _playerTarget);
|
|
||||||
void logCreateToken(Player *player, QString cardName, QString pt);
|
void actSayMessage();
|
||||||
void logDrawCards(Player *player, int number);
|
private slots:
|
||||||
void logUndoDraw(Player *player, QString cardName);
|
void addPlayer(Player *player);
|
||||||
void logMoveCard(Player *player, CardItem *card, CardZone *startZone, int oldX, CardZone *targetZone, int newX);
|
void removePlayer(Player *player);
|
||||||
void logFlipCard(Player *player, QString cardName, bool faceDown);
|
void playerListActionTriggered();
|
||||||
void logDestroyCard(Player *player, QString cardName);
|
|
||||||
void logAttachCard(Player *player, QString cardName, Player *targetPlayer, QString targetCardName);
|
void updateBoundingRect();
|
||||||
void logUnattachCard(Player *player, QString cardName);
|
void rearrangeZones();
|
||||||
void logSetCardCounter(Player *player, QString cardName, int counterId, int value, int oldValue);
|
|
||||||
void logSetTapped(Player *player, CardItem *card, bool tapped);
|
void actOpenDeckInDeckEditor();
|
||||||
void logSetCounter(Player *player, QString counterName, int value, int oldValue);
|
void actCreatePredefinedToken();
|
||||||
void logSetDoesntUntap(Player *player, CardItem *card, bool doesntUntap);
|
void actCreateRelatedCard();
|
||||||
void logSetPT(Player *player, CardItem *card, QString newPT);
|
void actCreateAllRelatedCards();
|
||||||
void logSetAnnotation(Player *player, CardItem *card, QString newAnnotation);
|
void cardMenuAction();
|
||||||
void logDumpZone(Player *player, CardZone *zone, int numberCards);
|
void actMoveCardXCardsFromTop();
|
||||||
void logStopDumpZone(Player *player, CardZone *zone);
|
void actCardCounterTrigger();
|
||||||
void logRevealCards(Player *player, CardZone *zone, int cardId, QString cardName, Player *otherPlayer, bool faceDown);
|
void actAttach();
|
||||||
void logAlwaysRevealTopCard(Player *player, CardZone *zone, bool reveal);
|
void actUnattach();
|
||||||
|
void actDrawArrow();
|
||||||
|
void actIncPT(int deltaP, int deltaT);
|
||||||
|
void actSetPT();
|
||||||
|
void actIncP();
|
||||||
|
void actDecP();
|
||||||
|
void actIncT();
|
||||||
|
void actDecT();
|
||||||
|
void actIncPT();
|
||||||
|
void actDecPT();
|
||||||
|
void actSetAnnotation();
|
||||||
|
void actPlay();
|
||||||
|
void actHide();
|
||||||
|
void actPlayFacedown();
|
||||||
|
void refreshShortcuts();
|
||||||
|
|
||||||
void sizeChanged();
|
private:
|
||||||
void gameConceded();
|
TabGame *game;
|
||||||
|
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,
|
||||||
|
*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;
|
||||||
|
|
||||||
public slots:
|
bool shortcutsActive;
|
||||||
void actUntapAll();
|
int defaultNumberTopCards;
|
||||||
void actRollDie();
|
int defaultNumberTopCardsToPlaceBelow;
|
||||||
void actCreateToken();
|
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
||||||
void actCreateAnotherToken();
|
bool lastTokenDestroy;
|
||||||
void actShuffle();
|
int lastTokenTableRow;
|
||||||
void actDrawCard();
|
ServerInfo_User *userInfo;
|
||||||
void actDrawCards();
|
int id;
|
||||||
void actUndoDraw();
|
bool active;
|
||||||
void actMulligan();
|
bool local;
|
||||||
void actMoveTopCardToPlayFaceDown();
|
bool mirrored;
|
||||||
void actMoveTopCardsToGrave();
|
bool handVisible;
|
||||||
void actMoveTopCardsToExile();
|
bool conceded;
|
||||||
void actMoveTopCardToBottom();
|
|
||||||
void actMoveBottomCardToGrave();
|
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 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);
|
||||||
|
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation);
|
||||||
|
QString dbNameFromTokenDisplayName(const QString &tokenName);
|
||||||
|
|
||||||
void actViewLibrary();
|
QRectF bRect;
|
||||||
void actViewTopCards();
|
|
||||||
void actAlwaysRevealTopCard();
|
|
||||||
void actViewGraveyard();
|
|
||||||
void actRevealRandomGraveyardCard();
|
|
||||||
void actViewRfg();
|
|
||||||
void actViewSideboard();
|
|
||||||
|
|
||||||
void actSayMessage();
|
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);
|
||||||
|
void eventRollDie(const Event_RollDie &event);
|
||||||
|
void eventCreateArrow(const Event_CreateArrow &event);
|
||||||
|
void eventDeleteArrow(const Event_DeleteArrow &event);
|
||||||
|
void eventCreateToken(const Event_CreateToken &event);
|
||||||
|
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context);
|
||||||
|
void eventSetCardCounter(const Event_SetCardCounter &event);
|
||||||
|
void eventCreateCounter(const Event_CreateCounter &event);
|
||||||
|
void eventSetCounter(const Event_SetCounter &event);
|
||||||
|
void eventDelCounter(const Event_DelCounter &event);
|
||||||
|
void eventDumpZone(const Event_DumpZone &event);
|
||||||
|
void eventStopDumpZone(const Event_StopDumpZone &event);
|
||||||
|
void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
|
||||||
|
void eventFlipCard(const Event_FlipCard &event);
|
||||||
|
void eventDestroyCard(const Event_DestroyCard &event);
|
||||||
|
void eventAttachCard(const Event_AttachCard &event);
|
||||||
|
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};
|
||||||
|
|
||||||
private slots:
|
enum { Type = typeOther };
|
||||||
void addPlayer(Player *player);
|
int type() const { return Type; }
|
||||||
void removePlayer(Player *player);
|
QRectF boundingRect() const;
|
||||||
void playerListActionTriggered();
|
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);
|
||||||
|
void addZone(CardZone *z);
|
||||||
|
|
||||||
void updateBoundingRect();
|
AbstractCounter *addCounter(const ServerInfo_Counter &counter);
|
||||||
void rearrangeZones();
|
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; }
|
||||||
|
|
||||||
void actOpenDeckInDeckEditor();
|
Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent);
|
||||||
void actCreatePredefinedToken();
|
~Player();
|
||||||
void actCreateRelatedCard();
|
void retranslateUi();
|
||||||
void actCreateAllRelatedCards();
|
void clear();
|
||||||
void cardMenuAction();
|
TabGame *getGame() const { return game; }
|
||||||
void actMoveCardXCardsFromTop();
|
void setDeck(const DeckLoader &_deck);
|
||||||
void actCardCounterTrigger();
|
QMenu *getPlayerMenu() const { return playerMenu; }
|
||||||
void actAttach();
|
int getId() const { return id; }
|
||||||
void actUnattach();
|
QString getName() const;
|
||||||
void actDrawArrow();
|
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||||
void actIncPT(int deltaP, int deltaT);
|
bool getLocal() const { return local; }
|
||||||
void actSetPT();
|
bool getMirrored() const { return mirrored; }
|
||||||
void actIncP();
|
const QMap<QString, CardZone *> &getZones() const { return zones; }
|
||||||
void actDecP();
|
const QMap<int, ArrowItem *> &getArrows() const { return arrows; }
|
||||||
void actIncT();
|
void setCardMenu(QMenu *menu);
|
||||||
void actDecT();
|
QMenu *getCardMenu() const;
|
||||||
void actIncPT();
|
void updateCardMenu(const CardItem *card);
|
||||||
void actDecPT();
|
bool getActive() const { return active; }
|
||||||
void actSetAnnotation();
|
void setActive(bool _active);
|
||||||
void actPlay();
|
void setShortcutsActive();
|
||||||
void actHide();
|
void setShortcutsInactive();
|
||||||
void actPlayFacedown();
|
void updateZones();
|
||||||
void refreshShortcuts();
|
|
||||||
|
void setConceded(bool _conceded);
|
||||||
|
bool getConceded() const { return conceded; }
|
||||||
|
|
||||||
private:
|
void setGameStarted();
|
||||||
TabGame *game;
|
|
||||||
QMenu *playerMenu, *handMenu, *moveHandMenu, *graveMenu, *moveGraveMenu, *rfgMenu, *moveRfgMenu, *libraryMenu, *sbMenu, *countersMenu, *sayMenu, *createPredefinedTokenMenu,
|
qreal getMinimumWidth() const;
|
||||||
*mRevealLibrary, *mRevealTopCard, *mRevealHand, *mRevealRandomHandCard, *mRevealRandomGraveyardCard;
|
void setMirrored(bool _mirrored);
|
||||||
QList<QMenu *> playerLists;
|
void processSceneSizeChange(int newPlayerWidth);
|
||||||
QList<QAction *> allPlayersActions;
|
|
||||||
QAction *aMoveHandToTopLibrary, *aMoveHandToBottomLibrary, *aMoveHandToGrave, *aMoveHandToRfg,
|
void processPlayerInfo(const ServerInfo_Player &info);
|
||||||
*aMoveGraveToTopLibrary, *aMoveGraveToBottomLibrary, *aMoveGraveToHand, *aMoveGraveToRfg,
|
void processCardAttachment(const ServerInfo_Player &info);
|
||||||
*aMoveRfgToTopLibrary, *aMoveRfgToBottomLibrary, *aMoveRfgToHand, *aMoveRfgToGrave,
|
|
||||||
*aViewLibrary, *aViewTopCards, *aAlwaysRevealTopCard, *aOpenDeckInDeckEditor, *aMoveTopCardsToGrave, *aMoveTopCardsToExile, *aMoveTopCardToBottom,
|
void processGameEvent(GameEvent::GameEventType type, const GameEvent &event, const GameEventContext &context);
|
||||||
*aViewGraveyard, *aViewRfg, *aViewSideboard,
|
|
||||||
*aDrawCard, *aDrawCards, *aUndoDraw, *aMulligan, *aShuffle, *aMoveTopToPlayFaceDown,
|
|
||||||
*aUntapAll, *aRollDie, *aCreateToken, *aCreateAnotherToken,
|
|
||||||
*aCardMenu, *aMoveBottomCardToGrave;
|
|
||||||
|
|
||||||
QList<QAction *> aAddCounter, aSetCounter, aRemoveCounter;
|
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
||||||
QAction *aPlay, *aPlayFacedown,
|
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
||||||
*aHide,
|
void sendGameCommand(PendingCommand *pend);
|
||||||
*aTap, *aDoesntUntap, *aAttach, *aUnattach, *aDrawArrow, *aSetPT, *aIncP, *aDecP, *aIncT, *aDecT, *aIncPT, *aDecPT, *aSetAnnotation, *aFlip, *aPeek, *aClone,
|
void sendGameCommand(const google::protobuf::Message &command);
|
||||||
*aMoveToTopLibrary, *aMoveToBottomLibrary, *aMoveToHand, *aMoveToGraveyard, *aMoveToExile, *aMoveToXfromTopOfLibrary;
|
|
||||||
|
|
||||||
bool shortcutsActive;
|
void setLastToken(CardInfo *cardInfo);
|
||||||
int defaultNumberTopCards;
|
|
||||||
int defaultNumberTopCardsToPlaceBelow;
|
|
||||||
QString lastTokenName, lastTokenColor, lastTokenPT, lastTokenAnnotation;
|
|
||||||
bool lastTokenDestroy;
|
|
||||||
int lastTokenTableRow;
|
|
||||||
ServerInfo_User *userInfo;
|
|
||||||
int id;
|
|
||||||
bool active;
|
|
||||||
bool local;
|
|
||||||
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 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);
|
|
||||||
bool createRelatedFromRelation(const CardItem *sourceCard, const CardRelation *cardRelation);
|
|
||||||
QString dbNameFromTokenDisplayName(const QString &tokenName);
|
|
||||||
|
|
||||||
QRectF bRect;
|
|
||||||
|
|
||||||
QMap<int, AbstractCounter *> counters;
|
|
||||||
QMap<int, ArrowItem *> arrows;
|
|
||||||
void rearrangeCounters();
|
|
||||||
|
|
||||||
void initSayMenu();
|
|
||||||
|
|
||||||
void eventGameSay(const Event_GameSay &event);
|
|
||||||
void eventShuffle(const Event_Shuffle &event);
|
|
||||||
void eventRollDie(const Event_RollDie &event);
|
|
||||||
void eventCreateArrow(const Event_CreateArrow &event);
|
|
||||||
void eventDeleteArrow(const Event_DeleteArrow &event);
|
|
||||||
void eventCreateToken(const Event_CreateToken &event);
|
|
||||||
void eventSetCardAttr(const Event_SetCardAttr &event, const GameEventContext &context);
|
|
||||||
void eventSetCardCounter(const Event_SetCardCounter &event);
|
|
||||||
void eventCreateCounter(const Event_CreateCounter &event);
|
|
||||||
void eventSetCounter(const Event_SetCounter &event);
|
|
||||||
void eventDelCounter(const Event_DelCounter &event);
|
|
||||||
void eventDumpZone(const Event_DumpZone &event);
|
|
||||||
void eventStopDumpZone(const Event_StopDumpZone &event);
|
|
||||||
void eventMoveCard(const Event_MoveCard &event, const GameEventContext &context);
|
|
||||||
void eventFlipCard(const Event_FlipCard &event);
|
|
||||||
void eventDestroyCard(const Event_DestroyCard &event);
|
|
||||||
void eventAttachCard(const Event_AttachCard &event);
|
|
||||||
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 { Type = typeOther };
|
|
||||||
int type() const override { return Type; }
|
|
||||||
QRectF boundingRect() const override;
|
|
||||||
void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override;
|
|
||||||
|
|
||||||
void playCard(CardItem *c, bool faceDown, bool tapped);
|
|
||||||
void addCard(CardItem *c);
|
|
||||||
void deleteCard(CardItem *c);
|
|
||||||
void addZone(CardZone *z);
|
|
||||||
|
|
||||||
AbstractCounter *addCounter(const ServerInfo_Counter &counter);
|
|
||||||
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; }
|
|
||||||
|
|
||||||
Player(const ServerInfo_User &info, int _id, bool _local, TabGame *_parent);
|
|
||||||
~Player() override;
|
|
||||||
void retranslateUi();
|
|
||||||
void clear();
|
|
||||||
TabGame *getGame() const { return game; }
|
|
||||||
void setDeck(const DeckLoader &_deck);
|
|
||||||
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; }
|
|
||||||
void setCardMenu(QMenu *menu);
|
|
||||||
QMenu *getCardMenu() const;
|
|
||||||
void updateCardMenu(const CardItem *card);
|
|
||||||
bool getActive() const { return active; }
|
|
||||||
void setActive(bool _active);
|
|
||||||
void setShortcutsActive();
|
|
||||||
void setShortcutsInactive();
|
|
||||||
void updateZones();
|
|
||||||
|
|
||||||
void setConceded(bool _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);
|
|
||||||
void sendGameCommand(PendingCommand *pend);
|
|
||||||
void sendGameCommand(const google::protobuf::Message &command);
|
|
||||||
|
|
||||||
void setLastToken(CardInfo *cardInfo);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -60,216 +60,208 @@ class LineEditCompleter;
|
||||||
class QDockWidget;
|
class QDockWidget;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
|
|
||||||
class ToggleButton : public QPushButton
|
class ToggleButton : public QPushButton {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
bool state;
|
bool state;
|
||||||
|
signals:
|
||||||
signals:
|
void stateChanged();
|
||||||
void stateChanged();
|
public:
|
||||||
|
ToggleButton(QWidget *parent = 0);
|
||||||
public:
|
bool getState() const { return state; }
|
||||||
explicit ToggleButton(QWidget *parent = nullptr);
|
void setState(bool _state);
|
||||||
bool getState() const { return state; }
|
protected:
|
||||||
void setState(bool _state);
|
void paintEvent(QPaintEvent *event);
|
||||||
|
|
||||||
protected:
|
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class DeckViewContainer : public QWidget
|
class DeckViewContainer : public QWidget {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QPushButton *loadLocalButton, *loadRemoteButton;
|
QPushButton *loadLocalButton, *loadRemoteButton;
|
||||||
ToggleButton *readyStartButton, *sideboardLockButton;
|
ToggleButton *readyStartButton, *sideboardLockButton;
|
||||||
DeckView *deckView;
|
DeckView *deckView;
|
||||||
TabGame *parentGame;
|
TabGame *parentGame;
|
||||||
int playerId;
|
int playerId;
|
||||||
|
private slots:
|
||||||
private slots:
|
void loadLocalDeck();
|
||||||
void loadLocalDeck();
|
void loadRemoteDeck();
|
||||||
void loadRemoteDeck();
|
void readyStart();
|
||||||
void readyStart();
|
void deckSelectFinished(const Response &r);
|
||||||
void deckSelectFinished(const Response &r);
|
void sideboardPlanChanged();
|
||||||
void sideboardPlanChanged();
|
void sideboardLockButtonClicked();
|
||||||
void sideboardLockButtonClicked();
|
void updateSideboardLockButtonText();
|
||||||
void updateSideboardLockButtonText();
|
void refreshShortcuts();
|
||||||
void refreshShortcuts();
|
signals:
|
||||||
|
void newCardAdded(AbstractCardItem *card);
|
||||||
signals:
|
void notIdle();
|
||||||
void newCardAdded(AbstractCardItem *card);
|
public:
|
||||||
|
DeckViewContainer(int _playerId, TabGame *parent);
|
||||||
public:
|
void retranslateUi();
|
||||||
DeckViewContainer(int _playerId, TabGame *parent);
|
void setButtonsVisible(bool _visible);
|
||||||
void retranslateUi();
|
void setReadyStart(bool ready);
|
||||||
void setReadyStart(bool ready);
|
void setSideboardLocked(bool locked);
|
||||||
void setSideboardLocked(bool locked);
|
void setDeck(const DeckLoader &deck);
|
||||||
void setDeck(const DeckLoader &deck);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TabGame : public Tab
|
class TabGame : public Tab {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
QTimer *gameTimer;
|
QTimer *gameTimer;
|
||||||
int secondsElapsed;
|
int secondsElapsed;
|
||||||
QList<AbstractClient *> clients;
|
QList<AbstractClient *> clients;
|
||||||
ServerInfo_Game gameInfo;
|
ServerInfo_Game gameInfo;
|
||||||
QMap<int, QString> roomGameTypes;
|
QMap<int, QString> roomGameTypes;
|
||||||
int hostId;
|
int hostId;
|
||||||
int localPlayerId;
|
int localPlayerId;
|
||||||
const bool isLocalGame;
|
const bool isLocalGame;
|
||||||
bool spectator;
|
bool spectator;
|
||||||
QMap<int, Player *> players;
|
QMap<int, Player *> players;
|
||||||
QMap<int, ServerInfo_User> spectators;
|
QMap<int, ServerInfo_User> spectators;
|
||||||
bool gameStateKnown;
|
bool gameStateKnown;
|
||||||
bool resuming;
|
bool resuming;
|
||||||
int currentPhase;
|
QStringList phasesList;
|
||||||
int activePlayer;
|
int currentPhase;
|
||||||
CardItem *activeCard;
|
int activePlayer;
|
||||||
bool gameClosed;
|
CardItem *activeCard;
|
||||||
QStringList gameTypes;
|
bool gameClosed;
|
||||||
QCompleter *completer;
|
QStringList gameTypes;
|
||||||
QStringList autocompleteUserList;
|
QCompleter *completer;
|
||||||
QStackedWidget * mainWidget;
|
QStringList autocompleteUserList;
|
||||||
|
QStackedWidget * mainWidget;
|
||||||
|
|
||||||
|
// Replay related members
|
||||||
|
GameReplay *replay;
|
||||||
|
int currentReplayStep;
|
||||||
|
QList<int> replayTimeline;
|
||||||
|
ReplayTimelineWidget *timelineWidget;
|
||||||
|
QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton;
|
||||||
|
|
||||||
// Replay related members
|
CardFrame *cardInfo;
|
||||||
GameReplay *replay;
|
PlayerListWidget *playerListWidget;
|
||||||
int currentReplayStep;
|
QLabel *timeElapsedLabel;
|
||||||
QList<int> replayTimeline;
|
MessageLogWidget *messageLog;
|
||||||
ReplayTimelineWidget *timelineWidget;
|
QLabel *sayLabel;
|
||||||
QToolButton *replayStartButton, *replayPauseButton, *replayFastForwardButton;
|
LineEditCompleter *sayEdit;
|
||||||
|
PhasesToolbar *phasesToolbar;
|
||||||
|
GameScene *scene;
|
||||||
|
GameView *gameView;
|
||||||
|
QMap<int, DeckViewContainer *> deckViewContainers;
|
||||||
|
QVBoxLayout *cardVInfoLayout, *messageLogLayout, *gamePlayAreaVBox, *deckViewContainerLayout;
|
||||||
|
QHBoxLayout *cardHInfoLayout, *sayHLayout, *mainHLayout, *replayControlLayout;
|
||||||
|
QWidget *cardBoxLayoutWidget, *messageLogLayoutWidget, *gamePlayAreaWidget, *deckViewContainerWidget, *replayControlWidget;
|
||||||
|
QDockWidget *cardInfoDock, *messageLayoutDock, *playerListDock, *replayDock;
|
||||||
|
QAction *playersSeparator;
|
||||||
|
QMenu *gameMenu, *phasesMenu, *viewMenu, *cardInfoDockMenu, *messageLayoutDockMenu, *playerListDockMenu, *replayDockMenu;
|
||||||
|
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout, *aResetReplayLayout;
|
||||||
|
QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aMessageLayoutDockVisible, *aMessageLayoutDockFloating, *aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating;
|
||||||
|
QList<QAction *> phaseActions;
|
||||||
|
|
||||||
CardFrame *cardInfo;
|
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
||||||
PlayerListWidget *playerListWidget;
|
|
||||||
QLabel *timeElapsedLabel;
|
|
||||||
MessageLogWidget *messageLog;
|
|
||||||
QLabel *sayLabel;
|
|
||||||
LineEditCompleter *sayEdit;
|
|
||||||
PhasesToolbar *phasesToolbar;
|
|
||||||
GameScene *scene;
|
|
||||||
GameView *gameView;
|
|
||||||
QMap<int, DeckViewContainer *> deckViewContainers;
|
|
||||||
QVBoxLayout *cardVInfoLayout, *messageLogLayout, *gamePlayAreaVBox, *deckViewContainerLayout;
|
|
||||||
QHBoxLayout *cardHInfoLayout, *sayHLayout, *replayControlLayout;
|
|
||||||
QWidget *cardBoxLayoutWidget, *messageLogLayoutWidget, *gamePlayAreaWidget, *deckViewContainerWidget, *replayControlWidget;
|
|
||||||
QDockWidget *cardInfoDock, *messageLayoutDock, *playerListDock, *replayDock;
|
|
||||||
QAction *playersSeparator;
|
|
||||||
QMenu *gameMenu, *phasesMenu, *viewMenu, *cardInfoDockMenu, *messageLayoutDockMenu, *playerListDockMenu, *replayDockMenu;
|
|
||||||
QAction *aGameInfo, *aConcede, *aLeaveGame, *aCloseReplay, *aNextPhase, *aNextTurn, *aRemoveLocalArrows, *aRotateViewCW, *aRotateViewCCW, *aResetLayout;
|
|
||||||
QAction *aCardInfoDockVisible, *aCardInfoDockFloating, *aMessageLayoutDockVisible, *aMessageLayoutDockFloating, *aPlayerListDockVisible, *aPlayerListDockFloating, *aReplayDockVisible, *aReplayDockFloating;
|
|
||||||
QList<QAction *> phaseActions;
|
|
||||||
|
|
||||||
Player *addPlayer(int playerId, const ServerInfo_User &info);
|
void startGame(bool resuming);
|
||||||
|
void stopGame();
|
||||||
|
void closeGame();
|
||||||
|
|
||||||
void startGame(bool resuming);
|
void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context);
|
||||||
void stopGame();
|
void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
||||||
void closeGame();
|
|
||||||
|
void eventGameStateChanged(const Event_GameStateChanged &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventJoin(const Event_Join &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventKicked(const Event_Kicked &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventGameHostChanged(const Event_GameHostChanged &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventGameClosed(const Event_GameClosed &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
Player *setActivePlayer(int id);
|
||||||
|
void eventSetActivePlayer(const Event_SetActivePlayer &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void setActivePhase(int phase);
|
||||||
|
void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void eventPing(const Event_Ping &event, int eventPlayerId, const GameEventContext &context);
|
||||||
|
void emitUserEvent();
|
||||||
|
void createMenuItems();
|
||||||
|
void createReplayMenuItems();
|
||||||
|
void createViewMenuItems();
|
||||||
|
void createCardInfoDock(bool bReplay=false);
|
||||||
|
void createPlayerListDock(bool bReplay=false);
|
||||||
|
void createMessageDock(bool bReplay=false);
|
||||||
|
void createPlayAreaWidget(bool bReplay=false);
|
||||||
|
void createDeckViewContainerWidget(bool bReplay=false);
|
||||||
|
void createReplayDock();
|
||||||
|
QString getLeaveReason(Event_Leave::LeaveReason reason);
|
||||||
|
signals:
|
||||||
|
void gameClosing(TabGame *tab);
|
||||||
|
void playerAdded(Player *player);
|
||||||
|
void playerRemoved(Player *player);
|
||||||
|
void containerProcessingStarted(const GameEventContext &context);
|
||||||
|
void containerProcessingDone();
|
||||||
|
void openMessageDialog(const QString &userName, bool focus);
|
||||||
|
void openDeckEditor(const DeckLoader *deck);
|
||||||
|
void notIdle();
|
||||||
|
private slots:
|
||||||
|
void replayNextEvent();
|
||||||
|
void replayFinished();
|
||||||
|
void replayStartButtonClicked();
|
||||||
|
void replayPauseButtonClicked();
|
||||||
|
void replayFastForwardButtonToggled(bool checked);
|
||||||
|
|
||||||
|
void incrementGameTime();
|
||||||
|
void adminLockChanged(bool lock);
|
||||||
|
void newCardAdded(AbstractCardItem *card);
|
||||||
|
void updateCardMenu(AbstractCardItem *card);
|
||||||
|
|
||||||
|
void actGameInfo();
|
||||||
|
void actConcede();
|
||||||
|
void actLeaveGame();
|
||||||
|
void actRemoveLocalArrows();
|
||||||
|
void actRotateViewCW();
|
||||||
|
void actRotateViewCCW();
|
||||||
|
void actSay();
|
||||||
|
void actPhaseAction();
|
||||||
|
void actNextPhase();
|
||||||
|
void actNextTurn();
|
||||||
|
|
||||||
void eventSpectatorSay(const Event_GameSay &event, int eventPlayerId, const GameEventContext &context);
|
void addMentionTag(QString value);
|
||||||
void eventSpectatorLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
void commandFinished(const Response &response);
|
||||||
|
|
||||||
|
void refreshShortcuts();
|
||||||
|
|
||||||
|
void loadLayout();
|
||||||
|
void actCompleterChanged();
|
||||||
|
void actResetLayout();
|
||||||
|
void freeDocksSize();
|
||||||
|
|
||||||
void eventGameStateChanged(const Event_GameStateChanged &event, int eventPlayerId, const GameEventContext &context);
|
bool eventFilter(QObject *o, QEvent *e);
|
||||||
void eventPlayerPropertiesChanged(const Event_PlayerPropertiesChanged &event, int eventPlayerId, const GameEventContext &context);
|
void dockVisibleTriggered();
|
||||||
void eventJoin(const Event_Join &event, int eventPlayerId, const GameEventContext &context);
|
void dockFloatingTriggered();
|
||||||
void eventLeave(const Event_Leave &event, int eventPlayerId, const GameEventContext &context);
|
void dockTopLevelChanged(bool topLevel);
|
||||||
void eventKicked(const Event_Kicked &event, int eventPlayerId, const GameEventContext &context);
|
public:
|
||||||
void eventGameHostChanged(const Event_GameHostChanged &event, int eventPlayerId, const GameEventContext &context);
|
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
||||||
void eventGameClosed(const Event_GameClosed &event, int eventPlayerId, const GameEventContext &context);
|
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
|
||||||
Player *setActivePlayer(int id);
|
~TabGame();
|
||||||
void eventSetActivePlayer(const Event_SetActivePlayer &event, int eventPlayerId, const GameEventContext &context);
|
void retranslateUi();
|
||||||
void setActivePhase(int phase);
|
void updatePlayerListDockTitle();
|
||||||
void eventSetActivePhase(const Event_SetActivePhase &event, int eventPlayerId, const GameEventContext &context);
|
void closeRequest();
|
||||||
void emitUserEvent();
|
const QMap<int, Player *> &getPlayers() const { return players; }
|
||||||
void createMenuItems();
|
CardItem *getCard(int playerId, const QString &zoneName, int cardId) const;
|
||||||
void createReplayMenuItems();
|
bool isHost() const { return hostId == localPlayerId; }
|
||||||
void createViewMenuItems();
|
bool getIsLocalGame() const { return isLocalGame; }
|
||||||
void createCardInfoDock(bool bReplay=false);
|
int getGameId() const { return gameInfo.game_id(); }
|
||||||
void createPlayerListDock(bool bReplay=false);
|
QString getTabText() const;
|
||||||
void createMessageDock(bool bReplay=false);
|
bool getSpectator() const { return spectator; }
|
||||||
void createPlayAreaWidget(bool bReplay=false);
|
bool getSpectatorsSeeEverything() const { return gameInfo.spectators_omniscient(); }
|
||||||
void createDeckViewContainerWidget(bool bReplay=false);
|
bool isSpectator();
|
||||||
void createReplayDock();
|
Player *getActiveLocalPlayer() const;
|
||||||
QString getLeaveReason(Event_Leave::LeaveReason reason);
|
AbstractClient *getClientForPlayer(int playerId) const;
|
||||||
|
|
||||||
signals:
|
void setActiveCard(CardItem *_card) { activeCard = _card; }
|
||||||
void gameClosing(TabGame *tab);
|
CardItem *getActiveCard() const { return activeCard; }
|
||||||
void playerAdded(Player *player);
|
|
||||||
void playerRemoved(Player *player);
|
|
||||||
void containerProcessingStarted(const GameEventContext &context);
|
|
||||||
void containerProcessingDone();
|
|
||||||
void openMessageDialog(const QString &userName, bool focus);
|
|
||||||
void openDeckEditor(const DeckLoader *deck);
|
|
||||||
|
|
||||||
private slots:
|
void processGameEventContainer(const GameEventContainer &cont, AbstractClient *client);
|
||||||
void replayNextEvent();
|
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
||||||
void replayFinished();
|
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
||||||
void replayStartButtonClicked();
|
public slots:
|
||||||
void replayPauseButtonClicked();
|
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
||||||
void replayFastForwardButtonToggled(bool checked);
|
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
||||||
|
|
||||||
void incrementGameTime();
|
|
||||||
void adminLockChanged(bool lock);
|
|
||||||
void newCardAdded(AbstractCardItem *card);
|
|
||||||
void updateCardMenu(AbstractCardItem *card);
|
|
||||||
|
|
||||||
void actGameInfo();
|
|
||||||
void actConcede();
|
|
||||||
void actLeaveGame();
|
|
||||||
void actRemoveLocalArrows();
|
|
||||||
void actRotateViewCW();
|
|
||||||
void actRotateViewCCW();
|
|
||||||
void actSay();
|
|
||||||
void actPhaseAction();
|
|
||||||
void actNextPhase();
|
|
||||||
void actNextTurn();
|
|
||||||
|
|
||||||
void addMentionTag(QString value);
|
|
||||||
void commandFinished(const Response &response);
|
|
||||||
|
|
||||||
void refreshShortcuts();
|
|
||||||
|
|
||||||
void loadLayout();
|
|
||||||
void actCompleterChanged();
|
|
||||||
void actResetLayout();
|
|
||||||
void freeDocksSize();
|
|
||||||
|
|
||||||
bool eventFilter(QObject *o, QEvent *e) override;
|
|
||||||
void dockVisibleTriggered();
|
|
||||||
void dockFloatingTriggered();
|
|
||||||
void dockTopLevelChanged(bool topLevel);
|
|
||||||
|
|
||||||
public:
|
|
||||||
TabGame(TabSupervisor *_tabSupervisor, QList<AbstractClient *> &_clients, const Event_GameJoined &event, const QMap<int, QString> &_roomGameTypes);
|
|
||||||
TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
|
|
||||||
~TabGame() override;
|
|
||||||
void retranslateUi() override;
|
|
||||||
void updatePlayerListDockTitle();
|
|
||||||
void closeRequest() override;
|
|
||||||
const QMap<int, Player *> &getPlayers() const { return players; }
|
|
||||||
CardItem *getCard(int playerId, const QString &zoneName, int cardId) const;
|
|
||||||
bool isHost() const { return hostId == localPlayerId; }
|
|
||||||
bool getIsLocalGame() const { return isLocalGame; }
|
|
||||||
int getGameId() const { return gameInfo.game_id(); }
|
|
||||||
QString getTabText() const override;
|
|
||||||
bool getSpectator() const { return spectator; }
|
|
||||||
bool getSpectatorsSeeEverything() const { return gameInfo.spectators_omniscient(); }
|
|
||||||
bool isSpectator();
|
|
||||||
Player *getActiveLocalPlayer() const;
|
|
||||||
AbstractClient *getClientForPlayer(int playerId) const;
|
|
||||||
|
|
||||||
void setActiveCard(CardItem *_card) { activeCard = _card; }
|
|
||||||
CardItem *getActiveCard() const { return activeCard; }
|
|
||||||
|
|
||||||
void processGameEventContainer(const GameEventContainer &cont, AbstractClient *client);
|
|
||||||
PendingCommand *prepareGameCommand(const ::google::protobuf::Message &cmd);
|
|
||||||
PendingCommand *prepareGameCommand(const QList< const ::google::protobuf::Message * > &cmdList);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
void sendGameCommand(PendingCommand *pend, int playerId = -1);
|
|
||||||
void sendGameCommand(const ::google::protobuf::Message &command, int playerId = -1);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,8 @@
|
||||||
#include "pb/serverinfo_room.pb.h"
|
#include "pb/serverinfo_room.pb.h"
|
||||||
#include "pb/moderator_commands.pb.h"
|
#include "pb/moderator_commands.pb.h"
|
||||||
|
|
||||||
CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent)
|
CloseButton::CloseButton(QWidget *parent)
|
||||||
|
: QAbstractButton(parent)
|
||||||
{
|
{
|
||||||
setFocusPolicy(Qt::NoFocus);
|
setFocusPolicy(Qt::NoFocus);
|
||||||
setCursor(Qt::ArrowCursor);
|
setCursor(Qt::ArrowCursor);
|
||||||
|
@ -38,9 +39,9 @@ CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent)
|
||||||
QSize CloseButton::sizeHint() const
|
QSize CloseButton::sizeHint() const
|
||||||
{
|
{
|
||||||
ensurePolished();
|
ensurePolished();
|
||||||
int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, nullptr, this);
|
int width = style()->pixelMetric(QStyle::PM_TabCloseIndicatorWidth, 0, this);
|
||||||
int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, nullptr, this);
|
int height = style()->pixelMetric(QStyle::PM_TabCloseIndicatorHeight, 0, this);
|
||||||
return {width, height};
|
return QSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CloseButton::enterEvent(QEvent *event)
|
void CloseButton::enterEvent(QEvent *event)
|
||||||
|
@ -62,34 +63,24 @@ void CloseButton::paintEvent(QPaintEvent * /*event*/)
|
||||||
opt.init(this);
|
opt.init(this);
|
||||||
opt.state |= QStyle::State_AutoRaise;
|
opt.state |= QStyle::State_AutoRaise;
|
||||||
if (isEnabled() && underMouse() && !isChecked() && !isDown())
|
if (isEnabled() && underMouse() && !isChecked() && !isDown())
|
||||||
{
|
|
||||||
opt.state |= QStyle::State_Raised;
|
opt.state |= QStyle::State_Raised;
|
||||||
}
|
|
||||||
|
|
||||||
if (isChecked())
|
if (isChecked())
|
||||||
{
|
|
||||||
opt.state |= QStyle::State_On;
|
opt.state |= QStyle::State_On;
|
||||||
}
|
|
||||||
|
|
||||||
if (isDown())
|
if (isDown())
|
||||||
{
|
|
||||||
opt.state |= QStyle::State_Sunken;
|
opt.state |= QStyle::State_Sunken;
|
||||||
}
|
|
||||||
|
if (const QTabBar *tb = qobject_cast<const QTabBar *>(parent())) {
|
||||||
if (const auto *tb = qobject_cast<const QTabBar *>(parent()))
|
|
||||||
{
|
|
||||||
int index = tb->currentIndex();
|
int index = tb->currentIndex();
|
||||||
auto position = static_cast<QTabBar::ButtonPosition>(style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb));
|
QTabBar::ButtonPosition position = (QTabBar::ButtonPosition) style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tb);
|
||||||
if (tb->tabButton(index, position) == this)
|
if (tb->tabButton(index, position) == this)
|
||||||
{
|
|
||||||
opt.state |= QStyle::State_Selected;
|
opt.state |= QStyle::State_Selected;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
|
style()->drawPrimitive(QStyle::PE_IndicatorTabClose, &opt, &p, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent) : QTabWidget(parent), userInfo(nullptr), client(_client), tabServer(nullptr), tabUserLists(nullptr), tabDeckStorage(nullptr), tabReplays(nullptr), tabAdmin(nullptr), tabLog(nullptr)
|
TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
||||||
|
: QTabWidget(parent), userInfo(0), client(_client), tabServer(0), tabUserLists(0), tabDeckStorage(0), tabReplays(0), tabAdmin(0), tabLog(0)
|
||||||
{
|
{
|
||||||
setElideMode(Qt::ElideRight);
|
setElideMode(Qt::ElideRight);
|
||||||
setMovable(true);
|
setMovable(true);
|
||||||
|
@ -122,63 +113,42 @@ void TabSupervisor::retranslateUi()
|
||||||
tabs.append(tabLog);
|
tabs.append(tabLog);
|
||||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||||
while (roomIterator.hasNext())
|
while (roomIterator.hasNext())
|
||||||
{
|
|
||||||
tabs.append(roomIterator.next().value());
|
tabs.append(roomIterator.next().value());
|
||||||
}
|
|
||||||
|
|
||||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||||
while (gameIterator.hasNext())
|
while (gameIterator.hasNext())
|
||||||
{
|
|
||||||
tabs.append(gameIterator.next().value());
|
tabs.append(gameIterator.next().value());
|
||||||
}
|
|
||||||
|
|
||||||
QListIterator<TabGame *> replayIterator(replayTabs);
|
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||||
while (replayIterator.hasNext())
|
while (replayIterator.hasNext())
|
||||||
{
|
|
||||||
tabs.append(replayIterator.next());
|
tabs.append(replayIterator.next());
|
||||||
}
|
|
||||||
|
|
||||||
QListIterator<TabDeckEditor *> deckEditorIterator(deckEditorTabs);
|
QListIterator<TabDeckEditor *> deckEditorIterator(deckEditorTabs);
|
||||||
while (deckEditorIterator.hasNext())
|
while (deckEditorIterator.hasNext())
|
||||||
{
|
|
||||||
tabs.append(deckEditorIterator.next());
|
tabs.append(deckEditorIterator.next());
|
||||||
}
|
|
||||||
|
|
||||||
QMapIterator<QString, TabMessage *> messageIterator(messageTabs);
|
QMapIterator<QString, TabMessage *> messageIterator(messageTabs);
|
||||||
while (messageIterator.hasNext())
|
while (messageIterator.hasNext())
|
||||||
{
|
|
||||||
tabs.append(messageIterator.next().value());
|
tabs.append(messageIterator.next().value());
|
||||||
}
|
|
||||||
|
|
||||||
for (auto &tab : tabs)
|
for (int i = 0; i < tabs.size(); ++i)
|
||||||
{
|
if (tabs[i]) {
|
||||||
if (tab)
|
int idx = indexOf(tabs[i]);
|
||||||
{
|
QString tabText = tabs[i]->getTabText();
|
||||||
int idx = indexOf(tab);
|
|
||||||
QString tabText = tab->getTabText();
|
|
||||||
setTabText(idx, sanitizeTabName(tabText));
|
setTabText(idx, sanitizeTabName(tabText));
|
||||||
setTabToolTip(idx, sanitizeHtml(tabText));
|
setTabToolTip(idx, sanitizeHtml(tabText));
|
||||||
tab->retranslateUi();
|
tabs[i]->retranslateUi();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabSupervisor::closeRequest()
|
bool TabSupervisor::closeRequest()
|
||||||
{
|
{
|
||||||
if (getGameCount())
|
if (getGameCount()) {
|
||||||
{
|
if (QMessageBox::question(this, tr("Are you sure?"), tr("There are still open games. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No) {
|
||||||
if (QMessageBox::question(this, tr("Are you sure?"), tr("There are still open games. Are you sure you want to quit?"), QMessageBox::Yes | QMessageBox::No, QMessageBox::No) == QMessageBox::No)
|
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TabDeckEditor *tab : deckEditorTabs)
|
foreach(TabDeckEditor *tab, deckEditorTabs)
|
||||||
{
|
{
|
||||||
if (!tab->confirmClose())
|
if(!tab->confirmClose())
|
||||||
{
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -215,52 +185,53 @@ int TabSupervisor::myAddTab(Tab *tab)
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::start(const ServerInfo_User &_userInfo)
|
void TabSupervisor::start(const ServerInfo_User &_userInfo) {
|
||||||
{
|
|
||||||
isLocalGame = false;
|
isLocalGame = false;
|
||||||
userInfo = new ServerInfo_User(_userInfo);
|
userInfo = new ServerInfo_User(_userInfo);
|
||||||
|
|
||||||
tabServer = new TabServer(this, client);
|
tabServer = new TabServer(this, client);
|
||||||
connect(tabServer, SIGNAL(roomJoined(const ServerInfo_Room &, bool)), this, SLOT(addRoomTab(const ServerInfo_Room &, bool)));
|
connect(tabServer, SIGNAL(roomJoined(
|
||||||
|
const ServerInfo_Room &, bool)), this, SLOT(addRoomTab(
|
||||||
|
const ServerInfo_Room &, bool)));
|
||||||
myAddTab(tabServer);
|
myAddTab(tabServer);
|
||||||
|
|
||||||
tabUserLists = new TabUserLists(this, client, *userInfo);
|
tabUserLists = new TabUserLists(this, client, *userInfo);
|
||||||
connect(tabUserLists, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
connect(tabUserLists, SIGNAL(openMessageDialog(
|
||||||
|
const QString &, bool)), this, SLOT(addMessageTab(
|
||||||
|
const QString &, bool)));
|
||||||
connect(tabUserLists, SIGNAL(userJoined(ServerInfo_User)), this, SLOT(processUserJoined(ServerInfo_User)));
|
connect(tabUserLists, SIGNAL(userJoined(ServerInfo_User)), this, SLOT(processUserJoined(ServerInfo_User)));
|
||||||
connect(tabUserLists, SIGNAL(userLeft(const QString &)), this, SLOT(processUserLeft(const QString &)));
|
connect(tabUserLists, SIGNAL(userLeft(
|
||||||
|
const QString &)), this, SLOT(processUserLeft(
|
||||||
|
const QString &)));
|
||||||
myAddTab(tabUserLists);
|
myAddTab(tabUserLists);
|
||||||
|
|
||||||
updatePingTime(0, -1);
|
updatePingTime(0, -1);
|
||||||
|
|
||||||
if (userInfo->user_level() & ServerInfo_User::IsRegistered)
|
if (userInfo->user_level() & ServerInfo_User::IsRegistered) {
|
||||||
{
|
|
||||||
tabDeckStorage = new TabDeckStorage(this, client);
|
tabDeckStorage = new TabDeckStorage(this, client);
|
||||||
connect(tabDeckStorage, SIGNAL(openDeckEditor(const DeckLoader *)), this, SLOT(addDeckEditorTab(const DeckLoader *)));
|
connect(tabDeckStorage, SIGNAL(openDeckEditor(
|
||||||
|
const DeckLoader *)), this, SLOT(addDeckEditorTab(
|
||||||
|
const DeckLoader *)));
|
||||||
myAddTab(tabDeckStorage);
|
myAddTab(tabDeckStorage);
|
||||||
|
|
||||||
tabReplays = new TabReplays(this, client);
|
tabReplays = new TabReplays(this, client);
|
||||||
connect(tabReplays, SIGNAL(openReplay(GameReplay* )), this, SLOT(openReplay(GameReplay* )));
|
connect(tabReplays, SIGNAL(openReplay(GameReplay * )), this, SLOT(openReplay(GameReplay * )));
|
||||||
myAddTab(tabReplays);
|
myAddTab(tabReplays);
|
||||||
}
|
} else {
|
||||||
else
|
tabDeckStorage = 0;
|
||||||
{
|
tabReplays = 0;
|
||||||
tabDeckStorage = nullptr;
|
|
||||||
tabReplays = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (userInfo->user_level() & ServerInfo_User::IsModerator)
|
if (userInfo->user_level() & ServerInfo_User::IsModerator) {
|
||||||
{
|
tabAdmin = new TabAdmin(this, client, (userInfo->user_level() & ServerInfo_User::IsAdmin));
|
||||||
tabAdmin = new TabAdmin(this, client, static_cast<bool>(userInfo->user_level() & ServerInfo_User::IsAdmin));
|
|
||||||
connect(tabAdmin, SIGNAL(adminLockChanged(bool)), this, SIGNAL(adminLockChanged(bool)));
|
connect(tabAdmin, SIGNAL(adminLockChanged(bool)), this, SIGNAL(adminLockChanged(bool)));
|
||||||
myAddTab(tabAdmin);
|
myAddTab(tabAdmin);
|
||||||
|
|
||||||
tabLog = new TabLog(this, client);
|
tabLog = new TabLog(this, client);
|
||||||
myAddTab(tabLog);
|
myAddTab(tabLog);
|
||||||
}
|
} else {
|
||||||
else
|
tabAdmin = 0;
|
||||||
{
|
tabLog = 0;
|
||||||
tabAdmin = nullptr;
|
|
||||||
tabLog = nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retranslateUi();
|
retranslateUi();
|
||||||
|
@ -276,117 +247,82 @@ void TabSupervisor::startLocal(const QList<AbstractClient *> &_clients)
|
||||||
isLocalGame = true;
|
isLocalGame = true;
|
||||||
userInfo = new ServerInfo_User;
|
userInfo = new ServerInfo_User;
|
||||||
localClients = _clients;
|
localClients = _clients;
|
||||||
for (auto &localClient : localClients)
|
for (int i = 0; i < localClients.size(); ++i)
|
||||||
{
|
connect(localClients[i], SIGNAL(gameEventContainerReceived(const GameEventContainer &)), this, SLOT(processGameEventContainer(const GameEventContainer &)));
|
||||||
connect(localClient, SIGNAL(gameEventContainerReceived(const GameEventContainer &)), this, SLOT(processGameEventContainer(const GameEventContainer &)));
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(localClients.first(), SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(localGameJoined(const Event_GameJoined &)));
|
connect(localClients.first(), SIGNAL(gameJoinedEventReceived(const Event_GameJoined &)), this, SLOT(localGameJoined(const Event_GameJoined &)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::stop()
|
void TabSupervisor::stop()
|
||||||
{
|
{
|
||||||
if ((!client) && localClients.isEmpty())
|
if ((!client) && localClients.isEmpty())
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (!localClients.isEmpty())
|
if (!localClients.isEmpty()) {
|
||||||
{
|
for (int i = 0; i < localClients.size(); ++i)
|
||||||
for (auto &localClient : localClients)
|
localClients[i]->deleteLater();
|
||||||
{
|
|
||||||
localClient->deleteLater();
|
|
||||||
}
|
|
||||||
|
|
||||||
localClients.clear();
|
localClients.clear();
|
||||||
|
|
||||||
emit localGameEnded();
|
emit localGameEnded();
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
if (tabUserLists)
|
if (tabUserLists)
|
||||||
{
|
|
||||||
tabUserLists->deleteLater();
|
tabUserLists->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
if (tabServer)
|
if (tabServer)
|
||||||
{
|
|
||||||
tabServer->deleteLater();
|
tabServer->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
if (tabDeckStorage)
|
if (tabDeckStorage)
|
||||||
{
|
|
||||||
tabDeckStorage->deleteLater();
|
tabDeckStorage->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
if (tabReplays)
|
if (tabReplays)
|
||||||
{
|
|
||||||
tabReplays->deleteLater();
|
tabReplays->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
if (tabAdmin)
|
if (tabAdmin)
|
||||||
{
|
|
||||||
tabAdmin->deleteLater();
|
tabAdmin->deleteLater();
|
||||||
}
|
|
||||||
|
|
||||||
if (tabLog)
|
if (tabLog)
|
||||||
{
|
|
||||||
tabLog->deleteLater();
|
tabLog->deleteLater();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
tabUserLists = 0;
|
||||||
tabUserLists = nullptr;
|
tabServer = 0;
|
||||||
tabServer = nullptr;
|
tabDeckStorage = 0;
|
||||||
tabDeckStorage = nullptr;
|
tabReplays = 0;
|
||||||
tabReplays = nullptr;
|
tabAdmin = 0;
|
||||||
tabAdmin = nullptr;
|
tabLog = 0;
|
||||||
tabLog = nullptr;
|
|
||||||
|
|
||||||
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
QMapIterator<int, TabRoom *> roomIterator(roomTabs);
|
||||||
while (roomIterator.hasNext())
|
while (roomIterator.hasNext())
|
||||||
{
|
|
||||||
roomIterator.next().value()->deleteLater();
|
roomIterator.next().value()->deleteLater();
|
||||||
}
|
|
||||||
roomTabs.clear();
|
roomTabs.clear();
|
||||||
|
|
||||||
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
QMapIterator<int, TabGame *> gameIterator(gameTabs);
|
||||||
while (gameIterator.hasNext())
|
while (gameIterator.hasNext())
|
||||||
{
|
|
||||||
gameIterator.next().value()->deleteLater();
|
gameIterator.next().value()->deleteLater();
|
||||||
}
|
|
||||||
gameTabs.clear();
|
gameTabs.clear();
|
||||||
|
|
||||||
QListIterator<TabGame *> replayIterator(replayTabs);
|
QListIterator<TabGame *> replayIterator(replayTabs);
|
||||||
while (replayIterator.hasNext())
|
while (replayIterator.hasNext())
|
||||||
{
|
|
||||||
replayIterator.next()->deleteLater();
|
replayIterator.next()->deleteLater();
|
||||||
}
|
|
||||||
replayTabs.clear();
|
replayTabs.clear();
|
||||||
|
|
||||||
delete userInfo;
|
delete userInfo;
|
||||||
userInfo = nullptr;
|
userInfo = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::updatePingTime(int value, int max)
|
void TabSupervisor::updatePingTime(int value, int max)
|
||||||
{
|
{
|
||||||
if (!tabServer || tabServer->getContentsChanged())
|
if (!tabServer)
|
||||||
{
|
return;
|
||||||
|
if (tabServer->getContentsChanged())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
setTabIcon(indexOf(tabServer), QIcon(PingPixmapGenerator::generatePixmap(15, value, max)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::closeButtonPressed()
|
void TabSupervisor::closeButtonPressed()
|
||||||
{
|
{
|
||||||
Tab *tab = dynamic_cast<Tab *>(dynamic_cast<CloseButton *>(sender())->property("tab").value<QObject *>());
|
Tab *tab = static_cast<Tab *>(static_cast<CloseButton *>(sender())->property("tab").value<QObject *>());
|
||||||
tab->closeRequest();
|
tab->closeRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
|
void TabSupervisor::addCloseButtonToTab(Tab *tab, int tabIndex)
|
||||||
{
|
{
|
||||||
auto closeSide = static_cast<QTabBar::ButtonPosition>(tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tabBar()));
|
QTabBar::ButtonPosition closeSide = (QTabBar::ButtonPosition) tabBar()->style()->styleHint(QStyle::SH_TabBar_CloseButtonPosition, 0, tabBar());
|
||||||
auto *closeButton = new CloseButton;
|
CloseButton *closeButton = new CloseButton;
|
||||||
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeButtonPressed()));
|
connect(closeButton, SIGNAL(clicked()), this, SLOT(closeButtonPressed()));
|
||||||
closeButton->setProperty("tab", qVariantFromValue((QObject *) tab));
|
closeButton->setProperty("tab", qVariantFromValue((QObject *) tab));
|
||||||
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
|
tabBar()->setTabButton(tabIndex, closeSide, closeButton);
|
||||||
|
@ -397,16 +333,10 @@ void TabSupervisor::gameJoined(const Event_GameJoined &event)
|
||||||
QMap<int, QString> roomGameTypes;
|
QMap<int, QString> roomGameTypes;
|
||||||
TabRoom *room = roomTabs.value(event.game_info().room_id());
|
TabRoom *room = roomTabs.value(event.game_info().room_id());
|
||||||
if (room)
|
if (room)
|
||||||
{
|
|
||||||
roomGameTypes = room->getGameTypes();
|
roomGameTypes = room->getGameTypes();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
for (int i = 0; i < event.game_types_size(); ++i)
|
for (int i = 0; i < event.game_types_size(); ++i)
|
||||||
{
|
|
||||||
roomGameTypes.insert(event.game_types(i).game_type_id(), QString::fromStdString(event.game_types(i).description()));
|
roomGameTypes.insert(event.game_types(i).game_type_id(), QString::fromStdString(event.game_types(i).description()));
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
TabGame *tab = new TabGame(this, QList<AbstractClient *>() << client, event, roomGameTypes);
|
||||||
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
connect(tab, SIGNAL(gameClosing(TabGame *)), this, SLOT(gameLeft(TabGame *)));
|
||||||
|
@ -428,8 +358,7 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
||||||
gameTabs.insert(event.game_info().game_id(), tab);
|
gameTabs.insert(event.game_info().game_id(), tab);
|
||||||
setCurrentWidget(tab);
|
setCurrentWidget(tab);
|
||||||
|
|
||||||
for (int i = 1; i < localClients.size(); ++i)
|
for (int i = 1; i < localClients.size(); ++i) {
|
||||||
{
|
|
||||||
Command_JoinGame cmd;
|
Command_JoinGame cmd;
|
||||||
cmd.set_game_id(event.game_info().game_id());
|
cmd.set_game_id(event.game_info().game_id());
|
||||||
localClients[i]->sendCommand(localClients[i]->prepareRoomCommand(cmd, 0));
|
localClients[i]->sendCommand(localClients[i]->prepareRoomCommand(cmd, 0));
|
||||||
|
@ -438,28 +367,19 @@ void TabSupervisor::localGameJoined(const Event_GameJoined &event)
|
||||||
|
|
||||||
void TabSupervisor::gameLeft(TabGame *tab)
|
void TabSupervisor::gameLeft(TabGame *tab)
|
||||||
{
|
{
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
|
|
||||||
gameTabs.remove(tab->getGameId());
|
gameTabs.remove(tab->getGameId());
|
||||||
removeTab(indexOf(tab));
|
removeTab(indexOf(tab));
|
||||||
|
|
||||||
if (!localClients.isEmpty())
|
if (!localClients.isEmpty())
|
||||||
{
|
|
||||||
stop();
|
stop();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
||||||
{
|
{
|
||||||
auto *tab = new TabRoom(this, client, userInfo, info);
|
TabRoom *tab = new TabRoom(this, client, userInfo, info);
|
||||||
connect(tab, SIGNAL(maximizeClient()), this, SLOT(maximizeMainWindow()));
|
connect(tab, SIGNAL(maximizeClient()), this, SLOT(maximizeMainWindow()));
|
||||||
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
|
connect(tab, SIGNAL(roomClosing(TabRoom *)), this, SLOT(roomLeft(TabRoom *)));
|
||||||
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
connect(tab, SIGNAL(openMessageDialog(const QString &, bool)), this, SLOT(addMessageTab(const QString &, bool)));
|
||||||
|
@ -467,22 +387,13 @@ void TabSupervisor::addRoomTab(const ServerInfo_Room &info, bool setCurrent)
|
||||||
addCloseButtonToTab(tab, tabIndex);
|
addCloseButtonToTab(tab, tabIndex);
|
||||||
roomTabs.insert(info.room_id(), tab);
|
roomTabs.insert(info.room_id(), tab);
|
||||||
if (setCurrent)
|
if (setCurrent)
|
||||||
{
|
|
||||||
setCurrentWidget(tab);
|
setCurrentWidget(tab);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::roomLeft(TabRoom *tab)
|
void TabSupervisor::roomLeft(TabRoom *tab)
|
||||||
{
|
{
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
|
|
||||||
roomTabs.remove(tab->getRoomId());
|
roomTabs.remove(tab->getRoomId());
|
||||||
removeTab(indexOf(tab));
|
removeTab(indexOf(tab));
|
||||||
|
@ -490,7 +401,7 @@ void TabSupervisor::roomLeft(TabRoom *tab)
|
||||||
|
|
||||||
void TabSupervisor::openReplay(GameReplay *replay)
|
void TabSupervisor::openReplay(GameReplay *replay)
|
||||||
{
|
{
|
||||||
auto *replayTab = new TabGame(this, replay);
|
TabGame *replayTab = new TabGame(this, replay);
|
||||||
connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *)));
|
connect(replayTab, SIGNAL(gameClosing(TabGame *)), this, SLOT(replayLeft(TabGame *)));
|
||||||
int tabIndex = myAddTab(replayTab);
|
int tabIndex = myAddTab(replayTab);
|
||||||
addCloseButtonToTab(replayTab, tabIndex);
|
addCloseButtonToTab(replayTab, tabIndex);
|
||||||
|
@ -501,9 +412,7 @@ void TabSupervisor::openReplay(GameReplay *replay)
|
||||||
void TabSupervisor::replayLeft(TabGame *tab)
|
void TabSupervisor::replayLeft(TabGame *tab)
|
||||||
{
|
{
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
|
|
||||||
replayTabs.removeAt(replayTabs.indexOf(tab));
|
replayTabs.removeAt(replayTabs.indexOf(tab));
|
||||||
}
|
}
|
||||||
|
@ -511,30 +420,20 @@ void TabSupervisor::replayLeft(TabGame *tab)
|
||||||
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus)
|
||||||
{
|
{
|
||||||
if (receiverName == QString::fromStdString(userInfo->name()))
|
if (receiverName == QString::fromStdString(userInfo->name()))
|
||||||
{
|
return 0;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
ServerInfo_User otherUser;
|
ServerInfo_User otherUser;
|
||||||
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(receiverName);
|
||||||
if (twi)
|
if (twi)
|
||||||
{
|
|
||||||
otherUser = twi->getUserInfo();
|
otherUser = twi->getUserInfo();
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
otherUser.set_name(receiverName.toStdString());
|
otherUser.set_name(receiverName.toStdString());
|
||||||
}
|
|
||||||
|
|
||||||
TabMessage *tab;
|
TabMessage *tab;
|
||||||
tab = messageTabs.value(QString::fromStdString(otherUser.name()));
|
tab = messageTabs.value(QString::fromStdString(otherUser.name()));
|
||||||
if (tab)
|
if (tab) {
|
||||||
{
|
|
||||||
if (focus)
|
if (focus)
|
||||||
{
|
setCurrentWidget(tab);
|
||||||
setCurrentWidget(tab);
|
|
||||||
}
|
|
||||||
|
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -545,28 +444,18 @@ TabMessage *TabSupervisor::addMessageTab(const QString &receiverName, bool focus
|
||||||
addCloseButtonToTab(tab, tabIndex);
|
addCloseButtonToTab(tab, tabIndex);
|
||||||
messageTabs.insert(receiverName, tab);
|
messageTabs.insert(receiverName, tab);
|
||||||
if (focus)
|
if (focus)
|
||||||
{
|
|
||||||
setCurrentWidget(tab);
|
setCurrentWidget(tab);
|
||||||
}
|
|
||||||
return tab;
|
return tab;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::maximizeMainWindow()
|
void TabSupervisor::maximizeMainWindow() {
|
||||||
{
|
|
||||||
emit showWindowIfHidden();
|
emit showWindowIfHidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::talkLeft(TabMessage *tab)
|
void TabSupervisor::talkLeft(TabMessage *tab)
|
||||||
{
|
{
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
|
|
||||||
messageTabs.remove(tab->getUserName());
|
messageTabs.remove(tab->getUserName());
|
||||||
removeTab(indexOf(tab));
|
removeTab(indexOf(tab));
|
||||||
|
@ -574,13 +463,9 @@ void TabSupervisor::talkLeft(TabMessage *tab)
|
||||||
|
|
||||||
TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
||||||
{
|
{
|
||||||
auto *tab = new TabDeckEditor(this);
|
TabDeckEditor *tab = new TabDeckEditor(this);
|
||||||
|
|
||||||
if (deckToOpen)
|
if (deckToOpen)
|
||||||
{
|
|
||||||
tab->setDeck(new DeckLoader(*deckToOpen));
|
tab->setDeck(new DeckLoader(*deckToOpen));
|
||||||
}
|
|
||||||
|
|
||||||
connect(tab, SIGNAL(deckEditorClosing(TabDeckEditor *)), this, SLOT(deckEditorClosed(TabDeckEditor *)));
|
connect(tab, SIGNAL(deckEditorClosing(TabDeckEditor *)), this, SLOT(deckEditorClosed(TabDeckEditor *)));
|
||||||
int tabIndex = myAddTab(tab);
|
int tabIndex = myAddTab(tab);
|
||||||
addCloseButtonToTab(tab, tabIndex);
|
addCloseButtonToTab(tab, tabIndex);
|
||||||
|
@ -591,15 +476,8 @@ TabDeckEditor *TabSupervisor::addDeckEditorTab(const DeckLoader *deckToOpen)
|
||||||
|
|
||||||
void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
||||||
{
|
{
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tab == currentWidget())
|
if (tab == currentWidget())
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
|
|
||||||
deckEditorTabs.removeAt(deckEditorTabs.indexOf(tab));
|
deckEditorTabs.removeAt(deckEditorTabs.indexOf(tab));
|
||||||
removeTab(indexOf(tab));
|
removeTab(indexOf(tab));
|
||||||
|
@ -607,18 +485,13 @@ void TabSupervisor::deckEditorClosed(TabDeckEditor *tab)
|
||||||
|
|
||||||
void TabSupervisor::tabUserEvent(bool globalEvent)
|
void TabSupervisor::tabUserEvent(bool globalEvent)
|
||||||
{
|
{
|
||||||
auto *tab = dynamic_cast<Tab *>(sender());
|
Tab *tab = static_cast<Tab *>(sender());
|
||||||
|
if (tab != currentWidget()) {
|
||||||
if (tab != currentWidget())
|
|
||||||
{
|
|
||||||
tab->setContentsChanged(true);
|
tab->setContentsChanged(true);
|
||||||
setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed"));
|
setTabIcon(indexOf(tab), QPixmap("theme:icons/tab_changed"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (globalEvent && settingsCache->getNotificationsEnabled())
|
if (globalEvent && settingsCache->getNotificationsEnabled())
|
||||||
{
|
|
||||||
QApplication::alert(this);
|
QApplication::alert(this);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
||||||
|
@ -631,129 +504,90 @@ void TabSupervisor::updateTabText(Tab *tab, const QString &newTabText)
|
||||||
void TabSupervisor::processRoomEvent(const RoomEvent &event)
|
void TabSupervisor::processRoomEvent(const RoomEvent &event)
|
||||||
{
|
{
|
||||||
TabRoom *tab = roomTabs.value(event.room_id(), 0);
|
TabRoom *tab = roomTabs.value(event.room_id(), 0);
|
||||||
|
|
||||||
if (tab)
|
if (tab)
|
||||||
{
|
|
||||||
tab->processRoomEvent(event);
|
tab->processRoomEvent(event);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processGameEventContainer(const GameEventContainer &cont)
|
void TabSupervisor::processGameEventContainer(const GameEventContainer &cont)
|
||||||
{
|
{
|
||||||
TabGame *tab = gameTabs.value(cont.game_id());
|
TabGame *tab = gameTabs.value(cont.game_id());
|
||||||
|
|
||||||
if (tab)
|
if (tab)
|
||||||
{
|
|
||||||
tab->processGameEventContainer(cont, qobject_cast<AbstractClient *>(sender()));
|
tab->processGameEventContainer(cont, qobject_cast<AbstractClient *>(sender()));
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
qDebug() << "gameEvent: invalid gameId";
|
qDebug() << "gameEvent: invalid gameId";
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
void TabSupervisor::processUserMessageEvent(const Event_UserMessage &event)
|
||||||
{
|
{
|
||||||
QString senderName = QString::fromStdString(event.sender_name());
|
QString senderName = QString::fromStdString(event.sender_name());
|
||||||
TabMessage *tab = messageTabs.value(senderName);
|
TabMessage *tab = messageTabs.value(senderName);
|
||||||
|
if (!tab)
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
tab = messageTabs.value(QString::fromStdString(event.receiver_name()));
|
tab = messageTabs.value(QString::fromStdString(event.receiver_name()));
|
||||||
}
|
if (!tab) {
|
||||||
|
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(senderName);
|
UserListTWI *twi = tabUserLists->getAllUsersList()->getUsers().value(senderName);
|
||||||
|
if (twi) {
|
||||||
if (twi)
|
|
||||||
{
|
|
||||||
UserLevelFlags userLevel = UserLevelFlags(twi->getUserInfo().user_level());
|
UserLevelFlags userLevel = UserLevelFlags(twi->getUserInfo().user_level());
|
||||||
if (settingsCache->getIgnoreUnregisteredUserMessages() && !userLevel.testFlag(ServerInfo_User::IsRegistered))
|
if (settingsCache->getIgnoreUnregisteredUserMessages() &&
|
||||||
{
|
!userLevel.testFlag(ServerInfo_User::IsRegistered))
|
||||||
// Flags are additive, so reg/mod/admin are all IsRegistered
|
// Flags are additive, so reg/mod/admin are all IsRegistered
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tab = addMessageTab(QString::fromStdString(event.sender_name()), false);
|
tab = addMessageTab(QString::fromStdString(event.sender_name()), false);
|
||||||
}
|
}
|
||||||
|
if (!tab)
|
||||||
if (tab == nullptr)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
tab->processUserMessageEvent(event);
|
tab->processUserMessageEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserLeft(const QString &userName)
|
void TabSupervisor::processUserLeft(const QString &userName)
|
||||||
{
|
{
|
||||||
TabMessage *tab = messageTabs.value(userName);
|
TabMessage *tab = messageTabs.value(userName);
|
||||||
|
|
||||||
if (tab)
|
if (tab)
|
||||||
{
|
|
||||||
tab->processUserLeft();
|
tab->processUserLeft();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfo)
|
void TabSupervisor::processUserJoined(const ServerInfo_User &userInfo)
|
||||||
{
|
{
|
||||||
TabMessage *tab = messageTabs.value(QString::fromStdString(userInfo.name()));
|
TabMessage *tab = messageTabs.value(QString::fromStdString(userInfo.name()));
|
||||||
if (tab)
|
if (tab)
|
||||||
{
|
|
||||||
tab->processUserJoined(userInfo);
|
tab->processUserJoined(userInfo);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::updateCurrent(int index)
|
void TabSupervisor::updateCurrent(int index)
|
||||||
{
|
{
|
||||||
if (index != -1)
|
if (index != -1) {
|
||||||
{
|
Tab *tab = static_cast<Tab *>(widget(index));
|
||||||
auto *tab = dynamic_cast<Tab *>(widget(index));
|
if (tab->getContentsChanged()) {
|
||||||
if (tab->getContentsChanged())
|
|
||||||
{
|
|
||||||
setTabIcon(index, QIcon());
|
setTabIcon(index, QIcon());
|
||||||
tab->setContentsChanged(false);
|
tab->setContentsChanged(false);
|
||||||
}
|
}
|
||||||
emit setMenu(dynamic_cast<Tab *>(widget(index))->getTabMenus());
|
emit setMenu(static_cast<Tab *>(widget(index))->getTabMenus());
|
||||||
tab->tabActivated();
|
tab->tabActivated();
|
||||||
}
|
} else
|
||||||
else
|
|
||||||
{
|
|
||||||
emit setMenu();
|
emit setMenu();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool TabSupervisor::getAdminLocked() const
|
bool TabSupervisor::getAdminLocked() const
|
||||||
{
|
{
|
||||||
if (!tabAdmin)
|
if (!tabAdmin)
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
return tabAdmin->getLocked();
|
return tabAdmin->getLocked();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||||
{
|
{
|
||||||
|
|
||||||
switch ((Event_NotifyUser::NotificationType) event.type())
|
switch ((Event_NotifyUser::NotificationType) event.type()) {
|
||||||
{
|
|
||||||
case Event_NotifyUser::UNKNOWN: QMessageBox::information(this, tr("Unknown Event"), tr("The server has sent you a message that your client does not understand.\nThis message might mean there is a new version of Cockatrice available or this server is running a custom or pre-release version.\n\nTo update your client, go to Help -> Check for Updates.")); break;
|
case Event_NotifyUser::UNKNOWN: QMessageBox::information(this, tr("Unknown Event"), tr("The server has sent you a message that your client does not understand.\nThis message might mean there is a new version of Cockatrice available or this server is running a custom or pre-release version.\n\nTo update your client, go to Help -> Check for Updates.")); break;
|
||||||
case Event_NotifyUser::IDLEWARNING: QMessageBox::information(this, tr("Idle Timeout"), tr("You are about to be logged out due to inactivity.")); break;
|
case Event_NotifyUser::IDLEWARNING: QMessageBox::information(this, tr("Idle Timeout"), tr("You are about to be logged out due to inactivity.")); break;
|
||||||
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
case Event_NotifyUser::PROMOTED: QMessageBox::information(this, tr("Promotion"), tr("You have been promoted to moderator. Please log out and back in for changes to take effect.")); break;
|
||||||
case Event_NotifyUser::WARNING:
|
case Event_NotifyUser::WARNING: {
|
||||||
{
|
|
||||||
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty())
|
if (!QString::fromStdString(event.warning_reason()).simplified().isEmpty())
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Warned"), tr("You have received a warning due to %1.\nPlease refrain from engaging in this activity or further actions may be taken against you. If you have any questions, please private message a moderator.").arg(QString::fromStdString(event.warning_reason()).simplified()));
|
QMessageBox::warning(this, tr("Warned"), tr("You have received a warning due to %1.\nPlease refrain from engaging in this activity or further actions may be taken against you. If you have any questions, please private message a moderator.").arg(QString::fromStdString(event.warning_reason()).simplified()));
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case Event_NotifyUser::CUSTOM:
|
case Event_NotifyUser::CUSTOM: {
|
||||||
{
|
if (!QString::fromStdString(event.custom_title()).simplified().isEmpty() && !QString::fromStdString(event.custom_content()).simplified().isEmpty()) {
|
||||||
if (!QString::fromStdString(event.custom_title()).simplified().isEmpty() && !QString::fromStdString(event.custom_content()).simplified().isEmpty())
|
|
||||||
{
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setParent(this);
|
msgBox.setParent(this);
|
||||||
msgBox.setWindowFlags(Qt::Dialog);
|
msgBox.setWindowFlags(Qt::Dialog);
|
||||||
|
@ -766,7 +600,7 @@ void TabSupervisor::processNotifyUserEvent(const Event_NotifyUser &event)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: ;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -783,11 +617,8 @@ QString TabSupervisor::getOwnUsername() const
|
||||||
|
|
||||||
bool TabSupervisor::isUserBuddy(const QString &userName) const
|
bool TabSupervisor::isUserBuddy(const QString &userName) const
|
||||||
{
|
{
|
||||||
if (!getUserListsTab() || !getUserListsTab()->getBuddyList())
|
if (!getUserListsTab()) return false;
|
||||||
{
|
if (!getUserListsTab()->getBuddyList()) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getBuddyList()->getUsers();
|
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getBuddyList()->getUsers();
|
||||||
bool senderIsBuddy = buddyList.contains(userName);
|
bool senderIsBuddy = buddyList.contains(userName);
|
||||||
return senderIsBuddy;
|
return senderIsBuddy;
|
||||||
|
@ -795,33 +626,26 @@ bool TabSupervisor::isUserBuddy(const QString &userName) const
|
||||||
|
|
||||||
bool TabSupervisor::isUserIgnored(const QString &userName) const
|
bool TabSupervisor::isUserIgnored(const QString &userName) const
|
||||||
{
|
{
|
||||||
if (!getUserListsTab() || !getUserListsTab()->getIgnoreList())
|
if (!getUserListsTab()) return false;
|
||||||
{
|
if (!getUserListsTab()->getIgnoreList()) return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getIgnoreList()->getUsers();
|
QMap<QString, UserListTWI *> buddyList = getUserListsTab()->getIgnoreList()->getUsers();
|
||||||
bool senderIsBuddy = buddyList.contains(userName);
|
bool senderIsBuddy = buddyList.contains(userName);
|
||||||
return senderIsBuddy;
|
return senderIsBuddy;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ServerInfo_User* TabSupervisor::getOnlineUser(const QString &userName) const
|
const ServerInfo_User * TabSupervisor::getOnlineUser(const QString &userName) const
|
||||||
{
|
{
|
||||||
if (!getUserListsTab() || !getUserListsTab()->getAllUsersList())
|
if (!getUserListsTab()) return nullptr;
|
||||||
{
|
if (!getUserListsTab()->getAllUsersList()) return nullptr;
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMap<QString, UserListTWI *> userList = getUserListsTab()->getAllUsersList()->getUsers();
|
QMap<QString, UserListTWI *> userList = getUserListsTab()->getAllUsersList()->getUsers();
|
||||||
const QString &userNameToMatchLower = userName.toLower();
|
const QString &userNameToMatchLower = userName.toLower();
|
||||||
QMap<QString, UserListTWI *>::iterator i;
|
QMap<QString, UserListTWI *>::iterator i;
|
||||||
|
|
||||||
for (i = userList.begin(); i != userList.end(); ++i)
|
for (i = userList.begin(); i != userList.end(); ++i)
|
||||||
if (i.key().toLower() == userNameToMatchLower)
|
if (i.key().toLower() == userNameToMatchLower) {
|
||||||
{
|
|
||||||
const ServerInfo_User &userInfo = i.value()->getUserInfo();
|
const ServerInfo_User &userInfo = i.value()->getUserInfo();
|
||||||
return &userInfo;
|
return &userInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,97 +30,90 @@ class ServerInfo_User;
|
||||||
class GameReplay;
|
class GameReplay;
|
||||||
class DeckList;
|
class DeckList;
|
||||||
|
|
||||||
class CloseButton : public QAbstractButton
|
class CloseButton : public QAbstractButton {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit CloseButton(QWidget *parent = nullptr);
|
CloseButton(QWidget *parent = 0);
|
||||||
QSize sizeHint() const override;
|
QSize sizeHint() const;
|
||||||
inline QSize minimumSizeHint() const override { return sizeHint(); }
|
inline QSize minimumSizeHint() const { return sizeHint(); }
|
||||||
|
protected:
|
||||||
protected:
|
void enterEvent(QEvent *event);
|
||||||
void enterEvent(QEvent *event) override;
|
void leaveEvent(QEvent *event);
|
||||||
void leaveEvent(QEvent *event) override;
|
void paintEvent(QPaintEvent *event);
|
||||||
void paintEvent(QPaintEvent *event) override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TabSupervisor : public QTabWidget, public UserlistProxy
|
class TabSupervisor : public QTabWidget, public UserlistProxy {
|
||||||
{
|
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
private:
|
private:
|
||||||
ServerInfo_User *userInfo;
|
ServerInfo_User *userInfo;
|
||||||
AbstractClient *client;
|
AbstractClient *client;
|
||||||
QList<AbstractClient *> localClients;
|
QList<AbstractClient *> localClients;
|
||||||
TabServer *tabServer;
|
TabServer *tabServer;
|
||||||
TabUserLists *tabUserLists;
|
TabUserLists *tabUserLists;
|
||||||
TabDeckStorage *tabDeckStorage;
|
TabDeckStorage *tabDeckStorage;
|
||||||
TabReplays *tabReplays;
|
TabReplays *tabReplays;
|
||||||
TabAdmin *tabAdmin;
|
TabAdmin *tabAdmin;
|
||||||
TabLog *tabLog;
|
TabLog *tabLog;
|
||||||
QMap<int, TabRoom *> roomTabs;
|
QMap<int, TabRoom *> roomTabs;
|
||||||
QMap<int, TabGame *> gameTabs;
|
QMap<int, TabGame *> gameTabs;
|
||||||
QList<TabGame *> replayTabs;
|
QList<TabGame *> replayTabs;
|
||||||
QMap<QString, TabMessage *> messageTabs;
|
QMap<QString, TabMessage *> messageTabs;
|
||||||
QList<TabDeckEditor *> deckEditorTabs;
|
QList<TabDeckEditor *> deckEditorTabs;
|
||||||
int myAddTab(Tab *tab);
|
int myAddTab(Tab *tab);
|
||||||
void addCloseButtonToTab(Tab *tab, int tabIndex);
|
void addCloseButtonToTab(Tab *tab, int tabIndex);
|
||||||
QString sanitizeTabName(QString dirty) const;
|
QString sanitizeTabName(QString dirty) const;
|
||||||
QString sanitizeHtml(QString dirty) const;
|
QString sanitizeHtml(QString dirty) const;
|
||||||
bool isLocalGame;
|
bool isLocalGame;
|
||||||
|
public:
|
||||||
public:
|
TabSupervisor(AbstractClient *_client, QWidget *parent = 0);
|
||||||
explicit TabSupervisor(AbstractClient *_client, QWidget *parent = nullptr);
|
~TabSupervisor();
|
||||||
~TabSupervisor() override;
|
void retranslateUi();
|
||||||
void retranslateUi();
|
void start(const ServerInfo_User &userInfo);
|
||||||
void start(const ServerInfo_User &userInfo);
|
void startLocal(const QList<AbstractClient *> &_clients);
|
||||||
void startLocal(const QList<AbstractClient *> &_clients);
|
void stop();
|
||||||
void stop();
|
bool getIsLocalGame() const { return isLocalGame; }
|
||||||
bool getIsLocalGame() const { return isLocalGame; }
|
int getGameCount() const { return gameTabs.size(); }
|
||||||
int getGameCount() const { return gameTabs.size(); }
|
TabUserLists *getUserListsTab() const { return tabUserLists; }
|
||||||
TabUserLists *getUserListsTab() const { return tabUserLists; }
|
ServerInfo_User *getUserInfo() const { return userInfo; }
|
||||||
ServerInfo_User *getUserInfo() const { return userInfo; }
|
AbstractClient *getClient() const;
|
||||||
AbstractClient *getClient() const;
|
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
|
||||||
const QMap<int, TabRoom *> &getRoomTabs() const { return roomTabs; }
|
bool getAdminLocked() const;
|
||||||
bool getAdminLocked() const;
|
bool closeRequest();
|
||||||
bool closeRequest();
|
bool isOwnUserRegistered() const;
|
||||||
bool isOwnUserRegistered() const override;
|
QString getOwnUsername() const;
|
||||||
QString getOwnUsername() const override;
|
bool isUserBuddy(const QString &userName) const;
|
||||||
bool isUserBuddy(const QString &userName) const override;
|
bool isUserIgnored(const QString &userName) const;
|
||||||
bool isUserIgnored(const QString &userName) const override;
|
const ServerInfo_User* getOnlineUser(const QString &userName) const;
|
||||||
const ServerInfo_User* getOnlineUser(const QString &userName) const override;
|
signals:
|
||||||
|
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
||||||
signals:
|
void localGameEnded();
|
||||||
void setMenu(const QList<QMenu *> &newMenuList = QList<QMenu *>());
|
void adminLockChanged(bool lock);
|
||||||
void localGameEnded();
|
void showWindowIfHidden();
|
||||||
void adminLockChanged(bool lock);
|
public slots:
|
||||||
void showWindowIfHidden();
|
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
|
||||||
|
void openReplay(GameReplay *replay);
|
||||||
public slots:
|
void maximizeMainWindow();
|
||||||
TabDeckEditor *addDeckEditorTab(const DeckLoader *deckToOpen);
|
private slots:
|
||||||
void openReplay(GameReplay *replay);
|
void closeButtonPressed();
|
||||||
void maximizeMainWindow();
|
void updateCurrent(int index);
|
||||||
|
void updatePingTime(int value, int max);
|
||||||
private slots:
|
void gameJoined(const Event_GameJoined &event);
|
||||||
void closeButtonPressed();
|
void localGameJoined(const Event_GameJoined &event);
|
||||||
void updateCurrent(int index);
|
void gameLeft(TabGame *tab);
|
||||||
void updatePingTime(int value, int max);
|
void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
|
||||||
void gameJoined(const Event_GameJoined &event);
|
void roomLeft(TabRoom *tab);
|
||||||
void localGameJoined(const Event_GameJoined &event);
|
TabMessage *addMessageTab(const QString &userName, bool focus);
|
||||||
void gameLeft(TabGame *tab);
|
void replayLeft(TabGame *tab);
|
||||||
void addRoomTab(const ServerInfo_Room &info, bool setCurrent);
|
void processUserLeft(const QString &userName);
|
||||||
void roomLeft(TabRoom *tab);
|
void processUserJoined(const ServerInfo_User &userInfo);
|
||||||
TabMessage *addMessageTab(const QString &userName, bool focus);
|
void talkLeft(TabMessage *tab);
|
||||||
void replayLeft(TabGame *tab);
|
void deckEditorClosed(TabDeckEditor *tab);
|
||||||
void processUserLeft(const QString &userName);
|
void tabUserEvent(bool globalEvent);
|
||||||
void processUserJoined(const ServerInfo_User &userInfo);
|
void updateTabText(Tab *tab, const QString &newTabText);
|
||||||
void talkLeft(TabMessage *tab);
|
void processRoomEvent(const RoomEvent &event);
|
||||||
void deckEditorClosed(TabDeckEditor *tab);
|
void processGameEventContainer(const GameEventContainer &cont);
|
||||||
void tabUserEvent(bool globalEvent);
|
void processUserMessageEvent(const Event_UserMessage &event);
|
||||||
void updateTabText(Tab *tab, const QString &newTabText);
|
void processNotifyUserEvent(const Event_NotifyUser &event);
|
||||||
void processRoomEvent(const RoomEvent &event);
|
|
||||||
void processGameEventContainer(const GameEventContainer &cont);
|
|
||||||
void processUserMessageEvent(const Event_UserMessage &event);
|
|
||||||
void processNotifyUserEvent(const Event_NotifyUser &event);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in a new issue