Skip to content
Merged
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
14 changes: 14 additions & 0 deletions addons/block_code/block_code_plugin.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ extends EditorPlugin
const MainPanel := preload("res://addons/block_code/ui/main_panel.tscn")
static var main_panel

var editor_inspector: EditorInspector

var old_feature_profile: String = ""

const DISABLED_CLASSES := [
Expand Down Expand Up @@ -47,6 +49,8 @@ const DISABLED_CLASSES := [
func _enter_tree():
Types.init_cast_graph()

editor_inspector = EditorInterface.get_inspector()

main_panel = MainPanel.instantiate()
main_panel.undo_redo = get_undo_redo()

Expand Down Expand Up @@ -91,6 +95,16 @@ func _exit_tree():
EditorInterface.set_current_feature_profile("")


func _ready():
editor_inspector.connect("edited_object_changed", _on_editor_inspector_edited_object_changed)


func _on_editor_inspector_edited_object_changed():
var block_code: BlockCode = editor_inspector.get_edited_object() as BlockCode
Copy link
Member

Choose a reason for hiding this comment

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

I was not aware of Godot's behavior to set the casted value to null if doesn't match the casted type. That's both neat and frightening.

if block_code:
BlockCodePlugin.main_panel.switch_script(block_code)


func _has_main_screen():
return true

Expand Down