Cockatrice 2025-11-30-Development-2.11.0-beta.38
A cross-platform virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
GameSelector Class Reference

Provides a widget for displaying, filtering, joining, spectating, and creating games in a room. More...

#include <game_selector.h>

Inheritance diagram for GameSelector:
[legend]
Collaboration diagram for GameSelector:
[legend]

Signals

void gameJoined (int gameId)
 Emitted when a game has been successfully joined.

Public Member Functions

 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.
void retranslateUi ()
 Updates UI text for translation/localization.
void processGameInfo (const ServerInfo_Game &info)
 Updates or adds a game entry in the list.

Private Slots

void actSetFilter ()
 Opens a dialog to set filters for the game list.
void actClearFilter ()
 Clears all filters applied to the game list.
void actCreate ()
 Opens the dialog to create a new game in the current room.
void actJoin ()
 Joins the currently selected game as a player.
void actJoinAsJudge ()
 Joins the currently selected game as a judge.
void actJoinAsSpectator ()
 Joins the currently selected game as a spectator.
void actJoinAsJudgeSpectator ()
void customContextMenu (const QPoint &point)
 Shows the custom context menu for a game when right-clicked.
void actSelectedGameChanged (const QModelIndex &current, const QModelIndex &previous)
 Slot called when the selected game changes.
void checkResponse (const Response &response)
 Processes server responses for join or spectate commands.
void ignoreListReceived (const QList< ServerInfo_User > &_ignoreList)
 Refreshes the game list when the ignore list is received from the server.
void processAddToListEvent (const Event_AddToList &event)
 Processes events where a user is added to a list (e.g., ignore or buddy).
void processRemoveFromListEvent (const Event_RemoveFromList &event)
 Processes events where a user is removed from a list (e.g., ignore or buddy).

Private Member Functions

void updateTitle ()
 Updates the widget title to reflect the current number of displayed games.
void disableButtons ()
 Disables create/join/spectate buttons.
void enableButtons ()
 Enables buttons for the currently selected game.
void enableButtonsForIndex (const QModelIndex &current)
 Enables buttons for a specific game index.
void joinGame (bool asSpectator=false, bool asJudge=false)
 Performs the join or spectate action for the currently selected game.

Private Attributes

AbstractClientclient
TabSupervisortabSupervisor
TabRoomroom
QTreeView * gameListView
GamesModelgameListModel
GamesProxyModelgameListProxyModel
GameSelectorQuickFilterToolBarquickFilterToolBar
QPushButton * filterButton
QPushButton * clearFilterButton
QPushButton * createButton
QPushButton * joinButton
QPushButton * joinAsJudgeButton
QPushButton * spectateButton
QPushButton * joinAsJudgeSpectatorButton
const bool showFilters
GameTypeMap gameTypeMap

Detailed Description

Provides a widget for displaying, filtering, joining, spectating, and creating games in a room.

The GameSelector displays all available games in a QTreeView. It supports filtering, creating, joining, spectating, and viewing game details. Integrates with TabSupervisor and TabRoom for room and game management.

Constructor & Destructor Documentation

◆ GameSelector()

GameSelector::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.

Parameters
_clientThe network client used to communicate with the server.
_tabSupervisorReference to TabSupervisor for managing tabs and rooms.
_roomPointer to the current room; nullptr if no room is selected.
_roomsMap of room IDs to room names.
_gameTypesMap of room IDs to their available game types.
restoresettingsWhether to restore filter settings from previous sessions.
_showfiltersWhether to display filter buttons.
parentParent QWidget.
Here is the call graph for this function:

Member Function Documentation

◆ actClearFilter

void GameSelector::actClearFilter ( )
privateslot

Clears all filters applied to the game list.

Resets the proxy model to show all games.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actCreate

void GameSelector::actCreate ( )
privateslot

Opens the dialog to create a new game in the current room.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actJoin

void GameSelector::actJoin ( )
privateslot

Joins the currently selected game as a player.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actJoinAsJudge

void GameSelector::actJoinAsJudge ( )
privateslot

Joins the currently selected game as a judge.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actJoinAsJudgeSpectator

void GameSelector::actJoinAsJudgeSpectator ( )
privateslot
Here is the call graph for this function:
Here is the caller graph for this function:

◆ actJoinAsSpectator

void GameSelector::actJoinAsSpectator ( )
privateslot

Joins the currently selected game as a spectator.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actSelectedGameChanged

void GameSelector::actSelectedGameChanged ( const QModelIndex & current,
const QModelIndex & previous )
privateslot

Slot called when the selected game changes.

Parameters
currentThe currently selected index.
previousThe previously selected index.

Updates the enabled/disabled state of buttons depending on the selected game.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ actSetFilter

