Cockatrice 2026-10-19-Development-3.1.2-beta.2
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
tab_game.h
Go to the documentation of this file.
1
8
9#ifndef TAB_GAME_H
10#define TAB_GAME_H
11
12#include "tab.h"
13
14#include <QList>
15#include <QLoggingCategory>
16#include <QMap>
17#include <QPair>
18#include <QSize>
19#include <QString>
20#include <QStringList>
21#include <QVector>
22#include <qtmetamacros.h>
23// IWYU pragma: keep
24// ServerInfo_User appears by value and inside QList in slot signatures, so the
25// moc-generated code needs the complete type.
26#include <libcockatrice/protocol/pb/serverinfo_user.pb.h>
27
28class CardMenu;
30class AbstractGame;
34class PlayerLogic;
35class QAction;
36class QCompleter;
37class QStringListModel;
38class QWidget;
40class ServerInfo_User;
41class TabSupervisor;
42class TearOffMenu;
43struct CardRef;
44struct LoadedDeck;
45
46inline Q_LOGGING_CATEGORY(TabGameLog, "tab_game");
47
48class UserListProxy;
49class AbstractClient;
50class GameView;
51class GameScene;
52class ReplayWidget;
54class QLabel;
55class QPushButton;
56class QMenu;
57class PhasesToolbar;
60class QVBoxLayout;
61class GameReplay;
63class QDockWidget;
64class QStackedWidget;
65
66class TabGame : public Tab
67{
68 Q_OBJECT
69private:
73 QStringList gameTypes;
74 QCompleter *mentionCompleter;
75 QStringListModel *mentionModel;
77 QStackedWidget *mainWidget;
78
81 QPushButton *inviteButton = nullptr;
84 QLabel *sayLabel;
98 QAction *aFocusChat;
99 QAction *aInviteToGame = nullptr;
101 QAction *aCardMenu;
102
107 {
108 QMenu *menu;
109 QAction *aVisible;
110 QAction *aFloating;
112 };
113
115
116 PlayerLogic *addPlayer(PlayerLogic *newPlayer);
117 void addLocalPlayer(PlayerLogic *newPlayer, int playerId);
118 void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName);
119 void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap);
120 void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
121 void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
122 void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo);
123 void createZoneForPlayer(PlayerLogic *newPlayer, int playerId);
124
125 void startGame(bool resuming);
126 void stopGame();
127 void closeGame();
128 bool leaveGame();
129
131 void setActivePhase(int phase);
132 void createMenuItems();
134 void createViewMenuItems();
135 void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize);
136 void createCardInfoDock(bool bReplay = false);
137 void createPlayerListDock(bool bReplay = false);
138 void createMessageDock(bool bReplay = false);
139 void createPlayAreaWidget(bool bReplay = false);
140 void createDeckViewContainerWidget(bool bReplay = false);
141 void createReplayDock(GameReplay *replay);
143signals:
147 void openMessageDialog(const QString &userName, bool focus);
148 void openDeckEditor(const LoadedDeck &deck);
149 void notIdle();
150
151 void phaseChanged(int phase);
152 void gameLeft();
153 void chatMessageSent(QString chatMessage);
155
156private slots:
157 void adminLockChanged(bool lock);
158 void newCardAdded(AbstractCardItem *card);
159 void setCardMenu(CardMenu *menu);
160
161 void actGameInfo();
162 void actInviteToGame();
163 void actConcede();
164 void actCopyGameLink();
166 void actRotateViewCW();
167 void actRotateViewCCW();
168 void actSay();
169 void actPhaseAction();
170 void actNextPhase();
171 void actNextPhaseAction();
172
173 void addMentionTag(const QString &value);
174 void linkCardToChat(const QString &cardName);
175
176 void refreshShortcuts();
177
178 void loadLayout();
179 void actCompleterChanged();
180 void notifyPlayerJoin(QString playerName);
181 void notifyPlayerKicked();
182 void processPlayerLeave(PlayerLogic *leavingPlayer);
183 void actResetLayout();
184
185 void hideEvent(QHideEvent *event) override;
186
187protected slots:
188 void closeEvent(QCloseEvent *event) override;
189
190public:
191 TabGame(TabSupervisor *_tabSupervisor,
192 QList<AbstractClient *> &_clients,
193 const Event_GameJoined &event,
194 const QMap<int, QString> &_roomGameTypes);
195 void connectToGameState();
200 TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
201 ~TabGame() override;
202 void retranslateUi() override;
204 bool closeRequest() override;
205
206 [[nodiscard]] QString getTabText() const override;
207
208 [[nodiscard]] AbstractGame *getGame() const
209 {
210 return game;
211 }
212
213public slots:
214 void viewCardInfo(const CardRef &cardRef = {}) const;
215 void resetForRewind();
216 void updateTimeElapsedLabel(QString newTime);
217 void addPlayerToAutoCompleteList(QString playerName);
218 void removePlayerFromAutoCompleteList(QString playerName);
219 void removeSpectator(int spectatorId, ServerInfo_User spectator);
220 void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked);
221 void processLocalPlayerReadyStateChanged(int playerId, bool ready);
222 void emitUserEvent();
223};
224
225#endif
Definition abstract_card_item.h:29
Definition abstract_client.h:73
Definition abstract_game.h:23
Definition card_info_frame_widget.h:25
Definition card_menu.h:23
Manages the game board display including players, zones, cards, and animations.
Definition game_scene.h:60
Definition game_view.h:28
Definition line_edit_completer.h:33
Definition message_log_widget.h:29
Definition phases_toolbar.h:67
Definition player_list_widget.h:46
Definition player_logic.h:56
Definition remote_connection_controller.h:20
Definition game.h:18
The top-level widget that is put in the replay dock widget. Contains the replay timeline as well as t...
Definition replay_widget.h:29
TabGame(TabSupervisor *_tabSupervisor, QList< AbstractClient * > &_clients, const Event_GameJoined &event, const QMap< int, QString > &_roomGameTypes)
Definition tab_game.cpp:136
void actCompleterChanged()
Definition tab_game.cpp:737
AbstractGame * game
Definition tab_game.h:70
void gameLeft()
QDockWidget * cardInfoDock
Definition tab_game.h:92
void createPlayAreaWidget(bool bReplay=false)
Definition tab_game.cpp:1275
QAction * aCopyGameLink
Definition tab_game.h:96
QAction * aResetReplayLayout
Definition tab_game.h:97
void actInviteToGame()
Definition tab_game.cpp:576
void closeEvent(QCloseEvent *event) override
Definition tab_game.cpp:527
QDockWidget * playerListDock
Definition tab_game.h:92
QStringList gameTypes
Definition tab_game.h:73
void createDeckViewContainerWidget(bool bReplay=false)
Definition tab_game.cpp:1317
void setCardMenu(CardMenu *menu)
Definition tab_game.cpp:1057
QAction * aReverseTurn
Definition tab_game.h:97
QStringListModel * mentionModel
Definition tab_game.h:75
void startGame(bool resuming)
Definition tab_game.cpp:913
void actNextPhaseAction()
Definition tab_game.cpp:703
QAction * aRotateViewCW
Definition tab_game.h:97
void createViewMenuItems()
Definition tab_game.cpp:1182
QAction * aLeaveGame
Definition tab_game.h:96
QLabel * timeElapsedLabel
Definition tab_game.h:82
QLabel * sayLabel
Definition tab_game.h:84
void addLocalPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:794
void addPlayerToAutoCompleteList(QString playerName)
Definition tab_game.cpp:665
QCompleter * mentionCompleter
Definition tab_game.h:74
void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize)
Definition tab_game.cpp:1203
void containerProcessingDone()
void actSay()
Definition tab_game.cpp:646
void newCardAdded(AbstractCardItem *card)
Definition tab_game.cpp:1005
void actResetLayout()
Definition tab_game.cpp:1245
void resetForRewind()
Definition tab_game.cpp:290
QAction * aGameInfo
Definition tab_game.h:96
bool leaveGame()
Definition tab_game.cpp:628
void notifyPlayerJoin(QString playerName)
Definition tab_game.cpp:743
void removePlayerFromAutoCompleteList(QString playerName)
Definition tab_game.cpp:673
void adminLockChanged(bool lock)
Definition tab_game.cpp:538
void stopGame()
Definition tab_game.cpp:944
void connectToGameState()
Definition tab_game.cpp:184
GameScene * scene
Definition tab_game.h:87
TearOffMenu * phasesMenu
Definition tab_game.h:95
CardInfoFrameWidget * cardInfoFrameWidget
Definition tab_game.h:79
void refreshShortcuts()
Definition tab_game.cpp:440
void actGameInfo()
Definition tab_game.cpp:545
QStringList autocompleteUserList
Definition tab_game.h:76
void actRotateViewCCW()
Definition tab_game.cpp:732
void actPhaseAction()
Definition tab_game.cpp:687
void updateInviteButtonState()
Definition tab_game.cpp:560
void createReplayMenuItems()
Definition tab_game.cpp:1155
void retranslateUi() override
Definition tab_game.cpp:331
void processPlayerLeave(PlayerLogic *leavingPlayer)
Definition tab_game.cpp:815
void viewCardInfo(const CardRef &cardRef={}) const
Definition tab_game.cpp:1328
void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:859
void connectMessageLogToGameEventHandler()
Definition tab_game.cpp:219
QAction * aResetLayout
Definition tab_game.h:97
QMap< int, TabbedDeckViewContainer * > deckViewContainers
Definition tab_game.h:89
void notifyPlayerKicked()
Definition tab_game.cpp:752
void loadLayout()
Definition tab_game.cpp:1233
QAction * aNextPhaseAction
Definition tab_game.h:96
PlayerLogic * addPlayer(PlayerLogic *newPlayer)
Definition tab_game.cpp:762
void updateTimeElapsedLabel(QString newTime)
Definition tab_game.cpp:533
void actRemoveLocalArrows()
Definition tab_game.cpp:719
PhasesToolbar * phasesToolbar
Definition tab_game.h:86
void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName)
Definition tab_game.cpp:837
void linkCardToChat(const QString &cardName)
Definition tab_game.cpp:284
QPushButton * inviteButton
Definition tab_game.h:81
void createCardInfoDock(bool bReplay=false)
Definition tab_game.cpp:1333
void phaseChanged(int phase)
void actConcede()
Definition tab_game.cpp:601
bool closeRequest() override
Definition tab_game.cpp:518
void createZoneForPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:892
QList< QAction * > phaseActions
Definition tab_game.h:100
void emitUserEvent()
Definition tab_game.cpp:306
QMenu * viewMenu
Definition tab_game.h:94
AbstractGame * getGame() const
Definition tab_game.h:208
void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:876
QString getTabText() const override
Definition tab_game.cpp:1019
void removeSpectator(int spectatorId, ServerInfo_User spectator)
Definition tab_game.cpp:680
GameView * gameView
Definition tab_game.h:88
QAction * aNextPhase
Definition tab_game.h:96
QDockWidget * replayDock
Definition tab_game.h:92
QMenu * gameMenu
Definition tab_game.h:94
PlayerListWidget * playerListWidget
Definition tab_game.h:80
QAction * aNextTurn
Definition tab_game.h:96
const UserListProxy * userListProxy
Definition tab_game.h:71
void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:865
void closeGame()
Definition tab_game.cpp:966
void connectToPlayerManager()
Definition tab_game.cpp:192
void addMentionTag(const QString &value)
Definition tab_game.cpp:278
QAction * aConcede
Definition tab_game.h:96
ReplayWidget * replayWidget
Definition tab_game.h:72
QAction * aRemoveLocalArrows
Definition tab_game.h:97
void openMessageDialog(const QString &userName, bool focus)
void turnAdvanced()
void createPlayerListDock(bool bReplay=false)
Definition tab_game.cpp:1355
QWidget * gamePlayAreaWidget
Definition tab_game.h:91
QWidget * deckViewContainerWidget
Definition tab_game.h:91
void createMessageDock(bool bReplay=false)
Definition tab_game.cpp:1392
void updatePlayerListDockTitle()
Definition tab_game.cpp:321
void createReplayDock(GameReplay *replay)
Definition tab_game.cpp:1299
void setActivePhase(int phase)
Definition tab_game.cpp:1000
QAction * aRotateViewCCW
Definition tab_game.h:97
QStackedWidget * mainWidget
Definition tab_game.h:77
QAction * aCardMenu
Definition tab_game.h:101
QAction * aInviteToGame
Definition tab_game.h:99
void gameClosing(TabGame *tab)
void notIdle()
void connectPlayerListToGameEventHandler()
Definition tab_game.cpp:264
QAction * playersSeparator
Definition tab_game.h:93
QDockWidget * messageLayoutDock
Definition tab_game.h:92
void containerProcessingStarted(const GameEventContext &context)
void hideEvent(QHideEvent *event) override
Definition tab_game.cpp:1486
void actRotateViewCW()
Definition tab_game.cpp:727
MessageLogWidget * messageLog
Definition tab_game.h:83
QVBoxLayout * deckViewContainerLayout
Definition tab_game.h:90
QAction * aFocusChat
Definition tab_game.h:98
void openDeckEditor(const LoadedDeck &deck)
void chatMessageSent(QString chatMessage)
void processLocalPlayerReadyStateChanged(int playerId, bool ready)
Definition tab_game.cpp:887
void connectToGameEventHandler()
Definition tab_game.cpp:201
void actCopyGameLink()
Definition tab_game.cpp:551
void createMenuItems()
Definition tab_game.cpp:1076
LineEditCompleter * sayEdit
Definition tab_game.h:85
PlayerLogic * setActivePlayer(int id)
Definition tab_game.cpp:972
void actNextPhase()
Definition tab_game.cpp:693
void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked)
Definition tab_game.cpp:882
void processMultipleRemotePlayerDeckSelect(QVector< QPair< int, QPair< QString, QString > > > playerIdDeckMap)
Definition tab_game.cpp:848
QMap< QDockWidget *, DockActions > dockToActions
Definition tab_game.h:114
Definition tab_supervisor.h:92
Tab(TabSupervisor *_tabSupervisor)
Definition tab.cpp:16
Definition tabbed_deck_view_container.h:20
Definition tearoff_menu.h:15
Definition user_list_proxy.h:19
Q_LOGGING_CATEGORY(CrashReportLog, "crash_report")
Definition card_ref.h:14
Definition event_game_joined.proto:5
Definition game_event_context.proto:2
Definition game_replay.proto:4
Represents a deck that was loaded from somewhere. Contains the DeckList itself, as well as info about...
Definition loaded_deck.h:14
Definition serverinfo_player.proto:6
Definition serverinfo_user.proto:2
The actions associated with managing a QDockWidget.
Definition tab_game.h:107
QAction * aVisible
Definition tab_game.h:109
QAction * aFloating
Definition tab_game.h:110
QMenu * menu
Definition tab_game.h:108
QSize defaultSize
Definition tab_game.h:111