Cockatrice 2026-06-27-Development-3.1.0-beta.3
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 "../game/abstract_game.h"
13#include "../game/player/player_logic.h"
14#include "../game_graphics/log/message_log_widget.h"
15#include "../interface/widgets/menus/tearoff_menu.h"
16#include "../interface/widgets/replay/replay_manager.h"
17#include "tab.h"
18
19#include <QCompleter>
20#include <QLoggingCategory>
21#include <QMap>
22
23class CardMenu;
24class ServerInfo_PlayerProperties;
26inline Q_LOGGING_CATEGORY(TabGameLog, "tab_game");
27
28class UserListProxy;
30class AbstractClient;
31class CardDatabase;
32class GameView;
33class GameScene;
34class ReplayManager;
36class QTimer;
37class QSplitter;
38class QLabel;
39class QToolButton;
40class QMenu;
41class ZoneViewLayout;
42class ZoneViewWidget;
43class PhasesToolbar;
46class CardZone;
48class CardItem;
49class QVBoxLayout;
50class QHBoxLayout;
51class GameReplay;
53class QDockWidget;
54class QStackedWidget;
55
56class TabGame : public Tab
57{
58 Q_OBJECT
59private:
63 QStringList gameTypes;
64 QCompleter *completer;
66 QStackedWidget *mainWidget;
67
72 QLabel *sayLabel;
77 QMap<int, TabbedDeckViewContainer *> deckViewContainers;
86 QAction *aFocusChat;
87 QList<QAction *> phaseActions;
88 QAction *aCardMenu;
89
94 {
95 QMenu *menu;
96 QAction *aVisible;
97 QAction *aFloating;
99 };
100
101 QMap<QDockWidget *, DockActions> dockToActions;
102
103 PlayerLogic *addPlayer(PlayerLogic *newPlayer);
104 void addLocalPlayer(PlayerLogic *newPlayer, int playerId);
105 void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName);
106 void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap);
107 void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
108 void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
109 void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo);
110 void createZoneForPlayer(PlayerLogic *newPlayer, int playerId);
111
112 void startGame(bool resuming);
113 void stopGame();
114 void closeGame();
115 bool leaveGame();
116
118 void setActivePhase(int phase);
119 void createMenuItems();
121 void createViewMenuItems();
122 void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize);
123 void createCardInfoDock(bool bReplay = false);
124 void createPlayerListDock(bool bReplay = false);
125 void createMessageDock(bool bReplay = false);
126 void createPlayAreaWidget(bool bReplay = false);
127 void createDeckViewContainerWidget(bool bReplay = false);
128 void createReplayDock(GameReplay *replay);
129signals:
131 void containerProcessingStarted(const GameEventContext &context);
133 void openMessageDialog(const QString &userName, bool focus);
134 void openDeckEditor(const LoadedDeck &deck);
135 void notIdle();
136
137 void phaseChanged(int phase);
138 void gameLeft();
139 void chatMessageSent(QString chatMessage);
141
142private slots:
143 void adminLockChanged(bool lock);
144 void newCardAdded(AbstractCardItem *card);
145 void setCardMenu(CardMenu *menu);
146
147 void actGameInfo();
148 void actConcede();
150 void actRotateViewCW();
151 void actRotateViewCCW();
152 void actSay();
153 void actPhaseAction();
154 void actNextPhase();
155 void actNextPhaseAction();
156
157 void addMentionTag(const QString &value);
158 void linkCardToChat(const QString &cardName);
159
160 void refreshShortcuts();
161
162 void loadLayout();
163 void actCompleterChanged();
164 void notifyPlayerJoin(QString playerName);
165 void notifyPlayerKicked();
166 void processPlayerLeave(PlayerLogic *leavingPlayer);
167 void actResetLayout();
168
169 void hideEvent(QHideEvent *event) override;
170
171protected slots:
172 void closeEvent(QCloseEvent *event) override;
173
174public:
175 TabGame(TabSupervisor *_tabSupervisor,
176 QList<AbstractClient *> &_clients,
177 const Event_GameJoined &event,
178 const QMap<int, QString> &_roomGameTypes);
179 void connectToGameState();
184 TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
185 ~TabGame() override;
186 void retranslateUi() override;
188 bool closeRequest() override;
189
190 [[nodiscard]] QString getTabText() const override;
191
192 [[nodiscard]] AbstractGame *getGame() const
193 {
194 return game;
195 }
196
197public slots:
198 void viewCardInfo(const CardRef &cardRef = {}) const;
199 void resetChatAndPhase();
200 void updateTimeElapsedLabel(QString newTime);
201 void addPlayerToAutoCompleteList(QString playerName);
202 void removePlayerFromAutoCompleteList(QString playerName);
203 void removeSpectator(int spectatorId, ServerInfo_User spectator);
204 void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked);
205 void processLocalPlayerReadyStateChanged(int playerId, bool ready);
206 void emitUserEvent();
207};
208
209#endif
Definition abstract_card_item.h:20
Definition abstract_client.h:51
Definition abstract_game.h:20
Core in-memory container for card and set data.
Definition card_database.h:29
Definition card_info_frame_widget.h:22
Definition card_item.h:28
Definition card_menu.h:17
Definition card_zone.h:26
Definition deck_view_container.h:49
Manages the game board display including players, zones, cards, and animations.
Definition game_scene.h:41
Definition game_view.h:17
Definition line_edit_completer.h:15
Definition message_log_widget.h:20
Definition phases_toolbar.h:66
Definition player_list_widget.h:41
Definition player_logic.h:64
Definition replay_manager.h:20
Definition replay_timeline_widget.h:19
TabGame(TabSupervisor *_tabSupervisor, QList< AbstractClient * > &_clients, const Event_GameJoined &event, const QMap< int, QString > &_roomGameTypes)
Definition tab_game.cpp:90
void actCompleterChanged()
Definition tab_game.cpp:627
AbstractGame * game
Definition tab_game.h:60
void gameLeft()
QDockWidget * cardInfoDock
Definition tab_game.h:80
void createPlayAreaWidget(bool bReplay=false)
Definition tab_game.cpp:1146
QAction * aResetReplayLayout
Definition tab_game.h:85
void closeEvent(QCloseEvent *event) override
Definition tab_game.cpp:468
QDockWidget * playerListDock
Definition tab_game.h:80
QStringList gameTypes
Definition tab_game.h:63
void createDeckViewContainerWidget(bool bReplay=false)
Definition tab_game.cpp:1187
void setCardMenu(CardMenu *menu)
Definition tab_game.cpp:946
QAction * aReverseTurn
Definition tab_game.h:84
void startGame(bool resuming)
Definition tab_game.cpp:803
void actNextPhaseAction()
Definition tab_game.cpp:593
QAction * aRotateViewCW
Definition tab_game.h:85
void createViewMenuItems()
Definition tab_game.cpp:1053
QCompleter * completer
Definition tab_game.h:64
QAction * aLeaveGame
Definition tab_game.h:84
QLabel * timeElapsedLabel
Definition tab_game.h:70
QLabel * sayLabel
Definition tab_game.h:72
void addLocalPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:684
void addPlayerToAutoCompleteList(QString playerName)
Definition tab_game.cpp:555
void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize)
Definition tab_game.cpp:1074
void containerProcessingDone()
void actSay()
Definition tab_game.cpp:537
void newCardAdded(AbstractCardItem *card)
Definition tab_game.cpp:894
void actResetLayout()
Definition tab_game.cpp:1116
QAction * aGameInfo
Definition tab_game.h:84
bool leaveGame()
Definition tab_game.cpp:519
void notifyPlayerJoin(QString playerName)
Definition tab_game.cpp:633
void removePlayerFromAutoCompleteList(QString playerName)
Definition tab_game.cpp:563
void adminLockChanged(bool lock)
Definition tab_game.cpp:479
void stopGame()
Definition tab_game.cpp:834
void connectToGameState()
Definition tab_game.cpp:138
GameScene * scene
Definition tab_game.h:75
TearOffMenu * phasesMenu
Definition tab_game.h:83
CardInfoFrameWidget * cardInfoFrameWidget
Definition tab_game.h:68
void refreshShortcuts()
Definition tab_game.cpp:381
void actGameInfo()
Definition tab_game.cpp:486
QStringList autocompleteUserList
Definition tab_game.h:65
void actRotateViewCCW()
Definition tab_game.cpp:622
void actPhaseAction()
Definition tab_game.cpp:577
void createReplayMenuItems()
Definition tab_game.cpp:1028
void retranslateUi() override
Definition tab_game.cpp:281
void processPlayerLeave(PlayerLogic *leavingPlayer)
Definition tab_game.cpp:705
void viewCardInfo(const CardRef &cardRef={}) const
Definition tab_game.cpp:1198
void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:749
void connectMessageLogToGameEventHandler()
Definition tab_game.cpp:173
QAction * aResetLayout
Definition tab_game.h:85
QMap< int, TabbedDeckViewContainer * > deckViewContainers
Definition tab_game.h:77
void notifyPlayerKicked()
Definition tab_game.cpp:642
void loadLayout()
Definition tab_game.cpp:1104
QAction * aNextPhaseAction
Definition tab_game.h:84
PlayerLogic * addPlayer(PlayerLogic *newPlayer)
Definition tab_game.cpp:652
void updateTimeElapsedLabel(QString newTime)
Definition tab_game.cpp:474
void actRemoveLocalArrows()
Definition tab_game.cpp:609
PhasesToolbar * phasesToolbar
Definition tab_game.h:74
void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName)
Definition tab_game.cpp:727
void linkCardToChat(const QString &cardName)
Definition tab_game.cpp:238
void createCardInfoDock(bool bReplay=false)
Definition tab_game.cpp:1203
void phaseChanged(int phase)
void actConcede()
Definition tab_game.cpp:492
bool closeRequest() override
Definition tab_game.cpp:459
void createZoneForPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:782
QList< QAction * > phaseActions
Definition tab_game.h:87
void emitUserEvent()
Definition tab_game.cpp:253
QMenu * viewMenu
Definition tab_game.h:82
AbstractGame * getGame() const
Definition tab_game.h:192
void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:766
QString getTabText() const override
Definition tab_game.cpp:908
void removeSpectator(int spectatorId, ServerInfo_User spectator)
Definition tab_game.cpp:570
GameView * gameView
Definition tab_game.h:76
QAction * aNextPhase
Definition tab_game.h:84
QDockWidget * replayDock
Definition tab_game.h:80
QMenu * gameMenu
Definition tab_game.h:82
PlayerListWidget * playerListWidget
Definition tab_game.h:69
QAction * aNextTurn
Definition tab_game.h:84
const UserListProxy * userListProxy
Definition tab_game.h:61
void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:755
void closeGame()
Definition tab_game.cpp:855
void connectToPlayerManager()
Definition tab_game.cpp:146
void addMentionTag(const QString &value)
Definition tab_game.cpp:232
QAction * aConcede
Definition tab_game.h:84
QAction * aRemoveLocalArrows
Definition tab_game.h:85
void openMessageDialog(const QString &userName, bool focus)
void turnAdvanced()
void createPlayerListDock(bool bReplay=false)
Definition tab_game.cpp:1225
QWidget * gamePlayAreaWidget
Definition tab_game.h:79
QWidget * deckViewContainerWidget
Definition tab_game.h:79
void createMessageDock(bool bReplay=false)
Definition tab_game.cpp:1244
void updatePlayerListDockTitle()
Definition tab_game.cpp:271
void createReplayDock(GameReplay *replay)
Definition tab_game.cpp:1170
~TabGame() override
Definition tab_game.cpp:261
void setActivePhase(int phase)
Definition tab_game.cpp:889
QAction * aRotateViewCCW
Definition tab_game.h:85
QStackedWidget * mainWidget
Definition tab_game.h:66
ReplayManager * replayManager
Definition tab_game.h:62
QAction * aCardMenu
Definition tab_game.h:88
void gameClosing(TabGame *tab)
void notIdle()
void connectPlayerListToGameEventHandler()
Definition tab_game.cpp:218
QAction * playersSeparator
Definition tab_game.h:81
QDockWidget * messageLayoutDock
Definition tab_game.h:80
void containerProcessingStarted(const GameEventContext &context)
void hideEvent(QHideEvent *event) override
Definition tab_game.cpp:1324
void actRotateViewCW()
Definition tab_game.cpp:617
MessageLogWidget * messageLog
Definition tab_game.h:71
QVBoxLayout * deckViewContainerLayout
Definition tab_game.h:78
QAction * aFocusChat
Definition tab_game.h:86
void openDeckEditor(const LoadedDeck &deck)
void chatMessageSent(QString chatMessage)
void processLocalPlayerReadyStateChanged(int playerId, bool ready)
Definition tab_game.cpp:777
void connectToGameEventHandler()
Definition tab_game.cpp:155
void createMenuItems()
Definition tab_game.cpp:959
LineEditCompleter * sayEdit
Definition tab_game.h:73
PlayerLogic * setActivePlayer(int id)
Definition tab_game.cpp:861
void actNextPhase()
Definition tab_game.cpp:583
void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked)
Definition tab_game.cpp:772
void processMultipleRemotePlayerDeckSelect(QVector< QPair< int, QPair< QString, QString > > > playerIdDeckMap)
Definition tab_game.cpp:738
void resetChatAndPhase()
Definition tab_game.cpp:244
QMap< QDockWidget *, DockActions > dockToActions
Definition tab_game.h:101
Definition tab_supervisor.h:84
Tab(TabSupervisor *_tabSupervisor)
Definition tab.cpp:11
Definition tabbed_deck_view_container.h:14
Definition tearoff_menu.h:14
Definition user_list_proxy.h:19
Definition view_zone_widget.h:51
Definition card_ref.h:14
Represents a deck that was loaded from somewhere. Contains the DeckList itself, as well as info about...
Definition loaded_deck.h:14
The actions associated with managing a QDockWidget.
Definition tab_game.h:94
QAction * aVisible
Definition tab_game.h:96
QAction * aFloating
Definition tab_game.h:97
QMenu * menu
Definition tab_game.h:95
QSize defaultSize
Definition tab_game.h:98
Q_LOGGING_CATEGORY(TabGameLog, "tab_game")