Kaynağa Gözat

Components checkboxes functionalty impl

Ivan Arkhipov 5 yıl önce
ebeveyn
işleme
4ee5da6cd5

+ 28 - 0
src/Legacy/models/settings.cpp

@@ -31,6 +31,7 @@ QMap<QString, QVariant> defaults = {
     {"DatabaseDownload/texture", false},       // GraphicsPatch
     {"DatabaseDownload/sound", false},         // SoundsPatch
     {"DatabaseDownload/video", false},         // VideosPatch
+    {"DatabaseDownload/micro", false},         // MicroPatch
 
     // Flags, meaning that database is fresh and needs to be installed
 
@@ -41,6 +42,7 @@ QMap<QString, QVariant> defaults = {
     {"DatabaseUpdated/texture", false},        // GraphicsPatch
     {"DatabaseUpdated/sound", false},          // SoundsPatch
     {"DatabaseUpdated/video", false},          // VideosPatch
+    {"DatabaseUpdated/micro", false},          // MircoPatch
 
     // Localisation components
     {"Components/texts_main", false},          // TextsPatch
@@ -108,7 +110,33 @@ void restoreFromSettingsBackup(const SettingsBackup& backup) {
 }
 
 void updatePatchComponentsDependencies() {
+    QSettings settings;
+
+    auto isComponentActive = [&settings](const QString& component) -> bool {
+        return settings.value("Components/" + component).toBool();
+    };
+
+    if (isComponentActive("texts_main") || isComponentActive("texts_items")
+            || isComponentActive("texts_emotes") || isComponentActive("videos")) {
+        // Videos also need text database, because it contains videos path references
+        settings.setValue("DatabaseDownload/text", true);
+    } else {
+        settings.setValue("DatabaseDownload/text", false);
+    }
+
+    if (isComponentActive("texts_main") || isComponentActive("texts_items")
+            || isComponentActive("texts_emotes")) {
+        settings.setValue("DatabaseDownload/font", true);
+    } else {
+        settings.setValue("DatabaseDownload/font", false);
+    }
 
+    settings.setValue("DatabaseDownload/image", isComponentActive("maps"));
+    settings.setValue("DatabaseDownload/loadscreen", isComponentActive("loadscreens"));
+    settings.setValue("DatabaseDownload/texture", isComponentActive("textures"));
+    settings.setValue("DatabaseDownload/sound", isComponentActive("sounds"));
+    settings.setValue("DatabaseDownload/video", isComponentActive("videos"));
+    settings.setValue("DatabaseDownload/micro", isComponentActive("micropatch"));
 }
 
 }  /* namespace Settings */

+ 94 - 4
src/Legacy/widgets/settingswidget.cpp

@@ -330,17 +330,105 @@ void SettingsWidget::on_patch_texts_checkbox_stateChanged(int arg1)
     processParameterChange();
     if (arg1 == Qt::Checked) {
         Settings::setValue("Components/texts_main", true);
-        Settings::updatePatchComponentsDependencies();
     } else {
         Settings::setValue("Components/texts_main", false);
-        Settings::updatePatchComponentsDependencies();
     }
     checkIfParametersWereReset();
 }
 
 
+void SettingsWidget::on_patch_items_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/texts_items", true);
+    } else {
+        Settings::setValue("Components/texts_items", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_emotes_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/texts_emotes", true);
+    } else {
+        Settings::setValue("Components/texts_emotes", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_maps_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/maps", true);
+    } else {
+        Settings::setValue("Components/maps", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_textures_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/textures", true);
+    } else {
+        Settings::setValue("Components/textures", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_loadscreens_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/loadscreens", true);
+    } else {
+        Settings::setValue("Components/loadscreens", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_sounds_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/sounds", true);
+    } else {
+        Settings::setValue("Components/sounds", false);
+    }
+    checkIfParametersWereReset();
+}
+
+void SettingsWidget::on_patch_video_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/videos", true);
+    } else {
+        Settings::setValue("Components/videos", false);
+    }
+    checkIfParametersWereReset();
+}
 
+void SettingsWidget::on_patch_force_apply_button_clicked()
+{
+ // TODO(endevir): Implement
+}
 
+void SettingsWidget::on_micropatch_checkbox_stateChanged(int arg1)
+{
+    processParameterChange();
+    if (arg1 == Qt::Checked) {
+        Settings::setValue("Components/micropatch", true);
+    } else {
+        Settings::setValue("Components/micropatch", false);
+    }
+    checkIfParametersWereReset();
+}
 
 void SettingsWidget::on_interface_scale_combobox_currentIndexChanged(const QString &arg1)
 {
@@ -406,5 +494,7 @@ void SettingsWidget::onPatchTotalOperationsFinished()
     ui->micropatch_checkbox->setEnabled(true);
 }
 
-
-
+void SettingsWidget::on_apply_changes_button_clicked()
+{
+    Settings::updatePatchComponentsDependencies();
+}

+ 20 - 0
src/Legacy/widgets/settingswidget.h

@@ -148,6 +148,26 @@ private slots:
 
     void on_patch_texts_checkbox_stateChanged(int arg1);
 
+    void on_patch_items_checkbox_stateChanged(int arg1);
+
+    void on_patch_emotes_checkbox_stateChanged(int arg1);
+
+    void on_patch_maps_checkbox_stateChanged(int arg1);
+
+    void on_patch_textures_checkbox_stateChanged(int arg1);
+
+    void on_patch_loadscreens_checkbox_stateChanged(int arg1);
+
+    void on_patch_sounds_checkbox_stateChanged(int arg1);
+
+    void on_patch_video_checkbox_stateChanged(int arg1);
+
+    void on_patch_force_apply_button_clicked();
+
+    void on_micropatch_checkbox_stateChanged(int arg1);
+
+    void on_apply_changes_button_clicked();
+
 private:
     bool patch_operations_running_;