Cockatrice/cockatrice/src/interface/widgets/tabs/tournament_tab_game_extension.h
Lukas Brübach 55099ab82c
[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.
2026-09-06 16:15:47 +02:00

54 lines
1.6 KiB
C++

#ifndef TOURNAMENT_TAB_GAME_EXTENSION_H
#define TOURNAMENT_TAB_GAME_EXTENSION_H
#include <QObject>
#include <QPointer>
#include <libcockatrice/protocol/pb/event_tournament_state.pb.h>
class QLabel;
class QPushButton;
class QWidget;
class TournamentWidget;
class TabGame;
/**
* @class TournamentTabGameExtension
* @ingroup GameViews
* @brief Attaches tournament behavior to a TabGame hosting a tournament hub game.
*
* Owns the tournament overview page inside the tab's stacked main widget,
* mirrors tournament state onto the always-visible deck-view status strip,
* and routes user intents (open match game, change settings, switch pages)
* between the two views.
*/
class TournamentTabGameExtension : public QObject
{
Q_OBJECT
public:
explicit TournamentTabGameExtension(TabGame *parent);
void initializeTournamentMode();
void retranslateUi();
private slots:
void onTournamentStateChanged(const Event_TournamentState &state);
void showOverviewPage();
void showDeckViewPage();
void openMatchGame(int gameId);
private:
void connectSignals();
void updateDeckViewStrip(const Event_TournamentState &state);
void updateNavigationButtons(const Event_TournamentState &state);
QPointer<TabGame> tabGame;
TournamentWidget *tournamentWidget = nullptr;
QWidget *tournamentOverviewWidget = nullptr;
QPushButton *backToGameButton = nullptr;
QPushButton *standingsButton = nullptr;
QLabel *deckViewStatusLabel = nullptr;
Event_TournamentState::TournamentPhase lastKnownPhase = Event_TournamentState::PHASE_DECK_BUILDING;
bool hasLastKnownPhase = false;
};
#endif // TOURNAMENT_TAB_GAME_EXTENSION_H