forked from 4d49/scene-library
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.gd
More file actions
72 lines (48 loc) · 2.08 KB
/
Copy pathplugin.gd
File metadata and controls
72 lines (48 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) 2023-2025 Mansur Isaev and contributors - MIT License
# See `LICENSE.md` included in the source distribution for details.
@tool
extends EditorPlugin
const SceneLibrary = preload("res://addons/scene-library/scripts/scene_library.gd")
const DOCK_NAME: String = "Scene Library"
var _editor: SceneLibrary = null
var _dock: EditorDock = null
func _enter_tree() -> void:
_editor = SceneLibrary.new()
_dock = EditorDock.new()
_dock.name = DOCK_NAME
_dock.default_slot = EditorDock.DOCK_SLOT_BOTTOM
_dock.add_child(_editor)
add_dock(_dock)
_editor.open_asset_request.connect(_on_open_asset_request)
_editor.inherit_asset_request.connect(_on_inherit_asset_request)
_editor.show_in_file_system_request.connect(_on_show_in_file_system_request)
_editor.show_in_file_manager_request.connect(_on_show_in_file_manager_request)
_editor.library_saved.connect(_on_library_saved)
_editor.library_unsaved.connect(_on_library_unsaved)
get_parent().connect(&"scene_saved", _editor.handle_scene_saved)
EditorInterface.get_file_system_dock().files_moved.connect(_editor.handle_file_moved)
EditorInterface.get_file_system_dock().file_removed.connect(_editor.handle_file_removed)
func _exit_tree() -> void:
remove_dock(_dock)
_dock.queue_free()
func _save_external_data() -> void:
if _editor.is_saved():
return
var library_path: String = _editor.get_current_library_path()
if library_path.is_empty():
return
_editor.save_library(library_path)
func _on_library_saved() -> void:
_dock.name = DOCK_NAME
func _on_library_unsaved() -> void:
_dock.name = DOCK_NAME + "(*)"
func _on_open_asset_request(path: String) -> void:
EditorInterface.open_scene_from_path(path)
func _on_inherit_asset_request(path: String) -> void:
EditorInterface.open_scene_from_path(path, true)
func _on_show_in_file_system_request(path: String) -> void:
EditorInterface.get_file_system_dock().navigate_to_path(path)
func _on_show_in_file_manager_request(path: String) -> void:
var error := OS.shell_show_in_file_manager(ProjectSettings.globalize_path(path), true)
if error:
push_warning(error_string(error))