void GameSelector::actSetFilter ( )
privateslot

Opens a dialog to set filters for the game list.

Updates the proxy model with selected filter parameters and refreshes the displayed game list.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkResponse

void GameSelector::checkResponse ( const Response & response)
privateslot

Processes server responses for join or spectate commands.

Parameters
responseThe response from the server.

Displays error messages for failed join/spectate attempts.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ customContextMenu

void GameSelector::customContextMenu ( const QPoint & point)
privateslot

Shows the custom context menu for a game when right-clicked.

Parameters
pointThe point at which the context menu is requested.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ disableButtons()

void GameSelector::disableButtons ( )
private

Disables create/join/spectate buttons.

Here is the caller graph for this function:

◆ enableButtons()

void GameSelector::enableButtons ( )
private

Enables buttons for the currently selected game.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ enableButtonsForIndex()

void GameSelector::enableButtonsForIndex ( const QModelIndex & current)
private

Enables buttons for a specific game index.

Parameters
currentThe index of the currently selected game.
Here is the caller graph for this function:

◆ gameJoined

void GameSelector::gameJoined ( int gameId)
signal

Emitted when a game has been successfully joined.

Parameters
gameIdThe ID of the joined game.

◆ ignoreListReceived

void GameSelector::ignoreListReceived ( const QList< ServerInfo_User > & _ignoreList)
privateslot

Refreshes the game list when the ignore list is received from the server.

Parameters
_ignoreListThe list of users being ignored.
Here is the caller graph for this function:

◆ joinGame()

void GameSelector::joinGame ( bool asSpectator = false,
bool asJudge = false )
private

Performs the join or spectate action for the currently selected game.

Parameters
asSpectatorTrue to join as a spectator, false to join as a player.
asJudgeTrue to join as a judge, false to join as a player.

Handles password prompts, overrides, and sending the join command to the server.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ processAddToListEvent

void GameSelector::processAddToListEvent ( const Event_AddToList & event)
privateslot

Processes events where a user is added to a list (e.g., ignore or buddy).

Parameters
eventThe event information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ processGameInfo()

void GameSelector::processGameInfo ( const ServerInfo_Game & info)

Updates or adds a game entry in the list.

Parameters
infoThe ServerInfo_Game object containing information about the game to update.
Here is the call graph for this function:

◆ processRemoveFromListEvent

void GameSelector::processRemoveFromListEvent ( const Event_RemoveFromList & event)
privateslot

Processes events where a user is removed from a list (e.g., ignore or buddy).

Parameters
eventThe event information.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ retranslateUi()

void GameSelector::retranslateUi ( )

Updates UI text for translation/localization.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ updateTitle()

void GameSelector::updateTitle ( )
private

Updates the widget title to reflect the current number of displayed games.

Shows the number of visible games versus total games if filters are enabled.

Here is the caller graph for this function:

Member Data Documentation

◆ clearFilterButton

QPushButton* GameSelector::clearFilterButton
private

Button to clear active filters.

◆ client

AbstractClient* GameSelector::client
private

The network client used to communicate with the server.

◆ createButton

QPushButton* GameSelector::createButton
private

Button to create a new game (only if room is set).

◆ filterButton

QPushButton* GameSelector::filterButton
private

Button to open the filter dialog.

◆ gameListModel

GamesModel* GameSelector::gameListModel
private

Model containing all games.

◆ gameListProxyModel

GamesProxyModel* GameSelector::gameListProxyModel
private

Proxy model for filtering and sorting the game list.

◆ gameListView

QTreeView* GameSelector::gameListView
private

View widget for displaying the game list.

◆ gameTypeMap

GameTypeMap GameSelector::gameTypeMap
private

Mapping of game types for the current room.

◆ joinAsJudgeButton

QPushButton* GameSelector::joinAsJudgeButton
private

Button to join the selected game as a judge.

◆ joinAsJudgeSpectatorButton

QPushButton* GameSelector::joinAsJudgeSpectatorButton
private

Button to join the selected game as a spectating judge.

◆ joinButton

QPushButton* GameSelector::joinButton
private

Button to join the selected game.

◆ quickFilterToolBar

GameSelectorQuickFilterToolBar* GameSelector::quickFilterToolBar
private

◆ room

TabRoom* GameSelector::room
private

The current room.

◆ showFilters

const bool GameSelector::showFilters
private

Determines whether filter buttons are displayed.

◆ spectateButton

QPushButton* GameSelector::spectateButton
private

Button to spectate the selected game.

◆ tabSupervisor

TabSupervisor* GameSelector::tabSupervisor
private

Reference to TabSupervisor for managing tabs and rooms.


The documentation for this class was generated from the following files: