Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions addons/dialogic/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ description="Create dialogs, characters and scenes to display conversations in y
https://github.com/dialogic-godot/dialogic"
author="Jowan Spooner, Emi, Cake and more!"
version="2.0-Alpha-19 WIP (Godot 4.3+)"
godot_version="4.5"
script="plugin.gd"
50 changes: 22 additions & 28 deletions addons/dialogic/plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -19,52 +19,46 @@ func _init() -> void:
#region ACTIVATION & EDITOR SETUP
################################################################################

## Activation & Editor Setup
func _enable_plugin() -> void:
add_autoload_singleton(PLUGIN_NAME, PLUGIN_HANDLER_PATH)
add_dialogic_default_action()


func _disable_plugin() -> void:
remove_autoload_singleton(PLUGIN_NAME)


## Called when the plugin is activated in the editor.
## Sets up the main editor interface and inspector plugin.
func _enter_tree() -> void:
# Add default input action for Dialogic
add_dialogic_default_action()

# Setup main editor view
# Use call_deferred to ensure editor_main_screen is ready in Godot 4.5+
editor_view = MainPanel.instantiate()
editor_view.plugin_reference = self
editor_view.hide()
get_editor_interface().get_editor_main_screen().add_child(editor_view)
call_deferred("_add_main_panel_to_editor", editor_view)
_make_visible(false)


# Setup inspector plugin
inspector_plugin = load("res://addons/dialogic/Editor/Inspector/inspector_plugin.gd").new()
add_inspector_plugin(inspector_plugin)

# Auto-update the singleton path for alpha users
# TODO remove at some point during beta or later
if not ProjectSettings.has_setting("autoload/"+PLUGIN_NAME) or not "Core" in ProjectSettings.get_setting("autoload/"+PLUGIN_NAME, ""):
if ProjectSettings.has_setting("autoload/"+PLUGIN_NAME):
remove_autoload_singleton(PLUGIN_NAME)
add_autoload_singleton(PLUGIN_NAME, PLUGIN_HANDLER_PATH)

## Helper function to safely add main panel to editor interface
## Deferred to ensure editor_main_screen is ready in Godot 4.5+
func _add_main_panel_to_editor(panel: Control) -> void:
var main_screen := get_editor_interface().get_editor_main_screen()
if main_screen:
main_screen.add_child(panel)


## Called when the plugin is deactivated in the editor.
## Cleans up the editor interface.
func _exit_tree() -> void:
if editor_view:
remove_control_from_bottom_panel(editor_view)
if editor_view.get_parent():
editor_view.get_parent().remove_child(editor_view)
editor_view.queue_free()

if inspector_plugin:
remove_inspector_plugin(inspector_plugin)

#endregion


#region PLUGIN_INFO
################################################################################

func _has_main_screen() -> bool:
return true


Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Restoring this code seems to have fixed my previously reported bug on this PR.

func _get_plugin_name() -> String:
return PLUGIN_NAME

Expand Down