Sfoglia il codice sorgente

Added more settings to Launcher that previously have no UI access

Ivan Savenko 1 anno fa
parent
commit
ae27b65435

+ 114 - 18
launcher/settingsView/csettingsview_moc.cpp

@@ -17,7 +17,6 @@
 #include "../helper.h"
 #include "../helper.h"
 #include "../jsonutils.h"
 #include "../jsonutils.h"
 #include "../languages.h"
 #include "../languages.h"
-#include "../launcherdirs.h"
 
 
 #include <QFileInfo>
 #include <QFileInfo>
 #include <QGuiApplication>
 #include <QGuiApplication>
@@ -35,12 +34,19 @@ QString resolutionToString(const QSize & resolution)
 	return QString{"%1x%2"}.arg(resolution.width()).arg(resolution.height());
 	return QString{"%1x%2"}.arg(resolution.width()).arg(resolution.height());
 }
 }
 
 
-static const std::string cursorTypesList[] =
+static constexpr std::array cursorTypesList =
 {
 {
 	"hardware",
 	"hardware",
 	"software"
 	"software"
 };
 };
 
 
+static constexpr std::array upscalingFilterTypes =
+{
+	"nearest",
+	"linear",
+	"best"
+};
+
 }
 }
 
 
 void CSettingsView::setDisplayList()
 void CSettingsView::setDisplayList()
@@ -72,9 +78,13 @@ void CSettingsView::loadSettings()
 #ifdef VCMI_MOBILE
 #ifdef VCMI_MOBILE
 	ui->comboBoxFullScreen->hide();
 	ui->comboBoxFullScreen->hide();
 	ui->labelFullScreen->hide();
 	ui->labelFullScreen->hide();
+	ui->labelCursorTypeDesktop->hide();
+	ui->comboBoxCursorTypeDesktop->hide();
 #else
 #else
 	ui->labelReservedArea->hide();
 	ui->labelReservedArea->hide();
-	ui->spinBoxReservedArea->hide();
+	ui->sliderReservedArea->hide();
+	ui->labelCursorTypeMobile->hide();
+	ui->comboBoxCursorTypeMobile->hide();
 	if (settings["video"]["realFullscreen"].Bool())
 	if (settings["video"]["realFullscreen"].Bool())
 		ui->comboBoxFullScreen->setCurrentIndex(2);
 		ui->comboBoxFullScreen->setCurrentIndex(2);
 	else
 	else
@@ -85,8 +95,8 @@ void CSettingsView::loadSettings()
 	ui->spinBoxInterfaceScaling->setValue(settings["video"]["resolution"]["scaling"].Float());
 	ui->spinBoxInterfaceScaling->setValue(settings["video"]["resolution"]["scaling"].Float());
 	ui->spinBoxFramerateLimit->setValue(settings["video"]["targetfps"].Float());
 	ui->spinBoxFramerateLimit->setValue(settings["video"]["targetfps"].Float());
 	ui->spinBoxFramerateLimit->setDisabled(settings["video"]["vsync"].Bool());
 	ui->spinBoxFramerateLimit->setDisabled(settings["video"]["vsync"].Bool());
-	ui->checkBoxVSync->setChecked(settings["video"]["vsync"].Bool());
-	ui->spinBoxReservedArea->setValue(std::round(settings["video"]["reservedWidth"].Float() * 100));
+	ui->comboBoxVSync->setCurrentIndex(settings["video"]["vsync"].Bool());
+	ui->sliderReservedArea->setValue(std::round(settings["video"]["reservedWidth"].Float() * 100));
 
 
 	ui->comboBoxFriendlyAI->setCurrentText(QString::fromStdString(settings["server"]["friendlyAI"].String()));
 	ui->comboBoxFriendlyAI->setCurrentText(QString::fromStdString(settings["server"]["friendlyAI"].String()));
 	ui->comboBoxNeutralAI->setCurrentText(QString::fromStdString(settings["server"]["neutralAI"].String()));
 	ui->comboBoxNeutralAI->setCurrentText(QString::fromStdString(settings["server"]["neutralAI"].String()));
