From a368ea500ae673816a577c20898cc58fdc079e89 Mon Sep 17 00:00:00 2001 From: Emmanouil Papadeas Date: Thu, 7 Jul 2022 01:37:04 +0300 Subject: [PATCH] Add more methods to ExtensionsAPI --- src/Autoload/ExtensionsAPI.gd | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/Autoload/ExtensionsAPI.gd b/src/Autoload/ExtensionsAPI.gd index 40d34cb85..73b52063c 100644 --- a/src/Autoload/ExtensionsAPI.gd +++ b/src/Autoload/ExtensionsAPI.gd @@ -1,3 +1,4 @@ +# gdlint: ignore=max-public-methods extends Node enum { FILE, EDIT, SELECT, IMAGE, VIEW, WINDOW, HELP } @@ -15,6 +16,14 @@ func get_extensions_node() -> Node: return Global.control.get_node("Extensions") +func get_config_file() -> ConfigFile: + return Global.config_cache + + +func get_canvas() -> Canvas: + return Global.canvas + + func _get_popup_menu(menu_type: int) -> PopupMenu: match menu_type: FILE: @@ -39,7 +48,9 @@ func add_menu_item(menu_type: int, item_name: String, item_metadata, item_id := if not image_menu: return -1 image_menu.add_item(item_name, item_id) - var idx: int = image_menu.get_item_count() - 1 + var idx := item_id + if item_id == -1: + idx = image_menu.get_item_count() - 1 image_menu.set_item_metadata(idx, item_metadata) return idx