-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[licenses] Add filesystem context menu
- Loading branch information
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
addons/licenses/internal/plugin/context_menu_filesystem.gd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
extends EditorContextMenuPlugin | ||
|
||
const Component := preload("res://addons/licenses/component.gd") | ||
const LicensesInterface := preload("res://addons/licenses/internal/plugin/licenses_interface.gd") | ||
|
||
var _li: LicensesInterface | ||
|
||
func _init() -> void: | ||
self._li = LicensesInterface.get_interface() | ||
|
||
func _popup_menu(paths: PackedStringArray) -> void: | ||
if paths.size() == 1: | ||
var comps: Array[Component] = self._li.get_components_in_path(paths[0]) | ||
if comps.size() > 0: | ||
for comp: Component in comps: | ||
self.add_context_menu_item("Show license (" + comp.name + ")", self._on_single_ctx_menu_clicked.bind(comp)) | ||
|
||
func _on_single_ctx_menu_clicked(_paths: PackedStringArray, comp: Component) -> void: | ||
self._li.show_popup(comp) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters