[Client] Address tournament UI review feedback

- Drop the in-game tournament-settings button: Command_TournamentSettingsSelect
  has no server handler (RespContextError), the host-ness decision was evaluated
  once at tab construction, and the button never received a label on first show.
  The dialog can be re-added together with a working Server_Player override.
- Pass PlayerManager::isSpectator() to TournamentWidget instead of relying on
  localPlayerId == -1, which never holds for spectators.
- Report games per match as the total series length (Best of %1) to match the
  DlgTournamentSettings hint and the server's use of the value; the previous
  gamesPerMatch * 2 - 1 mislabeled Bo3 as Best of 5.
- Block signals around read-only tournamentCheckBox setChecked so the disabled
  settings button is not re-enabled, and seed Command_CreateGame through
  mutable_tournament_settings() (field 15 became the settings message).
- return after closing a sub-game that routed to its parent tab.
This commit is contained in:
Lukas Brübach 2026-09-02 11:35:23 +02:00
parent 5af51af8e2
commit ef13df2bd2
6 changed files with 21 additions and 55 deletions

View file

@ -1,8 +1,6 @@
#include "tournament_tab_game_extension.h"
#include "../../../game/game_event_handler.h"
#include "../../../game/player/player_logic.h"
#include "../../widgets/dialogs/dlg_tournament_settings.h"
#include "../../widgets/draft/tournament_widget.h"
#include "tab_game.h"
#include "tab_supervisor.h"
@ -12,7 +10,6 @@
#include <QPushButton>
#include <QStackedWidget>
#include <QVBoxLayout>
#include <libcockatrice/protocol/pb/command_tournament.pb.h>
#include <libcockatrice/protocol/pb/event_tournament_state.pb.h>
TournamentTabGameExtension::TournamentTabGameExtension(TabGame *parent) : QObject(parent), tabGame(parent)
@ -29,6 +26,7 @@ TournamentTabGameExtension::TournamentTabGameExtension(TabGame *parent) : QObjec
tournamentWidget = new TournamentWidget(tournamentOverviewWidget);
tournamentWidget->setLocalPlayerId(parent->getGame()->getPlayerManager()->getLocalPlayerId());
tournamentWidget->setIsSpectator(parent->getGame()->getPlayerManager()->isSpectator());
overviewLayout->addWidget(tournamentWidget);
parent->getMainWidget()->addWidget(tournamentOverviewWidget);
@ -44,12 +42,6 @@ TournamentTabGameExtension::TournamentTabGameExtension(TabGame *parent) : QObjec
connectSignals();
}
bool TournamentTabGameExtension::isLocalPlayerHost() const
{
return tabGame->getGame()->getPlayerManager()->getLocalPlayerId() ==
tabGame->getGame()->getGameState()->getHostId();
}
void TournamentTabGameExtension::connectSignals()
{
auto *handler = tabGame->getGame()->getGameEventHandler();
@ -68,11 +60,6 @@ void TournamentTabGameExtension::initializeTournamentMode()
auto *deckLayout = tabGame->getDeckViewContainerLayout();
int index = 0;
deckLayout->insertWidget(index++, deckViewStatusLabel);
if (isLocalPlayerHost()) {
settingsButton = new QPushButton(tabGame->getDeckViewContainerWidget());
connect(settingsButton, &QPushButton::clicked, this, &TournamentTabGameExtension::showTournamentSettingsDialog);
deckLayout->insertWidget(index++, settingsButton);
}
deckLayout->insertWidget(index++, standingsButton);
deckLayout->insertSpacing(index, 4);
}
@ -81,9 +68,6 @@ void TournamentTabGameExtension::retranslateUi()
{
backToGameButton->setText(tr("Back to game view"));
standingsButton->setText(tr("Tournament standings"));
if (settingsButton) {
settingsButton->setText(tr("Tournament Settings"));
}
tournamentWidget->retranslateUi();
}
@ -126,9 +110,6 @@ void TournamentTabGameExtension::updateNavigationButtons(const Event_TournamentS
bool showStandings =
state.phase() == Event_TournamentState::PHASE_PLAYING || state.phase() == Event_TournamentState::PHASE_FINISHED;
standingsButton->setVisible(showStandings);
if (settingsButton) {
settingsButton->setVisible(state.phase() == Event_TournamentState::PHASE_DECK_BUILDING);
}
}
void TournamentTabGameExtension::onTournamentStateChanged(const Event_TournamentState &state)
@ -168,26 +149,6 @@ void TournamentTabGameExtension::showDeckViewPage()
}
}
void TournamentTabGameExtension::showTournamentSettingsDialog()
{
DlgTournamentSettings dlg(tabGame);
if (dlg.exec() != QDialog::Accepted) {
return;
}
DlgTournamentSettingsResult result = dlg.getResult();
PlayerLogic *localPlayer = tabGame->getGame()->getPlayerManager()->getActiveLocalPlayer(-1);
if (!localPlayer) {
TabSupervisor::actShowPopup(tr("You are not an active player in this game."));
return;
}
Command_TournamentSettingsSelect cmd;
cmd.mutable_settings()->set_games_per_match(result.gamesPerMatch);
tabGame->getGame()->getGameEventHandler()->sendGameCommand(cmd, localPlayer->getPlayerInfo()->getId());
}
void TournamentTabGameExtension::openMatchGame(int gameId)
{
if (!tabGame || gameId <= 0) {