Spectate as judge.

Took 8 minutes
This commit is contained in:
Lukas Brübach 2025-11-16 12:00:07 +01:00
parent 2e5f212db7
commit fafd8e77ed
2 changed files with 33 additions and 10 deletions

View file

@ -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();
}

View file

@ -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. */