From 9176927d53db6f32663953a8cf491503d0e20dc6 Mon Sep 17 00:00:00 2001 From: "M. H. Golkar" <1233337+mhgolkar@users.noreply.github.com> Date: Fri, 1 Mar 2024 14:36:07 +0330 Subject: [PATCH] Fix preferences being unexpectedly reset by view function Solves #62 where `history_size` was reset to 0 affecting undo/redo. --- scripts/core/configuration_handler.gd | 2 +- scripts/core/main_ui_management.gd | 2 +- scripts/editor/panels/preferences_panel.gd | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/core/configuration_handler.gd b/scripts/core/configuration_handler.gd index 7151572..76c16fa 100644 --- a/scripts/core/configuration_handler.gd +++ b/scripts/core/configuration_handler.gd @@ -88,10 +88,10 @@ class ConfigHandler : func _on_preference_modifications_done(confirmed_by_user:bool) -> void: print_debug("Preference Modification ", ("Confirmed." if confirmed_by_user else "Dismissed!")) - Main.UI.set_panel_visibility("preferences", false) if confirmed_by_user: # warning-ignore:return_value_discarded save_configurations_and_confirm(TEMPORARY, null, false) + Main.UI.set_panel_visibility("preferences", false) # saved as config file or not, confirmation has happened, so there are actions to be taken anyway: # update/reset the view (& theme) changes Main.UI.update_view_from_configuration(CONFIRMED) diff --git a/scripts/core/main_ui_management.gd b/scripts/core/main_ui_management.gd index b6aabe3..d8f00fd 100644 --- a/scripts/core/main_ui_management.gd +++ b/scripts/core/main_ui_management.gd @@ -203,7 +203,7 @@ class UiManager : # updates view partially or fully depending on the `configuration` func update_view_from_configuration(configuration:Dictionary) -> void: - print_debug("View updated:", configuration) + # print_debug("View updated:", configuration) for config in configuration: var cfg = configuration[config] match config: diff --git a/scripts/editor/panels/preferences_panel.gd b/scripts/editor/panels/preferences_panel.gd index 5076355..14abf03 100644 --- a/scripts/editor/panels/preferences_panel.gd +++ b/scripts/editor/panels/preferences_panel.gd @@ -65,6 +65,7 @@ func register_connections() -> void: FIELDS.app_local_dir_browse.connect("pressed", self, "prompt_local_dir_path", [], CONNECT_DEFERRED) FIELDS.app_local_dir_reset_menu.connect("item_selected_value", self, "_on_app_local_dir_reset_menu_item_selected", [], CONNECT_DEFERRED) FIELDS.history_size.get_line_edit().connect("text_changed", self, "preprocess_and_emit_modification_signal", ["history_size"], CONNECT_DEFERRED) + FIELDS.history_size.connect("value_changed", self, "preprocess_and_emit_modification_signal", ["history_size"], CONNECT_DEFERRED) pass func refresh_fields_view(preferences:Dictionary) -> void: @@ -89,8 +90,6 @@ func preprocess_and_emit_modification_signal(value, field) -> void: "language": value = FIELDS.language.get_item_id(value) # Convert idx to lang_id "history_size": - # NOTE: wee need this because spinners signal `value_changed` even on changes by code, - # so we use the `text_changed` of their inner LineEdit: value = max(0, int(value)) # .. then signal self.emit_signal("preference_modified", field, value)