Cockatrice 2026-06-01-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/log/message_log_widget.h"
14#include "../game/player/player_logic.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 ServerInfo_PlayerProperties;
25inline Q_LOGGING_CATEGORY(TabGameLog, "tab_game");
26
27class UserListProxy;
29class AbstractClient;
30class CardDatabase;
31class GameView;
32class GameScene;
33class ReplayManager;
35class QTimer;
36class QSplitter;
37class QLabel;
38class QToolButton;
39class QMenu;
40class ZoneViewLayout;
41class ZoneViewWidget;
42class PhasesToolbar;
45class CardZone;
47class CardItem;
48class QVBoxLayout;
49class QHBoxLayout;
50class GameReplay;
52class QDockWidget;
53class QStackedWidget;
54
55class TabGame : public Tab
56{
57 Q_OBJECT
58private:
62 QStringList gameTypes;
63 QCompleter *completer;
65 QStackedWidget *mainWidget;
66
71 QLabel *sayLabel;
76 QMap<int, TabbedDeckViewContainer *> deckViewContainers;
85 QAction *aFocusChat;
86 QList<QAction *> phaseActions;
87 QAction *aCardMenu;
88
93 {
94 QMenu *menu;
95 QAction *aVisible;
96 QAction *aFloating;
98 };
99
100 QMap<QDockWidget *, DockActions> dockToActions;
101
102 PlayerLogic *addPlayer(PlayerLogic *newPlayer);
103 void addLocalPlayer(PlayerLogic *newPlayer, int playerId);
104 void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName);
105 void processMultipleRemotePlayerDeckSelect(QVector<QPair<int, QPair<QString, QString>>> playerIdDeckMap);
106 void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
107 void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo);
108 void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo);
109 void createZoneForPlayer(PlayerLogic *newPlayer, int playerId);
110
111 void startGame(bool resuming);
112 void stopGame();
113 void closeGame();
114 bool leaveGame();
115
117 void setActivePhase(int phase);
118 void createMenuItems();
120 void createViewMenuItems();
121 void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize);
122 void createCardInfoDock(bool bReplay = false);
123 void createPlayerListDock(bool bReplay = false);
124 void createMessageDock(bool bReplay = false);
125 void createPlayAreaWidget(bool bReplay = false);
126 void createDeckViewContainerWidget(bool bReplay = false);
127 void createReplayDock(GameReplay *replay);
128signals:
130 void containerProcessingStarted(const GameEventContext &context);
132 void openMessageDialog(const QString &userName, bool focus);
133 void openDeckEditor(const LoadedDeck &deck);
134 void notIdle();
135
136 void phaseChanged(int phase);
137 void gameLeft();
138 void chatMessageSent(QString chatMessage);
140
141private slots:
142 void adminLockChanged(bool lock);
143 void newCardAdded(AbstractCardItem *card);
144 void setCardMenu(QMenu *menu);
145
146 void actGameInfo();
147 void actConcede();
149 void actRotateViewCW();
150 void actRotateViewCCW();
151 void actSay();
152 void actPhaseAction();
153 void actNextPhase();
154 void actNextPhaseAction();
155
156 void addMentionTag(const QString &value);
157 void linkCardToChat(const QString &cardName);
158
159 void refreshShortcuts();
160
161 void loadLayout();
162 void actCompleterChanged();
163 void notifyPlayerJoin(QString playerName);
164 void notifyPlayerKicked();
165 void processPlayerLeave(PlayerLogic *leavingPlayer);
166 void actResetLayout();
167
168 void hideEvent(QHideEvent *event) override;
169
170protected slots:
171 void closeEvent(QCloseEvent *event) override;
172
173public:
174 TabGame(TabSupervisor *_tabSupervisor,
175 QList<AbstractClient *> &_clients,
176 const Event_GameJoined &event,
177 const QMap<int, QString> &_roomGameTypes);
178 void connectToGameState();
183 TabGame(TabSupervisor *_tabSupervisor, GameReplay *replay);
184 ~TabGame() override;
185 void retranslateUi() override;
187 bool closeRequest() override;
188
189 [[nodiscard]] QString getTabText() const override;
190
191 [[nodiscard]] AbstractGame *getGame() const
192 {
193 return game;
194 }
195
196public slots:
197 void viewCardInfo(const CardRef &cardRef = {}) const;
198 void resetChatAndPhase();
199 void updateTimeElapsedLabel(QString newTime);
200 void addPlayerToAutoCompleteList(QString playerName);
201 void removePlayerFromAutoCompleteList(QString playerName);
202 void removeSpectator(int spectatorId, ServerInfo_User spectator);
203 void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked);
204 void processLocalPlayerReadyStateChanged(int playerId, bool ready);
205 void emitUserEvent();
206};
207
208#endif
Definition abstract_card_item.h:20
Definition abstract_client.h:51
Definition abstract_game.h:21
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_zone.h:26
Definition deck_view_container.h:49
Manages the game board display including players, zones, cards, and animations.
Definition game_scene.h:40
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:65
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:87
void actCompleterChanged()
Definition tab_game.cpp:625
AbstractGame * game
Definition tab_game.h:59
void gameLeft()
QDockWidget * cardInfoDock
Definition tab_game.h:79
void createPlayAreaWidget(bool bReplay=false)
Definition tab_game.cpp:1143
QAction * aResetReplayLayout
Definition tab_game.h:84
void closeEvent(QCloseEvent *event) override
Definition tab_game.cpp:466
QDockWidget * playerListDock
Definition tab_game.h:79
QStringList gameTypes
Definition tab_game.h:62
void createDeckViewContainerWidget(bool bReplay=false)
Definition tab_game.cpp:1179
QAction * aReverseTurn
Definition tab_game.h:83
void startGame(bool resuming)
Definition tab_game.cpp:800
void actNextPhaseAction()
Definition tab_game.cpp:591
QAction * aRotateViewCW
Definition tab_game.h:84
void createViewMenuItems()
Definition tab_game.cpp:1050
QCompleter * completer
Definition tab_game.h:63
QAction * aLeaveGame
Definition tab_game.h:83
QLabel * timeElapsedLabel
Definition tab_game.h:69
QLabel * sayLabel
Definition tab_game.h:71
void addLocalPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:678
void addPlayerToAutoCompleteList(QString playerName)
Definition tab_game.cpp:553
void registerDockWidget(QMenu *_viewMenu, QDockWidget *widget, const QSize &defaultSize)
Definition tab_game.cpp:1071
void containerProcessingDone()
void actSay()
Definition tab_game.cpp:535
void newCardAdded(AbstractCardItem *card)
Definition tab_game.cpp:891
void actResetLayout()
Definition tab_game.cpp:1113
QAction * aGameInfo
Definition tab_game.h:83
bool leaveGame()
Definition tab_game.cpp:517
void notifyPlayerJoin(QString playerName)
Definition tab_game.cpp:631
void removePlayerFromAutoCompleteList(QString playerName)
Definition tab_game.cpp:561
void adminLockChanged(bool lock)
Definition tab_game.cpp:477
void stopGame()
Definition tab_game.cpp:831
void connectToGameState()
Definition tab_game.cpp:135
GameScene * scene
Definition tab_game.h:74
TearOffMenu * phasesMenu
Definition tab_game.h:82
CardInfoFrameWidget * cardInfoFrameWidget
Definition tab_game.h:67
void refreshShortcuts()
Definition tab_game.cpp:379
void actGameInfo()
Definition tab_game.cpp:484
QStringList autocompleteUserList
Definition tab_game.h:64
void actRotateViewCCW()
Definition tab_game.cpp:620
void actPhaseAction()
Definition tab_game.cpp:575
void createReplayMenuItems()
Definition tab_game.cpp:1025
void retranslateUi() override
Definition tab_game.cpp:278
void processPlayerLeave(PlayerLogic *leavingPlayer)
Definition tab_game.cpp:699
void viewCardInfo(const CardRef &cardRef={}) const
Definition tab_game.cpp:1190
void setCardMenu(QMenu *menu)
Definition tab_game.cpp:943
void processLocalPlayerDeckSelect(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:746
void connectMessageLogToGameEventHandler()
Definition tab_game.cpp:170
QAction * aResetLayout
Definition tab_game.h:84
QMap< int, TabbedDeckViewContainer * > deckViewContainers
Definition tab_game.h:76
void notifyPlayerKicked()
Definition tab_game.cpp:640
void loadLayout()
Definition tab_game.cpp:1101
QAction * aNextPhaseAction
Definition tab_game.h:83
PlayerLogic * addPlayer(PlayerLogic *newPlayer)
Definition tab_game.cpp:650
void updateTimeElapsedLabel(QString newTime)
Definition tab_game.cpp:472
void actRemoveLocalArrows()
Definition tab_game.cpp:607
PhasesToolbar * phasesToolbar
Definition tab_game.h:73
void processRemotePlayerDeckSelect(QString deckList, int playerId, QString playerName)
Definition tab_game.cpp:724
void linkCardToChat(const QString &cardName)
Definition tab_game.cpp:235
void createCardInfoDock(bool bReplay=false)
Definition tab_game.cpp:1195
void phaseChanged(int phase)
void actConcede()
Definition tab_game.cpp:490
bool closeRequest() override
Definition tab_game.cpp:457
void createZoneForPlayer(PlayerLogic *newPlayer, int playerId)
Definition tab_game.cpp:779
QList< QAction * > phaseActions
Definition tab_game.h:86
void emitUserEvent()
Definition tab_game.cpp:250
QMenu * viewMenu
Definition tab_game.h:81
AbstractGame * getGame() const
Definition tab_game.h:191
void processLocalPlayerReady(int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:763
QString getTabText() const override
Definition tab_game.cpp:905
void removeSpectator(int spectatorId, ServerInfo_User spectator)
Definition tab_game.cpp:568
GameView * gameView
Definition tab_game.h:75
QAction * aNextPhase
Definition tab_game.h:83
QDockWidget * replayDock
Definition tab_game.h:79
QMenu * gameMenu
Definition tab_game.h:81
PlayerListWidget * playerListWidget
Definition tab_game.h:68
QAction * aNextTurn
Definition tab_game.h:83
const UserListProxy * userListProxy
Definition tab_game.h:60
void loadDeckForLocalPlayer(PlayerLogic *localPlayer, int playerId, ServerInfo_Player playerInfo)
Definition tab_game.cpp:752
void closeGame()
Definition tab_game.cpp:852
void connectToPlayerManager()
Definition tab_game.cpp:143
void addMentionTag(const QString &value)
Definition tab_game.cpp:229
QAction * aConcede
Definition tab_game.h:83
QAction * aRemoveLocalArrows
Definition tab_game.h:84
void openMessageDialog(const QString &userName, bool focus)
void turnAdvanced()
void createPlayerListDock(bool bReplay=false)
Definition tab_game.cpp:1217
QWidget * gamePlayAreaWidget
Definition tab_game.h:78
QWidget * deckViewContainerWidget
Definition tab_game.h:78
void createMessageDock(bool bReplay=false)
Definition tab_game.cpp:1236
void updatePlayerListDockTitle()
Definition tab_game.cpp:268
void createReplayDock(GameReplay *replay)
Definition tab_game.cpp:1167
~TabGame() override
Definition tab_game.cpp:258
void setActivePhase(int phase)
Definition tab_game.cpp:886
QAction * aRotateViewCCW
Definition tab_game.h:84
QStackedWidget * mainWidget
Definition tab_game.h:65
ReplayManager * replayManager
Definition tab_game.h:61
QAction * aCardMenu
Definition tab_game.h:87
void gameClosing(TabGame *tab)
void notIdle()
void connectPlayerListToGameEventHandler()
Definition tab_game.cpp:215
QAction * playersSeparator
Definition tab_game.h:80
QDockWidget * messageLayoutDock
Definition tab_game.h:79
void containerProcessingStarted(const GameEventContext &context)
void hideEvent(QHideEvent *event) override
Definition tab_game.cpp:1316
void actRotateViewCW()
Definition tab_game.cpp:615
MessageLogWidget * messageLog
Definition tab_game.h:70
QVBoxLayout * deckViewContainerLayout
Definition tab_game.h:77
QAction * aFocusChat
Definition tab_game.h:85
void openDeckEditor(const LoadedDeck &deck)
void chatMessageSent(QString chatMessage)
void processLocalPlayerReadyStateChanged(int playerId, bool ready)
Definition tab_game.cpp:774
void connectToGameEventHandler()
Definition tab_game.cpp:152
void createMenuItems()
Definition tab_game.cpp:956
LineEditCompleter * sayEdit
Definition tab_game.h:72
PlayerLogic * setActivePlayer(int id)
Definition tab_game.cpp:858
void actNextPhase()
Definition tab_game.cpp:581
void processLocalPlayerSideboardLocked(int playerId, bool sideboardLocked)
Definition tab_game.cpp:769
void processMultipleRemotePlayerDeckSelect(QVector< QPair< int, QPair< QString, QString > > > playerIdDeckMap)
Definition tab_game.cpp:735
void resetChatAndPhase()
Definition tab_game.cpp:241
QMap< QDockWidget *, DockActions > dockToActions
Definition tab_game.h:100
Definition tab_supervisor.h:83
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:93
QAction * aVisible
Definition tab_game.h:95
QAction * aFloating
Definition tab_game.h:96
QMenu * menu
Definition tab_game.h:94
QSize defaultSize
Definition tab_game.h:97
Q_LOGGING_CATEGORY(TabGameLog, "tab_game")