mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-07-28 11:50:25 -07:00
* [Settings] Split cache_settings into multiple files Took 9 minutes Took 4 minutes * [Settings] Fwd declare settings classes in cache_settings Took 15 minutes * Fix oracle includes. Took 8 minutes * Address comments, fix windows CI Took 8 minutes * fix copy constructor visibility Took 3 minutes * lint Took 2 minutes * Fix native format tests. Took 5 minutes * Remove test header guard Took 4 seconds * Remove tests invalid in CI environ Took 24 seconds * Adjust to rebase. Took 11 minutes * Change settings file name. Took 8 minutes --------- Co-authored-by: Lukas Brübach <lukas.bruebach@bdosecurity.de> Co-authored-by: Lukas Brübach <Bruebach.Lukas@bdosecurity.de>
86 lines
3.3 KiB
C++
86 lines
3.3 KiB
C++
#include "dlg_local_game_options.h"
|
|
|
|
#include "../../../client/settings/cache_settings.h"
|
|
|
|
#include <QCheckBox>
|
|
#include <QDialogButtonBox>
|
|
#include <QGridLayout>
|
|
#include <QGroupBox>
|
|
#include <QLabel>
|
|
#include <QSpinBox>
|
|
#include <QVBoxLayout>
|
|
#include <libcockatrice/settings/game_settings.h>
|
|
|
|
DlgLocalGameOptions::DlgLocalGameOptions(QWidget *parent) : QDialog(parent)
|
|
{
|
|
numberPlayersLabel = new QLabel(tr("Players:"), this);
|
|
numberPlayersEdit = new QSpinBox(this);
|
|
numberPlayersEdit->setMinimum(1);
|
|
numberPlayersEdit->setMaximum(8);
|
|
numberPlayersEdit->setValue(1);
|
|
numberPlayersLabel->setBuddy(numberPlayersEdit);
|
|
|
|
auto *generalGrid = new QGridLayout;
|
|
generalGrid->setContentsMargins(5, 5, 5, 5);
|
|
generalGrid->addWidget(numberPlayersLabel, 0, 0);
|
|
generalGrid->addWidget(numberPlayersEdit, 0, 1);
|
|
generalGroupBox = new QGroupBox(tr("General"), this);
|
|
generalGroupBox->setLayout(generalGrid);
|
|
|
|
startingLifeTotalLabel = new QLabel(tr("Starting life total:"), this);
|
|
startingLifeTotalEdit = new QSpinBox(this);
|
|
startingLifeTotalEdit->setMinimum(-999999999);
|
|
startingLifeTotalEdit->setMaximum(999999999);
|
|
startingLifeTotalEdit->setValue(20);
|
|
startingLifeTotalLabel->setBuddy(startingLifeTotalEdit);
|
|
|
|
auto *gameSetupGrid = new QGridLayout;
|
|
gameSetupGrid->setContentsMargins(5, 5, 5, 5);
|
|
gameSetupGrid->addWidget(startingLifeTotalLabel, 0, 0);
|
|
gameSetupGrid->addWidget(startingLifeTotalEdit, 0, 1);
|
|
gameSetupOptionsGroupBox = new QGroupBox(tr("Game setup options"), this);
|
|
gameSetupOptionsGroupBox->setLayout(gameSetupGrid);
|
|
|
|
rememberSettingsCheckBox = new QCheckBox(tr("Remember settings"), this);
|
|
|
|
buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
|
connect(buttonBox, &QDialogButtonBox::accepted, this, &DlgLocalGameOptions::actOK);
|
|
connect(buttonBox, &QDialogButtonBox::rejected, this, &DlgLocalGameOptions::reject);
|
|
|
|
auto *mainLayout = new QVBoxLayout;
|
|
mainLayout->addWidget(generalGroupBox);
|
|
mainLayout->addWidget(gameSetupOptionsGroupBox);
|
|
mainLayout->addWidget(rememberSettingsCheckBox);
|
|
mainLayout->addWidget(buttonBox);
|
|
setLayout(mainLayout);
|
|
|
|
rememberSettingsCheckBox->setChecked(SettingsCache::instance().game().getLocalGameRememberSettings());
|
|
if (rememberSettingsCheckBox->isChecked()) {
|
|
numberPlayersEdit->setValue(SettingsCache::instance().game().getLocalGameMaxPlayers());
|
|
startingLifeTotalEdit->setValue(SettingsCache::instance().game().getLocalGameStartingLifeTotal());
|
|
}
|
|
|
|
setWindowTitle(tr("Local game options"));
|
|
setFixedHeight(sizeHint().height());
|
|
|
|
numberPlayersEdit->setFocus();
|
|
}
|
|
|
|
void DlgLocalGameOptions::actOK()
|
|
{
|
|
SettingsCache::instance().game().setLocalGameRememberSettings(rememberSettingsCheckBox->isChecked());
|
|
if (rememberSettingsCheckBox->isChecked()) {
|
|
SettingsCache::instance().game().setLocalGameMaxPlayers(numberPlayersEdit->value());
|
|
SettingsCache::instance().game().setLocalGameStartingLifeTotal(startingLifeTotalEdit->value());
|
|
}
|
|
|
|
accept();
|
|
}
|
|
|
|
LocalGameOptions DlgLocalGameOptions::getOptions() const
|
|
{
|
|
return LocalGameOptions{
|
|
.numberPlayers = numberPlayersEdit->value(),
|
|
.startingLifeTotal = startingLifeTotalEdit->value(),
|
|
};
|
|
}
|