mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-04-27 07:48:01 -07:00
Add local game options (#6669)
* Add local game options dialog. Introduces LocalGameOptions struct and DlgLocalGameOptions dialog to replace the previous QInputDialog for starting local games. Encapsulates game configuration with a simple interface that prevents parameter explosion as options are added. The dialog provides UI with settings persistence via SettingsCache * integrate local game options into main window. Replaces QInputDialog with DlgLocalGameOptions in actSinglePlayer(). The startLocalGame() function now accepts LocalGameOptions, enabling configuration of starting life total and spectator visibility in addition to player count. Also adds user documentation for the local game options flow. * Removed superfluous documentation file * removed spectator option and moved structure definition * Now remember settings separately and & shortcuts removed * re-run checks
This commit is contained in:
parent
20ad9af989
commit
aa4592dc9e
8 changed files with 199 additions and 12 deletions
|
|
@ -27,6 +27,7 @@
|
|||
#include "../interface/widgets/dialogs/dlg_forgot_password_challenge.h"
|
||||
#include "../interface/widgets/dialogs/dlg_forgot_password_request.h"
|
||||
#include "../interface/widgets/dialogs/dlg_forgot_password_reset.h"
|
||||
#include "../interface/widgets/dialogs/dlg_local_game_options.h"
|
||||
#include "../interface/widgets/dialogs/dlg_manage_sets.h"
|
||||
#include "../interface/widgets/dialogs/dlg_register.h"
|
||||
#include "../interface/widgets/dialogs/dlg_settings.h"
|
||||
|
|
@ -49,7 +50,6 @@
|
|||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QMenuBar>
|
||||
#include <QMessageBox>
|
||||
|
|
@ -225,16 +225,15 @@ void MainWindow::actDisconnect()
|
|||
|
||||
void MainWindow::actSinglePlayer()
|
||||
{
|
||||
bool ok;
|
||||
int numberPlayers =
|
||||
QInputDialog::getInt(this, tr("Number of players"), tr("Please enter the number of players."), 1, 1, 8, 1, &ok);
|
||||
if (!ok)
|
||||
DlgLocalGameOptions dlg(this);
|
||||
if (dlg.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
|
||||
startLocalGame(numberPlayers);
|
||||
startLocalGame(dlg.getOptions());
|
||||
}
|
||||
|
||||
void MainWindow::startLocalGame(int numberPlayers)
|
||||
void MainWindow::startLocalGame(const LocalGameOptions &options)
|
||||
{
|
||||
aConnect->setEnabled(false);
|
||||
aRegister->setEnabled(false);
|
||||
|
|
@ -248,7 +247,7 @@ void MainWindow::startLocalGame(int numberPlayers)
|
|||
QList<AbstractClient *> localClients;
|
||||
localClients.append(mainClient);
|
||||
|
||||
for (int i = 0; i < numberPlayers - 1; ++i) {
|
||||
for (int i = 0; i < options.numberPlayers - 1; ++i) {
|
||||
LocalServerInterface *slaveLsi = localServer->newConnection();
|
||||
LocalClient *slaveClient =
|
||||
new LocalClient(slaveLsi, tr("Player %1").arg(i + 2), SettingsCache::instance().getClientID(), this);
|
||||
|
|
@ -257,7 +256,8 @@ void MainWindow::startLocalGame(int numberPlayers)
|
|||
tabSupervisor->startLocal(localClients);
|
||||
|
||||
Command_CreateGame createCommand;
|
||||
createCommand.set_max_players(static_cast<google::protobuf::uint32>(numberPlayers));
|
||||
createCommand.set_max_players(static_cast<google::protobuf::uint32>(options.numberPlayers));
|
||||
createCommand.set_starting_life_total(options.startingLifeTotal);
|
||||
mainClient->sendCommand(LocalClient::prepareRoomCommand(createCommand, 0));
|
||||
}
|
||||
|
||||
|
|
@ -913,7 +913,9 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
void MainWindow::startupConfigCheck()
|
||||
{
|
||||
if (SettingsCache::instance().debug().getLocalGameOnStartup()) {
|
||||
startLocalGame(SettingsCache::instance().debug().getLocalGamePlayerCount());
|
||||
LocalGameOptions options;
|
||||
options.numberPlayers = SettingsCache::instance().debug().getLocalGamePlayerCount();
|
||||
startLocalGame(options);
|
||||
}
|
||||
|
||||
if (SettingsCache::instance().getCheckUpdatesOnStartup()) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue