mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-07 05:53:59 -07:00
removed spectator option and moved structure definition
This commit is contained in:
parent
ae42593968
commit
81a7a768c5
5 changed files with 8 additions and 33 deletions
|
|
@ -1,21 +0,0 @@
|
|||
/**
|
||||
* @file local_game_options.h
|
||||
* @ingroup Game
|
||||
* @brief Configuration options for local games.
|
||||
*
|
||||
* This struct encapsulates all settings that can be configured when starting
|
||||
* a local game, providing a clean interface that prevents parameter explosion
|
||||
* as more options are added in the future.
|
||||
*/
|
||||
|
||||
#ifndef LOCAL_GAME_OPTIONS_H
|
||||
#define LOCAL_GAME_OPTIONS_H
|
||||
|
||||
struct LocalGameOptions
|
||||
{
|
||||
int numberPlayers = 1;
|
||||
int startingLifeTotal = 20;
|
||||
bool spectatorsSeeEverything = false;
|
||||
};
|
||||
|
||||
#endif // LOCAL_GAME_OPTIONS_H
|
||||
|
|
@ -32,12 +32,9 @@ DlgLocalGameOptions::DlgLocalGameOptions(QWidget *parent) : QDialog(parent)
|
|||
startingLifeTotalEdit->setValue(20);
|
||||
startingLifeTotalLabel->setBuddy(startingLifeTotalEdit);
|
||||
|
||||
spectatorsSeeEverythingCheckBox = new QCheckBox(tr("Spectators can see &everything"), this);
|
||||
|
||||
auto *gameSetupGrid = new QGridLayout;
|
||||
gameSetupGrid->addWidget(startingLifeTotalLabel, 0, 0);
|
||||
gameSetupGrid->addWidget(startingLifeTotalEdit, 0, 1);
|
||||
gameSetupGrid->addWidget(spectatorsSeeEverythingCheckBox, 1, 0, 1, 2);
|
||||
gameSetupOptionsGroupBox = new QGroupBox(tr("Game setup options"), this);
|
||||
gameSetupOptionsGroupBox->setLayout(gameSetupGrid);
|
||||
|
||||
|
|
@ -58,7 +55,6 @@ DlgLocalGameOptions::DlgLocalGameOptions(QWidget *parent) : QDialog(parent)
|
|||
if (rememberSettingsCheckBox->isChecked()) {
|
||||
numberPlayersEdit->setValue(SettingsCache::instance().getMaxPlayers());
|
||||
startingLifeTotalEdit->setValue(SettingsCache::instance().getDefaultStartingLifeTotal());
|
||||
spectatorsSeeEverythingCheckBox->setChecked(SettingsCache::instance().getSpectatorsCanSeeEverything());
|
||||
}
|
||||
|
||||
setWindowTitle(tr("Local game options"));
|
||||
|
|
@ -73,7 +69,6 @@ void DlgLocalGameOptions::actOK()
|
|||
if (rememberSettingsCheckBox->isChecked()) {
|
||||
SettingsCache::instance().setMaxPlayers(numberPlayersEdit->value());
|
||||
SettingsCache::instance().setDefaultStartingLifeTotal(startingLifeTotalEdit->value());
|
||||
SettingsCache::instance().setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
|
||||
}
|
||||
|
||||
accept();
|
||||
|
|
@ -84,6 +79,5 @@ LocalGameOptions DlgLocalGameOptions::getOptions() const
|
|||
return LocalGameOptions{
|
||||
.numberPlayers = numberPlayersEdit->value(),
|
||||
.startingLifeTotal = startingLifeTotalEdit->value(),
|
||||
.spectatorsSeeEverything = spectatorsSeeEverythingCheckBox->isChecked(),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,16 +4,20 @@
|
|||
* @brief Dialog for configuring local game options.
|
||||
*
|
||||
* Provides a user interface for setting up local games with configurable
|
||||
* number of players, starting life total, and spectator visibility options.
|
||||
* number of players and starting life total.
|
||||
*/
|
||||
|
||||
#ifndef DLG_LOCAL_GAME_OPTIONS_H
|
||||
#define DLG_LOCAL_GAME_OPTIONS_H
|
||||
|
||||
#include "../../../game/local_game_options.h"
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
struct LocalGameOptions
|
||||
{
|
||||
int numberPlayers = 1;
|
||||
int startingLifeTotal = 20;
|
||||
};
|
||||
|
||||
class QCheckBox;
|
||||
class QDialogButtonBox;
|
||||
class QGroupBox;
|
||||
|
|
@ -41,7 +45,6 @@ private:
|
|||
QLabel *startingLifeTotalLabel;
|
||||
QSpinBox *startingLifeTotalEdit;
|
||||
|
||||
QCheckBox *spectatorsSeeEverythingCheckBox;
|
||||
QCheckBox *rememberSettingsCheckBox;
|
||||
|
||||
QDialogButtonBox *buttonBox;
|
||||
|
|
|
|||
|
|
@ -258,7 +258,6 @@ void MainWindow::startLocalGame(const LocalGameOptions &options)
|
|||
Command_CreateGame createCommand;
|
||||
createCommand.set_max_players(static_cast<google::protobuf::uint32>(options.numberPlayers));
|
||||
createCommand.set_starting_life_total(options.startingLifeTotal);
|
||||
createCommand.set_spectators_see_everything(options.spectatorsSeeEverything);
|
||||
mainClient->sendCommand(LocalClient::prepareRoomCommand(createCommand, 0));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
#ifndef WINDOW_H
|
||||
#define WINDOW_H
|
||||
|
||||
#include "../game/local_game_options.h"
|
||||
#include "widgets/dialogs/dlg_local_game_options.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue