2021-02-08 08:24:40 +01:00
|
|
|
tool
|
|
|
|
extends EditorPlugin
|
|
|
|
|
2021-02-09 01:40:13 +01:00
|
|
|
const MdiGizmoPlugin = preload("res://addons/mesh_data_resource_editor/MDIGizmoPlugin.gd")
|
2021-03-02 13:03:02 +01:00
|
|
|
const MDIEdGui = preload("res://addons/mesh_data_resource_editor/MDIEd.tscn")
|
2021-02-08 08:24:40 +01:00
|
|
|
|
2021-02-09 01:40:13 +01:00
|
|
|
var gizmo_plugin = MdiGizmoPlugin.new()
|
2021-03-02 13:03:02 +01:00
|
|
|
var mdi_ed_gui : Control
|
2021-02-08 08:24:40 +01:00
|
|
|
|
2021-03-02 13:03:02 +01:00
|
|
|
var active_gizmos : Array
|
2021-02-28 00:18:38 +01:00
|
|
|
|
2021-02-09 01:40:13 +01:00
|
|
|
func _enter_tree():
|
2021-03-02 13:03:02 +01:00
|
|
|
print("_enter_tree")
|
|
|
|
|
|
|
|
gizmo_plugin = MdiGizmoPlugin.new()
|
|
|
|
mdi_ed_gui = MDIEdGui.instance()
|
2021-03-02 21:41:24 +01:00
|
|
|
mdi_ed_gui.plugin = self
|
2021-03-02 13:03:02 +01:00
|
|
|
active_gizmos = []
|
|
|
|
|
2021-02-28 00:18:38 +01:00
|
|
|
gizmo_plugin.plugin = self
|
|
|
|
|
2021-03-02 13:03:02 +01:00
|
|
|
add_control_to_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, mdi_ed_gui)
|
|
|
|
mdi_ed_gui.hide()
|
|
|
|
|
2021-02-09 01:40:13 +01:00
|
|
|
add_spatial_gizmo_plugin(gizmo_plugin)
|
2021-02-28 00:18:38 +01:00
|
|
|
|
|
|
|
set_input_event_forwarding_always_enabled()
|
2021-02-08 08:24:40 +01:00
|
|
|
|
|
|
|
func _exit_tree():
|
2021-03-02 13:03:02 +01:00
|
|
|
print("_exit_tree")
|
|
|
|
|
2021-02-09 01:40:13 +01:00
|
|
|
remove_spatial_gizmo_plugin(gizmo_plugin)
|
2021-03-02 13:03:02 +01:00
|
|
|
#remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, mdi_ed_gui)
|
|
|
|
mdi_ed_gui.queue_free()
|
|
|
|
pass
|
|
|
|
|
|
|
|
#func enable_plugin():
|
|
|
|
# print("enable_plugin")
|
|
|
|
# pass
|
|
|
|
#
|
|
|
|
#func disable_plugin():
|
|
|
|
# print("disable_plugin")
|
|
|
|
# remove_spatial_gizmo_plugin(gizmo_plugin)
|
|
|
|
# remove_control_from_container(EditorPlugin.CONTAINER_SPATIAL_EDITOR_SIDE_RIGHT, mdi_ed_gui)
|
|
|
|
# mdi_ed_gui.queue_free()
|
|
|
|
|
|
|
|
func handles(object):
|
|
|
|
print("disable_plugin")
|
|
|
|
|
|
|
|
if object is MeshDataInstance:
|
|
|
|
return true
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
|
|
|
func make_visible(visible):
|
|
|
|
print("make_visible")
|
|
|
|
|
|
|
|
if visible:
|
|
|
|
mdi_ed_gui.show()
|
|
|
|
else:
|
|
|
|
#mdi_ed_gui.hide()
|
|
|
|
#figure out how to hide it when something else gets selected, don't hide on unselect
|
|
|
|
pass
|
|
|
|
|
|
|
|
func get_plugin_name():
|
|
|
|
return "mesh_data_resource_editor"
|
2021-02-28 00:18:38 +01:00
|
|
|
|
|
|
|
#func forward_spatial_gui_input(camera, event):
|
|
|
|
# return forward_spatial_gui_input(0, camera, event)
|
|
|
|
|
|
|
|
func register_gizmo(gizmo):
|
|
|
|
active_gizmos.append(gizmo)
|
|
|
|
|
|
|
|
func unregister_gizmo(gizmo):
|
|
|
|
for i in range(active_gizmos.size()):
|
|
|
|
if active_gizmos[i] == gizmo:
|
|
|
|
active_gizmos.remove(i)
|
|
|
|
return
|
|
|
|
|
2021-03-02 21:41:24 +01:00
|
|
|
func translate_request(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.translate_request(on)
|
|
|
|
|
|
|
|
func scale_request(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.scale_request(on)
|
|
|
|
|
|
|
|
func rotate_request(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.rotate_request(on)
|
|
|
|
|
|
|
|
func axis_key_x(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.axis_key_x(on)
|
|
|
|
|
|
|
|
func axis_key_y(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.axis_key_y(on)
|
|
|
|
|
|
|
|
func axis_key_z(on : bool) -> void:
|
|
|
|
for g in active_gizmos:
|
|
|
|
g.axis_key_z(on)
|
|
|
|
|
2021-03-02 13:03:02 +01:00
|
|
|
func forward_spatial_gui_input(camera, event):
|
2021-02-28 00:18:38 +01:00
|
|
|
for g in active_gizmos:
|
2021-03-02 13:03:02 +01:00
|
|
|
if g.forward_spatial_gui_input(0, camera, event):
|
2021-02-28 00:18:38 +01:00
|
|
|
return true
|
|
|
|
|
|
|
|
return false
|
2021-03-02 13:03:02 +01:00
|
|
|
|
|
|
|
#func forward_spatial_gui_input(index, camera, event):
|
|
|
|
# for g in active_gizmos:
|
|
|
|
# if g.forward_spatial_gui_input(index, camera, event):
|
|
|
|
# return true
|
|
|
|
#
|
|
|
|
# return false
|