mirror of
https://github.com/Relintai/broken_seals.git
synced 2024-11-13 20:47:19 +01:00
Initial cleanups and setup for the uv editor.
This commit is contained in:
parent
1629224aeb
commit
34b6877afc
@ -4,19 +4,28 @@ extends Control
|
||||
var plugin : EditorPlugin
|
||||
|
||||
export var uv_preview_path : NodePath
|
||||
export var uv_editor_path : NodePath
|
||||
|
||||
var uv_preview : Node
|
||||
var uv_editor : Node
|
||||
|
||||
func _enter_tree():
|
||||
uv_preview = get_node(uv_preview_path)
|
||||
uv_editor = get_node(uv_editor_path)
|
||||
|
||||
func set_mesh_data_resource(a : MeshDataResource) -> void:
|
||||
if uv_preview:
|
||||
uv_preview.set_mesh_data_resource(a)
|
||||
|
||||
if uv_editor:
|
||||
uv_editor.set_mesh_data_resource(a)
|
||||
|
||||
func set_mesh_data_instance(a : MeshDataInstance) -> void:
|
||||
if uv_preview:
|
||||
uv_preview.set_mesh_data_instance(a)
|
||||
|
||||
if uv_editor:
|
||||
uv_editor.set_mesh_data_instance(a)
|
||||
|
||||
func _unhandled_key_input(event : InputEventKey) -> void:
|
||||
if event.echo:
|
||||
|
@ -14,6 +14,7 @@ __meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
uv_preview_path = NodePath("VBoxContainer/ScrollContainer/VBoxContainer2/Operations/Operations/UVDisplay")
|
||||
uv_editor_path = NodePath("Popups/UVEditorPopup/UVEditor")
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="."]
|
||||
margin_left = 7.0
|
||||
@ -520,17 +521,17 @@ margin_bottom = 593.0
|
||||
mouse_filter = 2
|
||||
|
||||
[node name="UVEditorPopup" type="ConfirmationDialog" parent="Popups"]
|
||||
margin_left = 245.0
|
||||
margin_top = 92.0
|
||||
margin_right = 753.0
|
||||
margin_bottom = 476.0
|
||||
margin_left = 149.0
|
||||
margin_top = 35.0
|
||||
margin_right = 901.0
|
||||
margin_bottom = 803.0
|
||||
window_title = "UV Editor"
|
||||
resizable = true
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="RectEditor" parent="Popups/UVEditorPopup" instance=ExtResource( 4 )]
|
||||
[node name="UVEditor" parent="Popups/UVEditorPopup" instance=ExtResource( 4 )]
|
||||
margin_left = 8.0
|
||||
margin_top = 8.0
|
||||
margin_right = -8.0
|
||||
|
@ -5,5 +5,8 @@ func _init():
|
||||
# Control/EditorZoomWidget
|
||||
pass
|
||||
|
||||
func set_edited_resource(res : WorldGenBaseResource):
|
||||
$ScrollContainer/MarginContainer/RectView.set_edited_resource(res)
|
||||
func set_mesh_data_resource(a : MeshDataResource) -> void:
|
||||
$ScrollContainer/MarginContainer/RectView.set_mesh_data_resource(a)
|
||||
|
||||
func set_mesh_data_instance(a : MeshDataInstance) -> void:
|
||||
$ScrollContainer/MarginContainer/RectView.set_mesh_data_instance(a)
|
||||
|
@ -1,13 +1,16 @@
|
||||
tool
|
||||
extends Control
|
||||
|
||||
var rect_editor_node_scene : PackedScene = preload("res://addons/world_generator/ui/RectViewNode.tscn")
|
||||
var rect_editor_node_scene : PackedScene = preload("res://addons/mesh_data_resource_editor/uv_editor/RectViewNode.tscn")
|
||||
|
||||
export(NodePath) var zoom_widget_path : NodePath = ""
|
||||
|
||||
var _rect_scale : float = 1
|
||||
|
||||
var edited_resource : WorldGenBaseResource = null
|
||||
var _mdr : MeshDataResource = null
|
||||
var _background_texture : Texture = null
|
||||
|
||||
var base_rect : Rect2 = Rect2(0, 0, 600, 600)
|
||||
var edited_resource_current_size : Vector2 = Vector2()
|
||||
|
||||
func _enter_tree():
|
||||
@ -23,13 +26,11 @@ func _enter_tree():
|
||||
connect("visibility_changed", self, "on_visibility_changed")
|
||||
|
||||
func on_visibility_changed() -> void:
|
||||
call_deferred("apply_zoom")
|
||||
if is_visible_in_tree():
|
||||
call_deferred("refresh")
|
||||
|
||||
func apply_zoom() -> void:
|
||||
if !edited_resource:
|
||||
return
|
||||
|
||||
var rect : Rect2 = edited_resource.rect
|
||||
var rect : Rect2 = base_rect
|
||||
edited_resource_current_size = rect.size
|
||||
rect.position = rect.position * _rect_scale
|
||||
rect.size = rect.size * _rect_scale
|
||||
@ -52,13 +53,13 @@ func on_zoom_changed(zoom : float) -> void:
|
||||
func _draw():
|
||||
draw_rect(Rect2(Vector2(), get_size()), Color(0.2, 0.2, 0.2, 1))
|
||||
|
||||
if _background_texture:
|
||||
draw_texture_rect_region(_background_texture, Rect2(Vector2(), get_size()), Rect2(Vector2(), _background_texture.get_size()))
|
||||
|
||||
func refresh() -> void:
|
||||
clear()
|
||||
|
||||
if !edited_resource:
|
||||
return
|
||||
|
||||
var rect : Rect2 = edited_resource.rect
|
||||
var rect : Rect2 = base_rect
|
||||
edited_resource_current_size = rect.size
|
||||
rect.position = rect.position * _rect_scale
|
||||
rect.size = rect.size * _rect_scale
|
||||
@ -74,35 +75,33 @@ func clear() -> void:
|
||||
func refresh_rects() -> void:
|
||||
clear_rects()
|
||||
|
||||
if !edited_resource:
|
||||
if !_mdr:
|
||||
return
|
||||
|
||||
var cont : Array = edited_resource.get_content()
|
||||
|
||||
for c in cont:
|
||||
if c:
|
||||
var s : Node = rect_editor_node_scene.instance()
|
||||
|
||||
add_child(s)
|
||||
s.set_editor_rect_scale(_rect_scale)
|
||||
s.edited_resource_parent_size = edited_resource_current_size
|
||||
s.set_edited_resource(c)
|
||||
# var cont : Array = edited_resource.get_content()
|
||||
#
|
||||
# for c in cont:
|
||||
# if c:
|
||||
# var s : Node = rect_editor_node_scene.instance()
|
||||
#
|
||||
# add_child(s)
|
||||
# s.set_editor_rect_scale(_rect_scale)
|
||||
# s.edited_resource_parent_size = edited_resource_current_size
|
||||
# s.set_edited_resource(c)
|
||||
|
||||
func clear_rects():
|
||||
for c in get_children():
|
||||
c.queue_free()
|
||||
remove_child(c)
|
||||
|
||||
func set_edited_resource(res : WorldGenBaseResource):
|
||||
if edited_resource:
|
||||
edited_resource.disconnect("changed", self, "on_edited_resource_changed")
|
||||
func set_mesh_data_resource(a : MeshDataResource) -> void:
|
||||
_mdr = a
|
||||
|
||||
func set_mesh_data_instance(a : MeshDataInstance) -> void:
|
||||
_background_texture = null
|
||||
|
||||
edited_resource = res
|
||||
|
||||
refresh()
|
||||
|
||||
if edited_resource:
|
||||
edited_resource.connect("changed", self, "on_edited_resource_changed")
|
||||
if a:
|
||||
_background_texture = a.texture
|
||||
|
||||
func on_edited_resource_changed() -> void:
|
||||
call_deferred("refresh")
|
||||
|
@ -4,7 +4,7 @@
|
||||
[ext_resource path="res://addons/mesh_data_resource_editor/widgets/EditorZoomWidget.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://addons/mesh_data_resource_editor/uv_editor/RectView.gd" type="Script" id=3]
|
||||
|
||||
[node name="RectEditor" type="PanelContainer"]
|
||||
[node name="UVEditor" type="PanelContainer"]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
script = ExtResource( 1 )
|
||||
|
Loading…
Reference in New Issue
Block a user