plugin.gd 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. @tool
  2. extends EditorPlugin
  3. var mod_tool_store
  4. var tools_panel
  5. func _enter_tree() -> void:
  6. mod_tool_store = preload("res://addons/mod_tool/global/store.gd").new() as ModToolStore
  7. mod_tool_store.name = "ModToolStore"
  8. get_tree().root.call_deferred("add_child", mod_tool_store, true)
  9. tools_panel = preload("res://addons/mod_tool/interface/panel/tools_panel.tscn").instantiate() as ModToolsPanel
  10. tools_panel.mod_tool_store = mod_tool_store
  11. tools_panel.editor_plugin = self
  12. EditorInterface.get_editor_main_screen().call_deferred("add_child", tools_panel, true)
  13. _make_visible(false)
  14. connect_to_script_editor()
  15. func _exit_tree() -> void:
  16. if mod_tool_store:
  17. mod_tool_store.queue_free()
  18. if tools_panel:
  19. tools_panel.free()
  20. func _make_visible(visible):
  21. if tools_panel:
  22. tools_panel.visible = visible
  23. func _has_main_screen():
  24. return true
  25. func _get_plugin_name():
  26. return "Mod Tool"
  27. func _get_plugin_icon():
  28. return EditorInterface.get_base_control().get_theme_icon(&"Tools", &"EditorIcons")
  29. func connect_to_script_editor() -> void:
  30. EditorInterface.get_script_editor().editor_script_changed.connect(ModToolUtils.reload_script.bind(mod_tool_store))