mirror of
https://github.com/Relintai/world_generator_addon.git
synced 2024-11-19 20:47:19 +01:00
Make the plugin a main screen plugin using a const.
This commit is contained in:
parent
a27c01dbcc
commit
64a93ab374
@ -1,6 +1,8 @@
|
|||||||
tool
|
tool
|
||||||
extends EditorPlugin
|
extends EditorPlugin
|
||||||
|
|
||||||
|
const USE_BOTTOM_PANEL = false
|
||||||
|
|
||||||
var SWorldGeneratorSettings = preload("res://addons/world_generator/resources/world_generator_settings.gd")
|
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")
|
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 SSubZone = preload("res://addons/world_generator/resources/subzone.gd")
|
||||||
|
|
||||||
var editor_packed_scene = preload("res://addons/world_generator/ui/MainScreen.tscn")
|
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
|
var tool_button : ToolButton = null
|
||||||
|
|
||||||
@ -25,11 +27,15 @@ func _enter_tree():
|
|||||||
|
|
||||||
editor_scene = editor_packed_scene.instance()
|
editor_scene = editor_packed_scene.instance()
|
||||||
editor_scene.set_plugin(self)
|
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")
|
func disable_plugin() -> void:
|
||||||
tool_button.hide()
|
|
||||||
|
|
||||||
func _exit_tree():
|
|
||||||
# remove_custom_type("WorldGeneratorSettings")
|
# remove_custom_type("WorldGeneratorSettings")
|
||||||
#
|
#
|
||||||
# remove_custom_type("WorldGenBaseResource")
|
# remove_custom_type("WorldGenBaseResource")
|
||||||
@ -38,8 +44,14 @@ func _exit_tree():
|
|||||||
# remove_custom_type("Zone")
|
# remove_custom_type("Zone")
|
||||||
# remove_custom_type("SubZone")
|
# 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):
|
func handles(object):
|
||||||
return object is WorldGenWorld
|
return object is WorldGenWorld
|
||||||
@ -51,25 +63,36 @@ func edit(object):
|
|||||||
if object is WorldGenWorld:
|
if object is WorldGenWorld:
|
||||||
var wgw : WorldGenWorld = object as WorldGenWorld
|
var wgw : WorldGenWorld = object as WorldGenWorld
|
||||||
editor_scene.set_wgworld(wgw)
|
editor_scene.set_wgworld(wgw)
|
||||||
|
get_editor_interface().set_main_screen_editor("World")
|
||||||
|
|
||||||
func make_visible(visible):
|
func make_visible(visible):
|
||||||
if tool_button:
|
if USE_BOTTOM_PANEL:
|
||||||
if visible:
|
if tool_button:
|
||||||
tool_button.show()
|
if visible:
|
||||||
else:
|
tool_button.show()
|
||||||
#if tool_button.pressed:
|
else:
|
||||||
# tool_button.pressed = false
|
#if tool_button.pressed:
|
||||||
|
# tool_button.pressed = false
|
||||||
|
|
||||||
if !tool_button.pressed:
|
if !tool_button.pressed:
|
||||||
tool_button.hide()
|
tool_button.hide()
|
||||||
|
else:
|
||||||
|
if editor_scene:
|
||||||
|
editor_scene.set_visible(visible)
|
||||||
|
|
||||||
func get_plugin_icon():
|
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():
|
func get_plugin_name():
|
||||||
return "WorldGeneratorEditor"
|
return "World"
|
||||||
|
|
||||||
func has_main_screen():
|
func has_main_screen():
|
||||||
return false
|
if USE_BOTTOM_PANEL:
|
||||||
|
return false
|
||||||
|
else:
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user