Skip to content

Commit

Permalink
change update_setting from signal to method, call when ui is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Eggbertx authored and Ark2000 committed Aug 12, 2023
1 parent 5fd27fc commit 53bfb39
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 19 deletions.
16 changes: 5 additions & 11 deletions addons/panku_console/common/module_options.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
4 changes: 2 additions & 2 deletions addons/panku_console/common/panku_module.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -75,4 +75,4 @@ func _init_module():

init_module()
if _opt:
_opt.loaded = true
_opt._loaded = true
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
6 changes: 1 addition & 5 deletions addons/panku_console/modules/native_logger/module.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
3 changes: 3 additions & 0 deletions addons/panku_console/modules/native_logger/opt.gd
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 53bfb39

Please sign in to comment.