From f5a7f5173f41038988f28e62664fade33e74dc69 Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Thu, 19 Jan 2023 18:14:10 +0200 Subject: [PATCH] Cursor type is now configurable in Launcher --- config/schemas/settings.json | 9 +++---- launcher/settingsView/csettingsview_moc.cpp | 20 ++++++++++++++++ launcher/settingsView/csettingsview_moc.h | 2 ++ launcher/settingsView/csettingsview_moc.ui | 26 +++++++++++++++++++++ 4 files changed, 53 insertions(+), 4 deletions(-) diff --git a/config/schemas/settings.json b/config/schemas/settings.json index bbe6133dc..d3472c3ab 100644 --- a/config/schemas/settings.json +++ b/config/schemas/settings.json @@ -82,7 +82,7 @@ "type" : "object", "additionalProperties" : false, "default": {}, - "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "realFullscreen", "softwareCursor", "spellbookAnimation", "driver", "showIntro", "displayIndex" ], + "required" : [ "screenRes", "bitsPerPixel", "fullscreen", "realFullscreen", "cursor", "spellbookAnimation", "driver", "showIntro", "displayIndex" ], "properties" : { "screenRes" : { "type" : "object", @@ -106,9 +106,10 @@ "type" : "boolean", "default" : false }, - "softwareCursor" : { - "type" : "boolean", - "default" : false + "cursor" : { + "type" : "string", + "enum" : [ "auto", "hardware", "software" ], + "default" : "auto" }, "showIntro" : { "type" : "boolean", diff --git a/launcher/settingsView/csettingsview_moc.cpp b/launcher/settingsView/csettingsview_moc.cpp index 43dc7e2a5..902992081 100644 --- a/launcher/settingsView/csettingsview_moc.cpp +++ b/launcher/settingsView/csettingsview_moc.cpp @@ -58,6 +58,13 @@ static const std::string languageTagList[] = "ukrainian", }; +static const std::string cursorTypesList[] = +{ + "auto", + "hardware", + "software" +}; + void CSettingsView::setDisplayList() { QStringList list; @@ -89,6 +96,8 @@ void CSettingsView::loadSettings() ui->comboBoxFullScreen->setDisabled(true); #else ui->comboBoxFullScreen->setCurrentIndex(settings["video"]["fullscreen"].Bool()); + if (settings["video"]["realFullscreen"].Bool()) + ui->comboBoxFullScreen->setCurrentIndex(2); #endif ui->comboBoxFriendlyAI->setCurrentText(QString::fromStdString(settings["server"]["friendlyAI"].String())); @@ -120,6 +129,10 @@ void CSettingsView::loadSettings() size_t languageIndex = boost::range::find(languageTagList, language) - languageTagList; if(languageIndex < ui->comboBoxLanguage->count()) ui->comboBoxLanguage->setCurrentIndex((int)languageIndex); + + std::string cursorType = settings["video"]["cursor"].String(); + size_t cursorTypeIndex = boost::range::find(cursorTypesList, cursorType) - cursorTypesList; + ui->comboBoxCursorType->setCurrentIndex((int)cursorTypeIndex); } void CSettingsView::fillValidResolutions(bool isExtraResolutionsModEnabled) @@ -339,3 +352,10 @@ void CSettingsView::changeEvent(QEvent *event) } QWidget::changeEvent(event); } + +void CSettingsView::on_comboBoxCursorType_currentIndexChanged(int index) +{ + Settings node = settings.write["video"]["cursor"]; + node->String() = cursorTypesList[index]; +} + diff --git a/launcher/settingsView/csettingsview_moc.h b/launcher/settingsView/csettingsview_moc.h index 1d54b3ffa..987143924 100644 --- a/launcher/settingsView/csettingsview_moc.h +++ b/launcher/settingsView/csettingsview_moc.h @@ -71,6 +71,8 @@ private slots: void on_comboBoxLanguage_currentIndexChanged(int index); + void on_comboBoxCursorType_currentIndexChanged(int index); + private: Ui::CSettingsView * ui; diff --git a/launcher/settingsView/csettingsview_moc.ui b/launcher/settingsView/csettingsview_moc.ui index 232526a26..73c7226f8 100644 --- a/launcher/settingsView/csettingsview_moc.ui +++ b/launcher/settingsView/csettingsview_moc.ui @@ -638,6 +638,32 @@ + + + + Cursor + + + + + + + + Default + + + + + Hardware + + + + + Software + + + +