From 06e025633e8213626fa4c5831e196753d2f58c49 Mon Sep 17 00:00:00 2001 From: Relintai Date: Fri, 5 Aug 2022 21:13:37 +0200 Subject: [PATCH] Now the world editor tries to center rects of the newly opened resources better. --- game/addons/world_generator/ui/RectEditor.gd | 24 +++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/game/addons/world_generator/ui/RectEditor.gd b/game/addons/world_generator/ui/RectEditor.gd index 302eeac2..2eb11664 100644 --- a/game/addons/world_generator/ui/RectEditor.gd +++ b/game/addons/world_generator/ui/RectEditor.gd @@ -3,23 +3,25 @@ extends PanelContainer var last_edited_res : WorldGenBaseResource = null -func _init(): -# Control/EditorZoomWidget - pass - func set_plugin(plugin : EditorPlugin) -> void: - $ScrollContainer/MarginContainer/RectView.set_plugin(plugin) + get_node("ScrollContainer/MarginContainer/RectView").set_plugin(plugin) func set_edited_resource(res : WorldGenBaseResource): + get_node("ScrollContainer/MarginContainer/RectView").set_edited_resource(res) + if res && res != last_edited_res: var r : Rect2 = res.get_rect() + last_edited_res = res if r.size.x > 0: - var rsx : float = $ScrollContainer/MarginContainer.rect_size.x - var scale : float = rsx / r.size.x + var rsx : float = get_node("ScrollContainer").rect_size.x + var scale : float = rsx / r.size.x * 0.8 - $Control/EditorZoomWidget.zoom = scale - - + get_node("Control/EditorZoomWidget").zoom = scale + get_node("ScrollContainer/MarginContainer/RectView").apply_zoom() - $ScrollContainer/MarginContainer/RectView.set_edited_resource(res) + var sb : ScrollBar = get_node("ScrollContainer").get_h_scrollbar() + sb.ratio = 1 + + sb = get_node("ScrollContainer").get_v_scrollbar() + sb.ratio = 1