From a36e393fb2adbcee1dbd5cdd68fc2b734fe1b9a7 Mon Sep 17 00:00:00 2001 From: Prakhar Shukla Date: Mon, 23 Nov 2026 15:03:21 +0530 Subject: [PATCH] Godot addon: Fix script editor menu in Godot 4.8 Signed-off-by: Prakhar Shukla --- addons/GDQuest_GDScript_formatter/menu.gd | 10 ++++++---- addons/GDQuest_GDScript_formatter_standalone/menu.gd | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/addons/GDQuest_GDScript_formatter/menu.gd b/addons/GDQuest_GDScript_formatter/menu.gd index 65f71fe..f98364c 100644 --- a/addons/GDQuest_GDScript_formatter/menu.gd +++ b/addons/GDQuest_GDScript_formatter/menu.gd @@ -75,14 +75,16 @@ func update_menu(show_uninstall: bool) -> void: ## Searches for and returns the last menu node in the script editor top menu bar, ## or null if not found. func _find_last_menu_button(script_editor: Control) -> MenuButton: - # The first child of the script editor should be a VBoxContainer (main container for the script editor main screen) - # Then the first child of that container should be an HBoxContainer (the menu bar) - # This is based on the current structure of Godot's script editor as of Godot 4.5 - # Note: We add multiple checks in there with null returns mainly in case something changes in a future if script_editor.get_child_count() == 0: return null var main_container := script_editor.get_child(0) + # Godot 4.8 wraps the existing layout in a DocumentEditorContainer. + if main_container.is_class("DocumentEditorContainer"): + if main_container.get_child_count() == 0: + return null + main_container = main_container.get_child(0) + if not is_instance_valid(main_container) or not main_container is VBoxContainer: return null diff --git a/addons/GDQuest_GDScript_formatter_standalone/menu.gd b/addons/GDQuest_GDScript_formatter_standalone/menu.gd index a0847dd..d8036b3 100644 --- a/addons/GDQuest_GDScript_formatter_standalone/menu.gd +++ b/addons/GDQuest_GDScript_formatter_standalone/menu.gd @@ -61,14 +61,16 @@ func update_menu() -> void: ## Searches for and returns the last menu node in the script editor top menu bar, ## or null if not found. func _find_last_menu_button(script_editor: Control) -> MenuButton: - # The first child of the script editor should be a VBoxContainer (main container for the script editor main screen) - # Then the first child of that container should be an HBoxContainer (the menu bar) - # This is based on the current structure of Godot's script editor as of Godot 4.5 - # Note: We add multiple checks in there with null returns mainly in case something changes in a future if script_editor.get_child_count() == 0: return null var main_container := script_editor.get_child(0) + # Godot 4.8 wraps the existing layout in a DocumentEditorContainer. + if main_container.is_class("DocumentEditorContainer"): + if main_container.get_child_count() == 0: + return null + main_container = main_container.get_child(0) + if not is_instance_valid(main_container) or not main_container is VBoxContainer: return null