Cockatrice 2026-09-01-Development-3.1.0-beta.10
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
game_selector.h
Go to the documentation of this file.
1#ifndef GAMESELECTOR_H
2#define GAMESELECTOR_H
3
5#include "game_type_map.h"
6
7#include <QGroupBox>
8#include <libcockatrice/protocol/pb/commands.pb.h>
9#include <libcockatrice/protocol/pb/event_add_to_list.pb.h>
10#include <libcockatrice/protocol/pb/event_remove_from_list.pb.h>
11
12class QTreeView;
13class GamesModel;
14class GamesProxyModel;
15class QPushButton;
16class QCheckBox;
17class QLabel;
18class AbstractClient;
19class TabSupervisor;
20class TabRoom;
21class ServerInfo_Game;
22class Response;
23
33class GameSelector : public QGroupBox
34{
35 Q_OBJECT
36private slots:
42 void actSetFilter();
44
50 void actClearFilter();
51
55 void actCreate();
56
60 void actJoin();
64 void actJoinAsJudge();
65
69 void actJoinAsSpectator();
71
76 void customContextMenu(const QPoint &point);
77
85 void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous);
86
93 void checkResponse(const Response &response);
94
99 void ignoreListReceived(const QList<ServerInfo_User> &_ignoreList);
100
105 void processAddToListEvent(const Event_AddToList &event);
106
112
113signals:
118 void gameJoined(int gameId);
119
120private:
124
125 QTreeView *gameListView;
128
130
131 QPushButton *filterButton;
132 QPushButton *clearFilterButton;
133 QPushButton *createButton;
134 QPushButton *joinButton;
135 QPushButton *joinAsJudgeButton;
136 QPushButton *spectateButton;
138
139 const bool showFilters;
141
147 void updateTitle();
148
152 void disableButtons();
153
157 void enableButtons();
158
163 void enableButtonsForIndex(const QModelIndex &current);
164
172 void joinGame(bool asSpectator = false, bool asJudge = false);
173
183 void joinGame(const ServerInfo_Game &game, bool asSpectator = false, bool asJudge = false);
184
185public:
198 TabSupervisor *_tabSupervisor,
199 TabRoom *_room,
200 const QMap<int, QString> &_rooms,
201 const QMap<int, GameTypeMap> &_gameTypes,
202 const bool restoresettings,
203 const bool _showfilters,
204 QWidget *parent = nullptr);
205
209 void retranslateUi();
210
215 void processGameInfo(const ServerInfo_Game &info);
225 bool joinGameById(int gameId, bool asSpectator = false);
226};
227
228#endif
Definition abstract_client.h:57
Definition game_selector_quick_filter_toolbar.h:12
void enableButtons()
Enables buttons for the currently selected game.
Definition game_selector.cpp:447
AbstractClient * client
Definition game_selector.h:121
void actJoinAsSpectator()
Joins the currently selected game as a spectator.
Definition game_selector.cpp:286
QPushButton * createButton
Definition game_selector.h:133
QPushButton * joinAsJudgeSpectatorButton
Definition game_selector.h:137
void actSelectedGameChanged(const QModelIndex &current, const QModelIndex &previous)
Slot called when the selected game changes.
Definition game_selector.cpp:491
void actJoin()
Joins the currently selected game as a player.
Definition game_selector.cpp:272
void retranslateUi()
Updates UI text for translation/localization.
Definition game_selector.cpp:470
const bool showFilters
Definition game_selector.h:139
GameSelectorQuickFilterToolBar * quickFilterToolBar
Definition game_selector.h:129
bool joinGameById(int gameId, bool asSpectator=false)
Finds a game by ID and joins or spectates it.
Definition game_selector.cpp:421
GameSelector(AbstractClient *_client, TabSupervisor *_tabSupervisor, TabRoom *_room, const QMap< int, QString > &_rooms, const QMap< int, GameTypeMap > &_gameTypes, const bool restoresettings, const bool _showfilters, QWidget *parent=nullptr)
Constructs a GameSelector widget.
Definition game_selector.cpp:30
void ignoreListReceived(const QList< ServerInfo_User > &_ignoreList)
Refreshes the game list when the ignore list is received from the server.
Definition game_selector.cpp:167
GamesProxyModel * gameListProxyModel
Definition game_selector.h:127
QPushButton * joinAsJudgeButton
Definition game_selector.h:135
void actJoinAsJudge()
Joins the currently selected game as a judge.
Definition game_selector.cpp:277
void actSetFilter()
Opens a dialog to set filters for the game list.
Definition game_selector.cpp:188
TabSupervisor * tabSupervisor
Definition game_selector.h:122
void actClearFilter()
Clears all filters applied to the game list.
Definition game_selector.cpp:207
QPushButton * joinButton
Definition game_selector.h:134
GameTypeMap gameTypeMap
Definition game_selector.h:140
void processAddToListEvent(const Event_AddToList &event)
Processes events where a user is added to a list (e.g., ignore or buddy).
Definition game_selector.cpp:172
void checkClearFilterButtonState()
Definition game_selector.cpp:202
GamesModel * gameListModel
Definition game_selector.h:126
QPushButton * spectateButton
Definition game_selector.h:136
void customContextMenu(const QPoint &point)
Shows the custom context menu for a game when right-clicked.
Definition game_selector.cpp:300
void disableButtons()
Disables create/join/spectate buttons.
Definition game_selector.cpp:437
void processGameInfo(const ServerInfo_Game &info)
Updates or adds a game entry in the list.
Definition game_selector.cpp:485
void gameJoined(int gameId)
Emitted when a game has been successfully joined.
void processRemoveFromListEvent(const Event_RemoveFromList &event)
Processes events where a user is removed from a list (e.g., ignore or buddy).
Definition game_selector.cpp:180
TabRoom * room
Definition game_selector.h:123
void enableButtonsForIndex(const QModelIndex &current)
Enables buttons for a specific game index.
Definition game_selector.cpp:457
void actCreate()
Opens the dialog to create a new game in the current room.
Definition game_selector.cpp:215
QPushButton * clearFilterButton
Definition game_selector.h:132
void updateTitle()
Updates the widget title to reflect the current number of displayed games.
Definition game_selector.cpp:496
void joinGame(bool asSpectator=false, bool asJudge=false)
Performs the join or spectate action for the currently selected game.
Definition game_selector.cpp:355
QPushButton * filterButton
Definition game_selector.h:131
QTreeView * gameListView
Definition game_selector.h:125
void checkResponse(const Response &response)
Processes server responses for join or spectate commands.
Definition game_selector.cpp:227
void actJoinAsJudgeSpectator()
Definition game_selector.cpp:291
Model storing all available games for display in a QTreeView or QTableView.
Definition games_model.h:24
Proxy model for filtering and sorting the GamesModel based on user preferences.
Definition games_model.h:113
Definition tab_room.h:51
Definition tab_supervisor.h:84
QMap< int, QString > GameTypeMap
Definition game_type_map.h:6
Definition event_add_to_list.proto:4
Definition event_remove_from_list.proto:3
Definition response.proto:11
Definition serverinfo_game.proto:5