2021-11-18 17:23:37 +01:00
tool
extends EditorPlugin
signal sd_scene_changed ( new_scene )
const MainScreen = preload ( " res://addons/summer_day/main_screen.tscn " )
const Timeline = preload ( " res://addons/summer_day/tool/timeline/timeline.tscn " )
2021-11-21 11:46:04 +01:00
var Canvas : SummerDayCanvas
2021-11-18 17:23:37 +01:00
var main_screen_instance : SummerDayMainScreen
var timeline_instance : SummerDayTimeline
2021-11-21 11:46:04 +01:00
var tool_context : = SummerDayToolContext . new ( )
2021-11-18 17:23:37 +01:00
func _enter_tree ( ) :
main_screen_instance = MainScreen . instance ( )
2021-11-21 11:46:04 +01:00
Canvas = main_screen_instance . get_node ( " Canvas " )
Canvas . tool_context = tool_context
self . connect ( " sd_scene_changed " ,
Canvas , " _on_SummerDay_scene_changed "
)
2021-11-18 17:23:37 +01:00
self . connect ( " sd_scene_changed " ,
2021-11-21 11:46:04 +01:00
tool_context , " _on_SummerDay_scene_changed "
2021-11-18 17:23:37 +01:00
)
# Add the main panel to the editor's main viewport.
get_editor_interface ( ) . get_editor_viewport ( ) . add_child ( main_screen_instance )
# Hide the main panel. Very much required.
make_visible ( false )
timeline_instance = Timeline . instance ( )
add_control_to_bottom_panel ( timeline_instance , " SummerDay Timeline " )
add_custom_type ( " SummerDayScene " , " Resource " ,
load ( " res://addons/summer_day/data_structure/scene/scene.gd " ) ,
get_editor_interface ( ) . get_base_control ( ) . get_icon ( " Animation " , " EditorIcons " ) )
add_custom_type ( " SummerDayDisplay " , " Control " ,
load ( " res://addons/summer_day/interface/display.gd " ) ,
get_editor_interface ( ) . get_base_control ( ) . get_icon ( " TextureRect " , " EditorIcons " ) )
func _exit_tree ( ) :
if main_screen_instance :
main_screen_instance . queue_free ( )
remove_custom_type ( " SummerDayScene " )
remove_custom_type ( " SummerDayDisplay " )
remove_control_from_bottom_panel ( timeline_instance )
func has_main_screen ( ) :
return true
func make_visible ( visible ) :
if main_screen_instance :
main_screen_instance . visible = visible
# if visible:
# make_bottom_panel_item_visible(timeline_instance)
# else:
# hide_bottom_panel()
func handles ( object ) :
if object is SummerDayScene :
return true
func edit ( scene ) :
emit_signal ( " sd_scene_changed " , scene )
func get_plugin_name ( ) :
return " SummerDay "
func get_plugin_icon ( ) :
return get_editor_interface ( ) . get_base_control ( ) . get_icon ( " AnimationPlayer " , " EditorIcons " )