Make the plugin a main screen plugin using a const.

This commit is contained in:
Relintai 2023-10-13 21:32:49 +02:00
parent a27c01dbcc
commit 64a93ab374

View File

@ -1,6 +1,8 @@
tool
extends EditorPlugin
const USE_BOTTOM_PANEL = false
var SWorldGeneratorSettings = preload("res://addons/world_generator/resources/world_generator_settings.gd")
var SWorldGenBaseResource = preload("res://addons/world_generator/resources/world_gen_base_resource.gd")
@ -10,7 +12,7 @@ var SZone = preload("res://addons/world_generator/resources/zone.gd")
var SSubZone = preload("res://addons/world_generator/resources/subzone.gd")
var editor_packed_scene = preload("res://addons/world_generator/ui/MainScreen.tscn")
var editor_scene = null
var editor_scene : Node = null
var tool_button : ToolButton = null
@ -25,11 +27,15 @@ func _enter_tree():
editor_scene = editor_packed_scene.instance()
editor_scene.set_plugin(self)
editor_scene.hide()
if USE_BOTTOM_PANEL:
tool_button = add_control_to_bottom_panel(editor_scene, "World Editor")
tool_button.hide()
else:
get_editor_interface().get_editor_viewport().add_child(editor_scene)
tool_button = add_control_to_bottom_panel(editor_scene, "World Editor")
tool_button.hide()
func _exit_tree():
func disable_plugin() -> void:
# remove_custom_type("WorldGeneratorSettings")
#
# remove_custom_type("WorldGenBaseResource")
@ -38,8 +44,14 @@ func _exit_tree():
# remove_custom_type("Zone")
# remove_custom_type("SubZone")
remove_control_from_bottom_panel(editor_scene)
if USE_BOTTOM_PANEL:
#remove_control_from_bottom_panel(editor_scene)
pass
if editor_scene:
editor_scene.queue_free()
editor_scene = null
func handles(object):
return object is WorldGenWorld
@ -51,25 +63,36 @@ func edit(object):
if object is WorldGenWorld:
var wgw : WorldGenWorld = object as WorldGenWorld
editor_scene.set_wgworld(wgw)
get_editor_interface().set_main_screen_editor("World")
func make_visible(visible):
if tool_button:
if visible:
tool_button.show()
else:
#if tool_button.pressed:
# tool_button.pressed = false
if USE_BOTTOM_PANEL:
if tool_button:
if visible:
tool_button.show()
else:
#if tool_button.pressed:
# tool_button.pressed = false
if !tool_button.pressed:
tool_button.hide()
if !tool_button.pressed:
tool_button.hide()
else:
if editor_scene:
editor_scene.set_visible(visible)
func get_plugin_icon():
return null
if USE_BOTTOM_PANEL:
return null
else:
return get_editor_interface().get_base_control().get_theme_icon(@"NavigationPolygon", @"EditorIcons")
func get_plugin_name():
return "WorldGeneratorEditor"
return "World"
func has_main_screen():
return false
if USE_BOTTOM_PANEL:
return false
else:
return true