Set a usable initial zoom value in world generator's rect editors.

This commit is contained in:
Relintai 2022-08-05 00:56:01 +02:00
parent ac7a4212a3
commit d53a157657
2 changed files with 13 additions and 6 deletions

View File

@ -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)

View File

@ -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
}