mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-20 21:07:17 +01:00
Now the world editor tries to center rects of the newly opened resources better.
This commit is contained in:
parent
b101213d84
commit
06e025633e
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user