From fafd8e77eded997320f04ba7f83443448069b77d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20Br=C3=BCbach?= Date: Sun, 16 Nov 2025 12:00:07 +0100 Subject: [PATCH] Spectate as judge. Took 8 minutes --- .../widgets/server/game_selector.cpp | 27 ++++++++++++++++--- .../interface/widgets/server/game_selector.h | 16 ++++++----- 2 files changed, 33 insertions(+), 10 deletions(-) diff --git a/cockatrice/src/interface/widgets/server/game_selector.cpp b/cockatrice/src/interface/widgets/server/game_selector.cpp index 077027e0d..8ee6943c8 100644 --- a/cockatrice/src/interface/widgets/server/game_selector.cpp +++ b/cockatrice/src/interface/widgets/server/game_selector.cpp @@ -96,6 +96,7 @@ GameSelector::GameSelector(AbstractClient *_client, joinButton = new QPushButton; joinAsJudgeButton = new QPushButton; spectateButton = new QPushButton; + joinAsJudgeSpectatorButton = new QPushButton; QHBoxLayout *buttonLayout = new QHBoxLayout; if (showFilters) { @@ -112,6 +113,11 @@ GameSelector::GameSelector(AbstractClient *_client, joinAsJudgeButton->setHidden(true); } buttonLayout->addWidget(spectateButton); + if (tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsJudge) { + buttonLayout->addWidget(joinAsJudgeSpectatorButton); + } else { + joinAsJudgeSpectatorButton->setHidden(true); + } buttonLayout->setAlignment(Qt::AlignTop); QVBoxLayout *mainLayout = new QVBoxLayout; @@ -127,7 +133,8 @@ GameSelector::GameSelector(AbstractClient *_client, connect(joinButton, &QPushButton::clicked, this, &GameSelector::actJoin); connect(joinAsJudgeButton, &QPushButton::clicked, this, &GameSelector::actJoinAsJudge); - connect(spectateButton, &QPushButton::clicked, this, &GameSelector::actSpectate); + connect(spectateButton, &QPushButton::clicked, this, &GameSelector::actJoinAsSpectator); + connect(joinAsJudgeSpectatorButton, &QPushButton::clicked, this, &GameSelector::actJoinAsJudgeSpectator); connect(gameListView->selectionModel(), &QItemSelectionModel::currentRowChanged, this, &GameSelector::actSelectedGameChanged); connect(gameListView, &QTreeView::activated, this, &GameSelector::actJoin); @@ -259,11 +266,19 @@ void GameSelector::actJoinAsJudge() return joinGame(false, true); } -void GameSelector::actSpectate() +void GameSelector::actJoinAsSpectator() { return joinGame(true); } +void GameSelector::actJoinAsJudgeSpectator() +{ + if (!(tabSupervisor->getUserInfo()->user_level() & ServerInfo_User::IsJudge)) { + return joinGame(true); + } + return joinGame(true, true); +} + void GameSelector::customContextMenu(const QPoint &point) { const auto &index = gameListView->indexAt(point); @@ -275,7 +290,7 @@ void GameSelector::customContextMenu(const QPoint &point) connect(&joinGame, &QAction::triggered, this, &GameSelector::actJoin); QAction spectateGame(tr("Spectate Game")); - connect(&spectateGame, &QAction::triggered, this, &GameSelector::actSpectate); + connect(&spectateGame, &QAction::triggered, this, &GameSelector::actJoinAsSpectator); QAction getGameInfo(tr("Game Information")); connect(&getGameInfo, &QAction::triggered, this, [=, this]() { @@ -294,6 +309,11 @@ void GameSelector::customContextMenu(const QPoint &point) connect(&joinGameAsJudge, &QAction::triggered, this, &GameSelector::actJoinAsJudge); menu.addAction(&joinGameAsJudge); + + QAction spectateGameAsJudge(tr("Spectate Game as Judge")); + connect(&spectateGameAsJudge, &QAction::triggered, this, &GameSelector::actJoinAsJudgeSpectator); + + menu.addAction(&spectateGameAsJudge); } menu.addAction(&spectateGame); @@ -384,6 +404,7 @@ void GameSelector::retranslateUi() joinButton->setText(tr("&Join")); joinAsJudgeButton->setText(tr("Join as judge")); spectateButton->setText(tr("J&oin as spectator")); + joinAsJudgeSpectatorButton->setText(tr("Join as judge spectator")); updateTitle(); } diff --git a/cockatrice/src/interface/widgets/server/game_selector.h b/cockatrice/src/interface/widgets/server/game_selector.h index 4a6be58b5..ea0a4feb0 100644 --- a/cockatrice/src/interface/widgets/server/game_selector.h +++ b/cockatrice/src/interface/widgets/server/game_selector.h @@ -65,7 +65,8 @@ private slots: /** * @brief Joins the currently selected game as a spectator. */ - void actSpectate(); + void actJoinAsSpectator(); + void actJoinAsJudgeSpectator(); /** * @brief Shows the custom context menu for a game when right-clicked. @@ -126,12 +127,13 @@ private: GameSelectorQuickFilterToolBar *quickFilterToolBar; - QPushButton *filterButton; /**< Button to open the filter dialog. */ - QPushButton *clearFilterButton; /**< Button to clear active filters. */ - QPushButton *createButton; /**< Button to create a new game (only if room is set). */ - QPushButton *joinButton; /**< Button to join the selected game. */ - QPushButton *joinAsJudgeButton; /**< Button to join the selected game as a judge. */ - QPushButton *spectateButton; /**< Button to spectate the selected game. */ + QPushButton *filterButton; /**< Button to open the filter dialog. */ + QPushButton *clearFilterButton; /**< Button to clear active filters. */ + QPushButton *createButton; /**< Button to create a new game (only if room is set). */ + QPushButton *joinButton; /**< Button to join the selected game. */ + QPushButton *joinAsJudgeButton; /**< Button to join the selected game as a judge. */ + QPushButton *spectateButton; /**< Button to spectate the selected game. */ + QPushButton *joinAsJudgeSpectatorButton; /**< Button to join the selected game as a spectating judge. */ const bool showFilters; /**< Determines whether filter buttons are displayed. */ GameTypeMap gameTypeMap; /**< Mapping of game types for the current room. */