diff --git a/game/addons/world_generator/ui/RectEditor.gd b/game/addons/world_generator/ui/RectEditor.gd index d86112e3..302eeac2 100644 --- a/game/addons/world_generator/ui/RectEditor.gd +++ b/game/addons/world_generator/ui/RectEditor.gd @@ -1,6 +1,8 @@ tool extends PanelContainer +var last_edited_res : WorldGenBaseResource = null + func _init(): # Control/EditorZoomWidget pass @@ -9,4 +11,15 @@ func set_plugin(plugin : EditorPlugin) -> void: $ScrollContainer/MarginContainer/RectView.set_plugin(plugin) func set_edited_resource(res : WorldGenBaseResource): + if res && res != last_edited_res: + var r : Rect2 = res.get_rect() + + if r.size.x > 0: + var rsx : float = $ScrollContainer/MarginContainer.rect_size.x + var scale : float = rsx / r.size.x + + $Control/EditorZoomWidget.zoom = scale + + + $ScrollContainer/MarginContainer/RectView.set_edited_resource(res) diff --git a/game/addons/world_generator/ui/RectEditor.tscn b/game/addons/world_generator/ui/RectEditor.tscn index ae622a30..9ff7bccf 100644 --- a/game/addons/world_generator/ui/RectEditor.tscn +++ b/game/addons/world_generator/ui/RectEditor.tscn @@ -8,9 +8,6 @@ anchor_right = 1.0 anchor_bottom = 1.0 script = ExtResource( 1 ) -__meta__ = { -"_edit_use_anchors_": false -} [node name="ScrollContainer" type="ScrollContainer" parent="."] margin_left = 7.0 @@ -49,6 +46,3 @@ anchor_bottom = 0.0 margin_right = 115.0 margin_bottom = 22.0 custom_constants/separation = -8 -__meta__ = { -"_edit_use_anchors_": false -}