@@ -123,8 +133,25 @@ void CSettingsView::loadSettings()
 	fillValidRenderers();
 	fillValidRenderers();
 
 
 	std::string cursorType = settings["video"]["cursor"].String();
 	std::string cursorType = settings["video"]["cursor"].String();
-	size_t cursorTypeIndex = boost::range::find(cursorTypesList, cursorType) - cursorTypesList;
-	ui->comboBoxCursorType->setCurrentIndex((int)cursorTypeIndex);
+	int cursorTypeIndex = vstd::find_pos(cursorTypesList, cursorType);
+	ui->comboBoxCursorTypeDesktop->setCurrentIndex(cursorTypeIndex);
+	ui->comboBoxCursorTypeMobile->setCurrentIndex(cursorTypeIndex);
+
+	std::string upscalingFilter = settings["video"]["scalingMode"].String();
+	int upscalingFilterIndex = vstd::find_pos(upscalingFilterTypes, upscalingFilter);
+	ui->comboBoxUpscalingFilter->setCurrentIndex(upscalingFilterIndex);
+
+	ui->sliderMusicVolume->setValue(settings["general"]["music"].Integer());
+	ui->sliderSoundVolume->setValue(settings["general"]["sound"].Integer());
+	ui->comboBoxRelativeCursorMode->setCurrentIndex(settings["general"]["userRelativePointer"].Bool());
+	ui->sliderRelativeCursorSpeed->setValue(settings["general"]["relativePointerSpeedMultiplier"].Integer());
+	ui->comboBoxHapticFeedback->setCurrentIndex(settings["launcher"]["hapticFeedback"].Bool());
+	ui->sliderLongTouchDuration->setValue(settings["general"]["longTouchTimeMilliseconds"].Integer());
+	ui->slideToleranceDistanceMouse->setValue(settings["input"]["mouseToleranceDistance"].Integer());
+	ui->sliderToleranceDistanceTouch->setValue(settings["input"]["touchToleranceDistance"].Integer());
+	ui->sliderToleranceDistanceController->setValue(settings["input"]["shortcutToleranceDistance"].Integer());
+	ui->lineEditGameLobbyHost->setText(QString::fromStdString(settings["lobby"]["hostname"].String()));
+	ui->spinBoxNetworkPortLobby->setValue(settings["lobby"]["port"].Integer());
 }
 }
 
 
 void CSettingsView::fillValidResolutions()
 void CSettingsView::fillValidResolutions()
@@ -395,16 +422,20 @@ void CSettingsView::showEvent(QShowEvent * event)
 	QWidget::showEvent(event);
 	QWidget::showEvent(event);
 }
 }
 
 
-void CSettingsView::on_comboBoxCursorType_currentIndexChanged(int index)
+void CSettingsView::on_comboBoxCursorTypeDesktop_currentIndexChanged(int index)
 {
 {
 	Settings node = settings.write["video"]["cursor"];
 	Settings node = settings.write["video"]["cursor"];
 	node->String() = cursorTypesList[index];
 	node->String() = cursorTypesList[index];
 }
 }
 
 
-void CSettingsView::loadTranslation()
+void CSettingsView::on_comboBoxCursorTypeMobile_currentIndexChanged(int index)
 {
 {
-	Languages::fillLanguages(ui->comboBoxLanguageBase, true);
+	Settings node = settings.write["video"]["cursor"];
+	node->String() = cursorTypesList[index];
+}
 
 
+void CSettingsView::loadTranslation()
+{
 	QString baseLanguage = Languages::getHeroesDataLanguage();
 	QString baseLanguage = Languages::getHeroesDataLanguage();
 
 
 	auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
 	auto * mainWindow = dynamic_cast<MainWindow *>(qApp->activeWindow());
@@ -474,13 +505,6 @@ void CSettingsView::on_pushButtonTranslation_clicked()
 	}
 	}
 }
 }
 
 
