mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-07 05:53:59 -07:00
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.
This commit is contained in:
parent
789642aee3
commit
a83005994b
4 changed files with 59 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,9 @@ 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);
|
||||
createCommand.set_spectators_see_everything(options.spectatorsSeeEverything);
|
||||
mainClient->sendCommand(LocalClient::prepareRoomCommand(createCommand, 0));
|
||||
}
|
||||
|
||||
|
|
@ -913,7 +914,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()) {
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#ifndef WINDOW_H
|
||||
#define WINDOW_H
|
||||
|
||||
#include "../game/local_game_options.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QMainWindow>
|
||||
#include <QMessageBox>
|
||||
|
|
@ -137,7 +139,7 @@ private:
|
|||
void createCardUpdateProcess(bool background = false);
|
||||
void exitCardDatabaseUpdate();
|
||||
|
||||
void startLocalGame(int numberPlayers);
|
||||
void startLocalGame(const LocalGameOptions &options);
|
||||
|
||||
QList<QMenu *> tabMenus;
|
||||
QMenu *cockatriceMenu, *dbMenu, *tabsMenu, *helpMenu, *trayIconMenu;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
@page user_reference User Reference
|
||||
|
||||
|
||||
## Local Games
|
||||
|
||||
- @subpage starting_local_game
|
||||
|
||||
## Deck Management
|
||||
|
||||
- @subpage creating_decks
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
@page starting_local_game Starting a Local Game
|
||||
|
||||
## Overview
|
||||
|
||||
Local games allow you to play Cockatrice offline without connecting to a server. This is useful for testing decks, playing against yourself, or practicing game mechanics.
|
||||
|
||||
## Starting a Local Game
|
||||
|
||||
1. From the main menu, select **Cockatrice** > **Start local game** (or use the keyboard shortcut)
|
||||
2. The **Local game options** dialog will appear
|
||||
|
||||
## Configuration Options
|
||||
|
||||
### Number of Players
|
||||
|
||||
Set the number of players in the game (1-8). Each player will be assigned a name like "Player 1", "Player 2", etc.
|
||||
|
||||
### Starting Life Total
|
||||
|
||||
Set the starting life total for all players. The default is 20, which is standard for most Magic: The Gathering formats. You can set this to any value from 1 to 99999 to accommodate different formats:
|
||||
- **20** - Standard, Modern, Legacy, Vintage, Limited
|
||||
- **40** - Commander/EDH
|
||||
- **30** - Two-Headed Giant (per team)
|
||||
|
||||
### Spectators Can See Everything
|
||||
|
||||
When enabled, spectators can see all hidden information (hands, face-down cards, etc.). This is useful when streaming or recording gameplay where viewers should see the full game state.
|
||||
|
||||
### Remember Settings
|
||||
|
||||
When checked, your current settings will be saved and automatically loaded the next time you start a local game. This saves time if you frequently use the same configuration.
|
||||
|
||||
## After Starting
|
||||
|
||||
Once you click **OK**, the game will start and you can:
|
||||
- Load a deck for each player
|
||||
- Play the game as you would in a multiplayer match
|
||||
- Switch between players using the player tabs
|
||||
Loading…
Add table
Add a link
Reference in a new issue