diff options
| author | radiohotline <radoihotline@disroot.rg> | 2026-08-25 16:33:56 +0300 |
|---|---|---|
| committer | radiohotline <radoihotline@disroot.rg> | 2026-08-25 16:33:56 +0300 |
| commit | a89e744ed0e8c759caf041a580112365bbfe4303 (patch) | |
| tree | dd61e320904176995727e86a857d00c90d4933ba /addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd | |
| parent | 6d53d8cac78250dc888aa49d5f9d4175c6652feb (diff) | |
Diffstat (limited to 'addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd')
| -rw-r--r-- | addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd b/addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd new file mode 100644 index 0000000..0c92b92 --- /dev/null +++ b/addons/gdUnit4/src/ui/menu/GdUnitEditorFileSystemContextMenuHandler.gd @@ -0,0 +1,37 @@ +@tool +extends EditorContextMenuPlugin + +var _context_menus: Array[GdUnitContextMenuItem] = [] + + +func _init() -> void: + var is_test_suite := func is_visible(script: Script, is_ts: bool) -> bool: + if script == null: + return false + return GdUnitTestSuiteScanner.is_test_suite(script) == is_ts + _context_menus.append(GdUnitContextMenuItem.new( + GdUnitCommandFileSystemRunTests.ID, + "Run Testsuites", + is_test_suite.bind(true) + )) + _context_menus.append(GdUnitContextMenuItem.new( + GdUnitCommandFileSystemDebugTests.ID, + "Debug Testsuites", + is_test_suite.bind(true) + )) + + # setup shortcuts + for menu_item in _context_menus: + if menu_item.shortcut(): + var cb := func call(...files: Array) -> void: + var paths: Array = files[0] + menu_item.execute.callv(paths) + add_menu_shortcut(menu_item.shortcut(), cb) + + +func _popup_menu(paths: PackedStringArray) -> void: + for menu_item in _context_menus: + if menu_item.shortcut(): + add_context_menu_item_from_shortcut(menu_item.name, menu_item.shortcut(), menu_item.icon) + else: + add_context_menu_item(menu_item.name, menu_item.execute.bindv(paths).unbind(1), menu_item.icon) |
