From 53bfb397891f799e031d16ff16eba599bdf05e57 Mon Sep 17 00:00:00 2001 From: Eggbertx Date: Thu, 3 Aug 2023 21:52:41 -0700 Subject: [PATCH] change update_setting from signal to method, call when ui is changed --- addons/panku_console/common/module_options.gd | 16 +++++----------- addons/panku_console/common/panku_module.gd | 4 ++-- .../data_controller/exporter/exporter_2.gd | 5 ++++- .../modules/native_logger/module.gd | 6 +----- .../panku_console/modules/native_logger/opt.gd | 3 +++ 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/addons/panku_console/common/module_options.gd b/addons/panku_console/common/module_options.gd index 26797c0..72500fe 100644 --- a/addons/panku_console/common/module_options.gd +++ b/addons/panku_console/common/module_options.gd @@ -2,15 +2,9 @@ class_name ModuleOptions extends Resource var _module:PankuModule -signal update_setting(key: String, value: Variant) - -var loaded := false: - set(l): - if l: - update_setting.connect(_module.save_module_data) - else: - if update_setting.is_connected(_module.save_module_data): - update_setting.disconnect(_module.save_module_data) - get: - return update_setting.is_connected(_module.save_module_data) +var _loaded := false +func update_setting(key: String, value: Variant): + self.set(key, value) + if _loaded and _module: + _module.save_module_data(key, value) diff --git a/addons/panku_console/common/panku_module.gd b/addons/panku_console/common/panku_module.gd index 0caef7a..32ea11f 100644 --- a/addons/panku_console/common/panku_module.gd +++ b/addons/panku_console/common/panku_module.gd @@ -16,7 +16,7 @@ func init_module(): # called when the module is unloaded (quit program) func quit_module(): if _opt: - _opt.loaded = false + _opt._loaded = false # called at the start of each physics frame func update_module(delta:float): @@ -75,4 +75,4 @@ func _init_module(): init_module() if _opt: - _opt.loaded = true + _opt._loaded = true diff --git a/addons/panku_console/modules/data_controller/exporter/exporter_2.gd b/addons/panku_console/modules/data_controller/exporter/exporter_2.gd index d48a900..395ec13 100644 --- a/addons/panku_console/modules/data_controller/exporter/exporter_2.gd +++ b/addons/panku_console/modules/data_controller/exporter/exporter_2.gd @@ -132,7 +132,10 @@ func init_data(): if !is_instance_valid(obj): return if prop_name in obj: - obj.set(prop_name, val) + if obj.has_method("update_setting"): + obj.update_setting(prop_name, val) + else: + obj.set(prop_name, val) ) func init_ui_row(ui_row:Control, property:Dictionary) -> Control: diff --git a/addons/panku_console/modules/native_logger/module.gd b/addons/panku_console/modules/native_logger/module.gd index 0fab83b..39182ea 100644 --- a/addons/panku_console/modules/native_logger/module.gd +++ b/addons/panku_console/modules/native_logger/module.gd @@ -53,13 +53,9 @@ func init_module(): func quit_module(): + super.quit_module() save_window_data(window) - save_module_data("font_size", get_module_opt().font_size) - save_module_data("screen_overlay", get_module_opt().screen_overlay) - save_module_data("screen_overlay_alpha", get_module_opt().screen_overlay_alpha) - save_module_data("screen_overlay_font_size", get_module_opt().screen_overlay_font_size) save_module_data("screen_overlay_font_shadow", get_module_opt().screen_overlay_font_shadow) - save_module_data("font_size", get_module_opt().font_size) save_module_data("logger_tags", logger_ui.get_data()) func open_window(): diff --git a/addons/panku_console/modules/native_logger/opt.gd b/addons/panku_console/modules/native_logger/opt.gd index a051698..8d2c7a6 100644 --- a/addons/panku_console/modules/native_logger/opt.gd +++ b/addons/panku_console/modules/native_logger/opt.gd @@ -21,16 +21,19 @@ func open_window(): _module.output_overlay.visible = v get: return _module.output_overlay.visible + @export_range(0.0, 1.0, 0.01) var screen_overlay_alpha:float = 0.5: set(v): _module.output_overlay.modulate.a = v get: return _module.output_overlay.modulate.a + @export_range(8, 24) var screen_overlay_font_size:int = 16: set(v): _module.output_overlay.theme.default_font_size = v get: return _module.output_overlay.theme.default_font_size + @export var screen_overlay_font_shadow:bool = false: set(v): var val = Color.BLACK if v else null