-void CSettingsView::on_comboBoxLanguageBase_currentIndexChanged(int index)
-{
-	Settings node = settings.write["general"]["gameDataLanguage"];
-	QString selectedLanguage = ui->comboBoxLanguageBase->itemData(index).toString();
-	node->String() = selectedLanguage.toStdString();
-}
-
 void CSettingsView::on_checkBoxRepositoryDefault_stateChanged(int arg1)
 void CSettingsView::on_checkBoxRepositoryDefault_stateChanged(int arg1)
 {
 {
 	Settings node = settings.write["launcher"]["defaultRepositoryEnabled"];
 	Settings node = settings.write["launcher"]["defaultRepositoryEnabled"];
@@ -556,7 +580,7 @@ void CSettingsView::on_spinBoxAutoSaveLimit_valueChanged(int arg1)
 	node->Float() = arg1;
 	node->Float() = arg1;
 }
 }
 
 
-void CSettingsView::on_lineEditAutoSavePrefix_textEdited(const QString &arg1)
+void CSettingsView::on_lineEditAutoSavePrefix_textEdited(const QString & arg1)
 {
 {
 	Settings node = settings.write["general"]["savePrefix"];
 	Settings node = settings.write["general"]["savePrefix"];
 	node->String() = arg1.toStdString();
 	node->String() = arg1.toStdString();
@@ -579,3 +603,75 @@ void CSettingsView::on_checkBoxIgnoreSslErrors_clicked(bool checked)
 	Settings node = settings.write["launcher"]["ignoreSslErrors"];
 	Settings node = settings.write["launcher"]["ignoreSslErrors"];
 	node->Bool() = checked;
 	node->Bool() = checked;
 }
 }
