From 284cfa3c2f4430c3b9fefc958f3f951b44bea236 Mon Sep 17 00:00:00 2001 From: CrispyPin Date: Thu, 22 Jul 2021 15:40:39 +0200 Subject: [PATCH] properly load slider values in menu --- ovr-utils/overlay_settings_sync.gd | 3 +++ ovr-utils/ui/ListOverlayItem.tscn | 8 +++++--- ovr-utils/ui/overlay_list_item.gd | 13 ++++++++++--- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/ovr-utils/overlay_settings_sync.gd b/ovr-utils/overlay_settings_sync.gd index 8e714ff..7f7342d 100644 --- a/ovr-utils/overlay_settings_sync.gd +++ b/ovr-utils/overlay_settings_sync.gd @@ -1,5 +1,7 @@ extends Node +signal loaded_settings + onready var p = get_parent() var loaded := false var _needs_sync := true @@ -66,6 +68,7 @@ func load_all() -> void: print("FAILED to load settings") save_all() loaded = true + emit_signal("loaded_settings") func _on_SyncTimer_timeout() -> void: diff --git a/ovr-utils/ui/ListOverlayItem.tscn b/ovr-utils/ui/ListOverlayItem.tscn index df5d6c5..84d1a81 100644 --- a/ovr-utils/ui/ListOverlayItem.tscn +++ b/ovr-utils/ui/ListOverlayItem.tscn @@ -158,7 +158,7 @@ icon = ExtResource( 4 ) anchor_top = -0.016 anchor_right = 1.0 anchor_bottom = -0.016 -margin_top = -455.944 +margin_top = -905.944 margin_bottom = -6.944 __meta__ = { "_edit_use_anchors_": false @@ -168,11 +168,12 @@ __meta__ = { margin_left = 8.0 margin_top = 8.0 margin_right = 168.0 -margin_bottom = 441.0 +margin_bottom = 891.0 min_value = 0.1 max_value = 1.0 step = 0.05 value = 0.4 +scrollable = false __meta__ = { "_edit_use_anchors_": false } @@ -203,8 +204,9 @@ margin_bottom = 441.0 focus_mode = 0 min_value = 0.3 max_value = 1.0 -step = 0.05 +step = 0.1 value = 1.0 +scrollable = false __meta__ = { "_edit_use_anchors_": false } diff --git a/ovr-utils/ui/overlay_list_item.gd b/ovr-utils/ui/overlay_list_item.gd index 26222d7..4da9acb 100644 --- a/ovr-utils/ui/overlay_list_item.gd +++ b/ovr-utils/ui/overlay_list_item.gd @@ -5,17 +5,24 @@ var overlay func _ready() -> void: overlay = OverlayManager.get_node(overlay_name) + overlay.get_node("OverlaySettingsSync").connect("loaded_settings", self, "_apply_loaded") $MoreOptions/Container/List/SetSize/PanelContainer.visible = false $MoreOptions/Container/List/SetAlpha/PanelContainer.visible = false - $MoreOptions/Container/List/SetSize/PanelContainer/SizeSlider.value = overlay.width_meters $MoreOptions.visible = false $BasicOptions/Label.text = overlay_name name = overlay_name +# overlay.connect("overlay_visible_changed", self, "_overlay_visible_changed") +# overlay.connect("path_changed", self, "_update_warning") + + +func _apply_loaded(): + $MoreOptions/Container/List/SetSize/PanelContainer/SizeSlider.value = overlay.width_meters $MoreOptions/Container/List/Target.selected = overlay.TARGETS.find(overlay.target) - overlay.connect("overlay_visible_changed", self, "_overlay_visible_changed") - overlay.connect("path_changed", self, "_update_warning") + $MoreOptions/Container/List/SetAlpha/PanelContainer/AlphaSlider.value = overlay.alpha + _overlay_visible_changed(overlay.overlay_visible) + _update_warning() func _update_warning():