mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-09 01:23:57 -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);
|
startingLifeTotalEdit->setValue(20);
|
||||||
startingLifeTotalLabel->setBuddy(startingLifeTotalEdit);
|
startingLifeTotalLabel->setBuddy(startingLifeTotalEdit);
|
||||||
|
|
||||||
spectatorsSeeEverythingCheckBox = new QCheckBox(tr("Spectators can see &everything"), this);
|
|
||||||
|
|
||||||
auto *gameSetupGrid = new QGridLayout;
|
auto *gameSetupGrid = new QGridLayout;
|
||||||
gameSetupGrid->addWidget(startingLifeTotalLabel, 0, 0);
|
gameSetupGrid->addWidget(startingLifeTotalLabel, 0, 0);
|
||||||
gameSetupGrid->addWidget(startingLifeTotalEdit, 0, 1);
|
gameSetupGrid->addWidget(startingLifeTotalEdit, 0, 1);
|
||||||
gameSetupGrid->addWidget(spectatorsSeeEverythingCheckBox, 1, 0, 1, 2);
|
|
||||||
gameSetupOptionsGroupBox = new QGroupBox(tr("Game setup options"), this);
|
gameSetupOptionsGroupBox = new QGroupBox(tr("Game setup options"), this);
|
||||||
gameSetupOptionsGroupBox->setLayout(gameSetupGrid);
|
gameSetupOptionsGroupBox->setLayout(gameSetupGrid);
|
||||||
|
|
||||||
|
|
@ -58,7 +55,6 @@ DlgLocalGameOptions::DlgLocalGameOptions(QWidget *parent) : QDialog(parent)
|
||||||
if (rememberSettingsCheckBox->isChecked()) {
|
if (rememberSettingsCheckBox->isChecked()) {
|
||||||
numberPlayersEdit->setValue(SettingsCache::instance().getMaxPlayers());
|
numberPlayersEdit->setValue(SettingsCache::instance().getMaxPlayers());
|
||||||
startingLifeTotalEdit->setValue(SettingsCache::instance().getDefaultStartingLifeTotal());
|
startingLifeTotalEdit->setValue(SettingsCache::instance().getDefaultStartingLifeTotal());
|
||||||
spectatorsSeeEverythingCheckBox->setChecked(SettingsCache::instance().getSpectatorsCanSeeEverything());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setWindowTitle(tr("Local game options"));
|
setWindowTitle(tr("Local game options"));
|
||||||
|
|
@ -73,7 +69,6 @@ void DlgLocalGameOptions::actOK()
|
||||||
if (rememberSettingsCheckBox->isChecked()) {
|
if (rememberSettingsCheckBox->isChecked()) {
|
||||||
SettingsCache::instance().setMaxPlayers(numberPlayersEdit->value());
|
SettingsCache::instance().setMaxPlayers(numberPlayersEdit->value());
|
||||||
SettingsCache::instance().setDefaultStartingLifeTotal(startingLifeTotalEdit->value());
|
SettingsCache::instance().setDefaultStartingLifeTotal(startingLifeTotalEdit->value());
|
||||||
SettingsCache::instance().setSpectatorsCanSeeEverything(spectatorsSeeEverythingCheckBox->isChecked());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
accept();
|
accept();
|
||||||
|
|
@ -84,6 +79,5 @@ LocalGameOptions DlgLocalGameOptions::getOptions() const
|
||||||
return LocalGameOptions{
|
return LocalGameOptions{
|
||||||
.numberPlayers = numberPlayersEdit->value(),
|
.numberPlayers = numberPlayersEdit->value(),
|
||||||
.startingLifeTotal = startingLifeTotalEdit->value(),
|
.startingLifeTotal = startingLifeTotalEdit->value(),
|
||||||
.spectatorsSeeEverything = spectatorsSeeEverythingCheckBox->isChecked(),
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,16 +4,20 @@
|
||||||
* @brief Dialog for configuring local game options.
|
* @brief Dialog for configuring local game options.
|
||||||
*
|
*
|
||||||
* Provides a user interface for setting up local games with configurable
|
* 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
|
#ifndef DLG_LOCAL_GAME_OPTIONS_H
|
||||||
#define DLG_LOCAL_GAME_OPTIONS_H
|
#define DLG_LOCAL_GAME_OPTIONS_H
|
||||||
|
|
||||||
#include "../../../game/local_game_options.h"
|
|
||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
struct LocalGameOptions
|
||||||
|
{
|
||||||
|
int numberPlayers = 1;
|
||||||
|
int startingLifeTotal = 20;
|
||||||
|
};
|
||||||
|
|
||||||
class QCheckBox;
|
class QCheckBox;
|
||||||
class QDialogButtonBox;
|
class QDialogButtonBox;
|
||||||
class QGroupBox;
|
class QGroupBox;
|
||||||
|
|
@ -41,7 +45,6 @@ private:
|
||||||
QLabel *startingLifeTotalLabel;
|
QLabel *startingLifeTotalLabel;
|
||||||
QSpinBox *startingLifeTotalEdit;
|
QSpinBox *startingLifeTotalEdit;
|
||||||
|
|
||||||
QCheckBox *spectatorsSeeEverythingCheckBox;
|
|
||||||
QCheckBox *rememberSettingsCheckBox;
|
QCheckBox *rememberSettingsCheckBox;
|
||||||
|
|
||||||
QDialogButtonBox *buttonBox;
|
QDialogButtonBox *buttonBox;
|
||||||
|
|
|
||||||
|
|
@ -258,7 +258,6 @@ void MainWindow::startLocalGame(const LocalGameOptions &options)
|
||||||
Command_CreateGame createCommand;
|
Command_CreateGame createCommand;
|
||||||
createCommand.set_max_players(static_cast<google::protobuf::uint32>(options.numberPlayers));
|
createCommand.set_max_players(static_cast<google::protobuf::uint32>(options.numberPlayers));
|
||||||
createCommand.set_starting_life_total(options.startingLifeTotal);
|
createCommand.set_starting_life_total(options.startingLifeTotal);
|
||||||
createCommand.set_spectators_see_everything(options.spectatorsSeeEverything);
|
|
||||||
mainClient->sendCommand(LocalClient::prepareRoomCommand(createCommand, 0));
|
mainClient->sendCommand(LocalClient::prepareRoomCommand(createCommand, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
#ifndef WINDOW_H
|
#ifndef WINDOW_H
|
||||||
#define WINDOW_H
|
#define WINDOW_H
|
||||||
|
|
||||||
#include "../game/local_game_options.h"
|
#include "widgets/dialogs/dlg_local_game_options.h"
|
||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue