QTfrontend/gameuiconfig.cpp
branchui-scaling
changeset 15304 c4fd2813b127
parent 13389 24b531dcebe7
parent 14982 575dbd7b5f43
child 15685 d92eeb468dad
--- a/QTfrontend/gameuiconfig.cpp	Wed May 16 18:22:28 2018 +0200
+++ b/QTfrontend/gameuiconfig.cpp	Wed Jul 31 23:14:27 2019 +0200
@@ -105,15 +105,17 @@
     Form->ui.pageOptions->CBFrontendFullscreen->setChecked(ffscr);
 
     Form->ui.pageOptions->SLQuality->setValue(value("video/quality", 5).toUInt());
+    Form->ui.pageOptions->SLZoom->setValue(value("video/zoom", 100).toUInt());
     Form->ui.pageOptions->CBStereoMode->setCurrentIndex(value("video/stereo", 0).toUInt());
     Form->ui.pageOptions->CBFrontendEffects->setChecked(value("frontend/effects", true).toBool());
     Form->ui.pageOptions->CBSound->setChecked(value("audio/sound", true).toBool());
     Form->ui.pageOptions->CBFrontendSound->setChecked(value("frontend/sound", true).toBool());
     Form->ui.pageOptions->CBMusic->setChecked(value("audio/music", true).toBool());
     Form->ui.pageOptions->CBFrontendMusic->setChecked(value("frontend/music", true).toBool());
+    Form->ui.pageOptions->CBDampenAudio->setChecked(value("audio/dampen", true).toBool());
     Form->ui.pageOptions->SLVolume->setValue(value("audio/volume", 100).toUInt());
 
-    QString netNick = value("net/nick", tr("Guest")+QString("%1").arg(rand())).toString();
+    QString netNick = value("net/nick", getRandomNick()).toString();
     Form->ui.pageOptions->editNetNick->setText(netNick);
     bool savePwd = value("net/savepassword",true).toBool();
     Form->ui.pageOptions->CBSavePassword->setChecked(savePwd);
@@ -241,11 +243,12 @@
 void GameUIConfig::SaveOptions()
 {
     setValue("video/fullscreenResolution", Form->ui.pageOptions->CBResolution->currentText());
-    setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->text());
-    setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->text());
+    setValue("video/windowedWidth", Form->ui.pageOptions->windowWidthEdit->value());
+    setValue("video/windowedHeight", Form->ui.pageOptions->windowHeightEdit->value());
     setValue("video/fullscreen", vid_Fullscreen());
 
     setValue("video/quality", Form->ui.pageOptions->SLQuality->value());
+    setValue("video/zoom", Form->ui.pageOptions->SLZoom->value());
     setValue("video/stereo", stereoMode());
 
     setValue("frontend/effects", isFrontendEffects());
@@ -270,6 +273,7 @@
     setValue("audio/music", isMusicEnabled());
     setValue("frontend/music", isFrontendMusicEnabled());
     setValue("audio/volume", Form->ui.pageOptions->SLVolume->value());
+    setValue("audio/dampen", isAudioDampenEnabled());
 
     setValue("net/nick", netNick());
     if (netPasswordIsValid() && Form->ui.pageOptions->CBSavePassword->isChecked()) {
@@ -365,8 +369,8 @@
         full.setWidth(wh[0].toInt());
         full.setHeight(wh[1].toInt());
     }
-    windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->text().toInt());
-    windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->text().toInt());
+    windowed.setWidth(Form->ui.pageOptions->windowWidthEdit->value());
+    windowed.setHeight(Form->ui.pageOptions->windowHeightEdit->value());
     return std::make_pair(full, windowed);
 }
 
@@ -443,6 +447,26 @@
     return Form->ui.pageOptions->CBFrontendFullscreen->isChecked();
 }
 
+quint16 GameUIConfig::zoom()
+{
+    return Form->ui.pageOptions->SLZoom->value();
+}
+
+bool GameUIConfig::isHolidaySillinessEnabled() const
+{
+    return value("misc/holidaySilliness", true).toBool();
+}
+
+int GameUIConfig::quickGameExperience() const
+{
+    return value("misc/quickGameExperience", 0).toInt();
+}
+
+void GameUIConfig::setQuickGameExperience(int exp)
+{
+    setValue("misc/quickGameExperience", exp);
+}
+
 bool GameUIConfig::isSoundEnabled()
 {
     return Form->ui.pageOptions->CBSound->isChecked();
@@ -460,6 +484,10 @@
 {
     return Form->ui.pageOptions->CBFrontendMusic->isChecked();
 }
+bool GameUIConfig::isAudioDampenEnabled()
+{
+    return Form->ui.pageOptions->CBDampenAudio->isChecked();
+}
 
 bool GameUIConfig::isShowFPSEnabled()
 {
@@ -503,6 +531,16 @@
     Form->ui.pageOptions->editNetNick->setText(value("net/nick", "").toString());
 }
 
+QString GameUIConfig::getRandomNick()
+{
+    // Generate random nick name or pick old one if one was already generated.
+    QString nick;
+    if (cachedRandomNick.isNull())
+        // "Guest" + number between 1 and 99999
+        cachedRandomNick = tr("Guest") + QString("%1").arg(rand() % 99999 + 1);
+    return cachedRandomNick;
+}
+
 QByteArray GameUIConfig::netPasswordHash()
 {
     return QCryptographicHash::hash(Form->ui.pageOptions->editNetPassword->text().toUtf8(), QCryptographicHash::Md5).toHex();