-
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.
- Loading branch information
Showing
9 changed files
with
255 additions
and
95 deletions.
There are no files selected for viewing
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
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
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,39 @@ | ||
extends Node | ||
|
||
const Component := preload("../component.gd") | ||
const Licenses := preload("../licenses.gd") | ||
|
||
signal components_changed() | ||
|
||
var _components: Array[Component] = [] | ||
|
||
func emit_changed() -> void: | ||
self.components_changed.emit() | ||
|
||
func add_component(component: Component) -> void: | ||
self._components.append(component) | ||
self._components.sort_custom(Licenses.compare_components_ascending) | ||
|
||
func set_components(components_: Array[Component]) -> void: | ||
self._components = components_ | ||
|
||
func components() -> Array[Component]: | ||
return self._components | ||
|
||
func get_at(idx: int) -> Component: | ||
return self._components[idx] | ||
|
||
func remove_at(idx: int) -> void: | ||
self._components.remove_at(idx) | ||
|
||
func remove_component(component: Component) -> void: | ||
var idx: int = self._components.find(component) | ||
if idx == -1: | ||
return | ||
self.remove_at(idx) | ||
|
||
func sort_custom(fn: Callable) -> void: | ||
self._components.sort_custom(fn) | ||
|
||
func count() -> int: | ||
return len(self._components) |
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
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,36 @@ | ||
extends RefCounted | ||
|
||
const ComponentsContainer := preload("components_container.gd") | ||
|
||
var _components: ComponentsContainer | ||
|
||
func _init(components: ComponentsContainer): | ||
self._components = components | ||
var fs_dock: FileSystemDock = EditorInterface.get_file_system_dock() | ||
fs_dock.files_moved.connect(self._on_file_moved) | ||
fs_dock.folder_moved.connect(self._on_folder_moved) | ||
|
||
func _on_file_moved(old_file: String, new_file: String) -> void: | ||
var changed: bool = false | ||
for comp in self._components.components(): | ||
for idx in range(comp.paths.size()): | ||
var path: String = comp.paths[idx] | ||
if path == old_file: | ||
changed = true | ||
comp.paths[idx] = new_file | ||
if changed: | ||
self._components.emit_changed() | ||
|
||
func _on_folder_moved(old_folder: String, new_folder: String) -> void: | ||
var old_folder_no_slash: String = old_folder.rstrip("/") | ||
var changed: bool = false | ||
for comp in self._components.components(): | ||
for idx in range(comp.paths.size()): | ||
var path: String = comp.paths[idx] | ||
if path == old_folder_no_slash: | ||
changed = true | ||
comp.paths[idx] = new_folder.rstrip("/") | ||
if path.begins_with(old_folder): | ||
comp.paths[idx] = new_folder.rstrip("/") + "/" + comp.paths[idx].trim_prefix(old_folder) | ||
if changed: | ||
self._components.emit_changed() |
Oops, something went wrong.