+
+void CSettingsView::on_comboBoxUpscalingFilter_currentIndexChanged(int index)
+{
+	Settings node = settings.write["video"]["scalingMode"];
+	node->String() = upscalingFilterTypes[index];
+}
+
+void CSettingsView::on_sliderMusicVolume_valueChanged(int value)
+{
+	Settings node = settings.write["general"]["music"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_sliderSoundVolume_valueChanged(int value)
+{
+	Settings node = settings.write["general"]["sound"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_comboBoxRelativeCursorMode_currentIndexChanged(int index)
+{
+	Settings node = settings.write["general"]["userRelativePointer"];
+	node->Bool() = index;
+}
+
+void CSettingsView::on_sliderRelativeCursorSpeed_valueChanged(int value)
+{
+	Settings node = settings.write["general"]["relativePointerSpeedMultiplier"];
+	node->Float() = value / 100.0;
+}
+
+void CSettingsView::on_comboBoxHapticFeedback_currentIndexChanged(int index)
+{
+	Settings node = settings.write["general"]["hapticFeedback"];
+	node->Bool() = index;
+}
+
+void CSettingsView::on_sliderLongTouchDuration_valueChanged(int value)
+{
+	Settings node = settings.write["general"]["longTouchTimeMilliseconds"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_slideToleranceDistanceMouse_valueChanged(int value)
+{
+	Settings node = settings.write["input"]["mouseToleranceDistance"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_sliderToleranceDistanceTouch_valueChanged(int value)
+{
+	Settings node = settings.write["input"]["touchToleranceDistance"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_sliderToleranceDistanceController_valueChanged(int value)
+{
+	Settings node = settings.write["input"]["shortcutToleranceDistance"];
+	node->Integer() = value;
+}
+
+void CSettingsView::on_lineEditGameLobbyHost_textChanged(const QString & arg1)
+{
+	Settings node = settings.write["lobby"]["hostname"];
+	node->String() = arg1.toStdString();
+}
+
+void CSettingsView::on_spinBoxNetworkPortLobby_valueChanged(int arg1)
+{
+	Settings node = settings.write["lobby"]["port"];
+	node->Integer() = arg1;
+}

+ 14 - 17
launcher/settingsView/csettingsview_moc.h

@@ -43,40 +43,37 @@ private slots:
 	void on_comboBoxDisplayIndex_currentIndexChanged(int index);
 	void on_comboBoxDisplayIndex_currentIndexChanged(int index);
 	void on_comboBoxAutoSave_currentIndexChanged(int index);
 	void on_comboBoxAutoSave_currentIndexChanged(int index);
 	void on_comboBoxLanguage_currentIndexChanged(int index);
 	void on_comboBoxLanguage_currentIndexChanged(int index);
-	void on_comboBoxCursorType_currentIndexChanged(int index);
+	void on_comboBoxCursorTypeMobile_currentIndexChanged(int index);
+	void on_comboBoxCursorTypeDesktop_currentIndexChanged(int index);
 	void on_pushButtonTranslation_clicked();
 	void on_pushButtonTranslation_clicked();
-
-	void on_comboBoxLanguageBase_currentIndexChanged(int index);
-
 	void on_checkBoxRepositoryDefault_stateChanged(int arg1);
 	void on_checkBoxRepositoryDefault_stateChanged(int arg1);
-
 	void on_checkBoxRepositoryExtra_stateChanged(int arg1);
 	void on_checkBoxRepositoryExtra_stateChanged(int arg1);
-
 	void on_lineEditRepositoryExtra_textEdited(const QString &arg1);
 	void on_lineEditRepositoryExtra_textEdited(const QString &arg1);
-
 	void on_spinBoxInterfaceScaling_valueChanged(int arg1);
 	void on_spinBoxInterfaceScaling_valueChanged(int arg1);
-
 	void on_refreshRepositoriesButton_clicked();
 	void on_refreshRepositoriesButton_clicked();
-
 	void on_spinBoxFramerateLimit_valueChanged(int arg1);
 	void on_spinBoxFramerateLimit_valueChanged(int arg1);
-
 	void on_checkBoxVSync_stateChanged(int arg1);
 	void on_checkBoxVSync_stateChanged(int arg1);
-
 	void on_comboBoxEnemyPlayerAI_currentTextChanged(const QString &arg1);
 	void on_comboBoxEnemyPlayerAI_currentTextChanged(const QString &arg1);
-
 	void on_comboBoxAlliedPlayerAI_currentTextChanged(const QString &arg1);
 	void on_comboBoxAlliedPlayerAI_currentTextChanged(const QString &arg1);
-
 	void on_checkBoxAutoSavePrefix_stateChanged(int arg1);
 	void on_checkBoxAutoSavePrefix_stateChanged(int arg1);
-
 	void on_spinBoxAutoSaveLimit_valueChanged(int arg1);
 	void on_spinBoxAutoSaveLimit_valueChanged(int arg1);
-
 	void on_lineEditAutoSavePrefix_textEdited(const QString &arg1);
 	void on_lineEditAutoSavePrefix_textEdited(const QString &arg1);
-
 	void on_spinBoxReservedArea_valueChanged(int arg1);
 	void on_spinBoxReservedArea_valueChanged(int arg1);
-
 	void on_comboBoxRendererType_currentTextChanged(const QString &arg1);
 	void on_comboBoxRendererType_currentTextChanged(const QString &arg1);
 
 
 	void on_checkBoxIgnoreSslErrors_clicked(bool checked);
 	void on_checkBoxIgnoreSslErrors_clicked(bool checked);
+	void on_comboBoxUpscalingFilter_currentIndexChanged(int index);
+	void on_sliderMusicVolume_valueChanged(int value);
+	void on_sliderSoundVolume_valueChanged(int value);
+	void on_comboBoxRelativeCursorMode_currentIndexChanged(int index);
+	void on_sliderRelativeCursorSpeed_valueChanged(int value);
+	void on_comboBoxHapticFeedback_currentIndexChanged(int index);
+	void on_sliderLongTouchDuration_valueChanged(int value);
+	void on_slideToleranceDistanceMouse_valueChanged(int value);
+	void on_sliderToleranceDistanceTouch_valueChanged(int value);
+	void on_sliderToleranceDistanceController_valueChanged(int value);
+	void on_lineEditGameLobbyHost_textChanged(const QString &arg1);
+	void on_spinBoxNetworkPortLobby_valueChanged(int arg1);
 
 
 private:
 private:
 	Ui::CSettingsView * ui;
 	Ui::CSettingsView * ui;

File diff suppressed because it is too large
+ 601 - 188
launcher/settingsView/csettingsview_moc.ui


Some files were not shown because too many files changed in this diff