godot_translation_editor/addons/zylann.translation_editor/tools/plugin.gd

45 lines
1.0 KiB
GDScript3
Raw Normal View History

2018-11-13 22:37:26 +01:00
tool
extends EditorPlugin
2020-06-14 20:20:03 +02:00
const TranslationEditor = preload("./translation_editor.gd")
const TranslationEditorScene = preload("./translation_editor.tscn")
2018-11-13 22:37:26 +01:00
2020-06-14 20:20:03 +02:00
var _main_control : TranslationEditor = null
2018-11-13 22:37:26 +01:00
func _enter_tree():
print("Translation editor plugin Enter tree")
2020-06-14 20:20:03 +02:00
var editor_interface := get_editor_interface()
var base_control := editor_interface.get_base_control()
2018-11-13 22:37:26 +01:00
2020-06-14 20:20:03 +02:00
_main_control = TranslationEditorScene.instance()
2018-11-13 22:37:26 +01:00
_main_control.configure_for_godot_integration(base_control)
_main_control.hide()
editor_interface.get_editor_viewport().add_child(_main_control)
func _exit_tree():
print("Translation editor plugin Exit tree")
2018-11-13 22:37:26 +01:00
# The main control is not freed when the plugin is disabled
_main_control.queue_free()
_main_control = null
2020-06-14 20:20:03 +02:00
func has_main_screen() -> bool:
2018-11-13 22:37:26 +01:00
return true
2020-06-14 20:20:03 +02:00
func get_plugin_name() -> String:
2018-11-13 22:37:26 +01:00
return "Localization"
2020-06-14 20:20:03 +02:00
func get_plugin_icon() -> Texture:
2018-11-15 00:35:57 +01:00
return preload("icons/icon_translation_editor.svg")
2020-06-14 20:20:03 +02:00
func make_visible(visible: bool):
2018-11-13 22:37:26 +01:00
_main_control.visible = visible