mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
A simple id for extensions (#653)
* A simple id for extensions A simple id system for extensions using the benefit of groups * formatting
This commit is contained in:
parent
906123bab1
commit
de2d7b7748
|
@ -111,6 +111,12 @@ func _add_extension(file_name: String) -> void:
|
||||||
|
|
||||||
func _enable_extension(extension: Extension, save_to_config := true) -> void:
|
func _enable_extension(extension: Extension, save_to_config := true) -> void:
|
||||||
var extension_path: String = "res://src/Extensions/%s/" % extension.file_name
|
var extension_path: String = "res://src/Extensions/%s/" % extension.file_name
|
||||||
|
|
||||||
|
# A unique id for the extension (currently set to file_name). More parameters (version etc.)
|
||||||
|
# can be easily added using the str() function. for example
|
||||||
|
# var id: String = str(extension.file_name, extension.version)
|
||||||
|
var id: String = extension.file_name
|
||||||
|
|
||||||
if extension.enabled:
|
if extension.enabled:
|
||||||
for node in extension.nodes:
|
for node in extension.nodes:
|
||||||
var scene_path: String = extension_path.plus_file(node)
|
var scene_path: String = extension_path.plus_file(node)
|
||||||
|
@ -118,10 +124,10 @@ func _enable_extension(extension: Extension, save_to_config := true) -> void:
|
||||||
if extension_scene:
|
if extension_scene:
|
||||||
var extension_node: Node = extension_scene.instance()
|
var extension_node: Node = extension_scene.instance()
|
||||||
extension_parent.add_child(extension_node)
|
extension_parent.add_child(extension_node)
|
||||||
|
extension_node.add_to_group(id) # Keep track of what to remove later
|
||||||
else:
|
else:
|
||||||
for node in extension.nodes:
|
for ext_node in extension_parent.get_children():
|
||||||
var ext_node = extension_parent.get_node(node.get_basename())
|
if ext_node.is_in_group(id): # Node for extention found
|
||||||
if ext_node:
|
|
||||||
extension_parent.remove_child(ext_node)
|
extension_parent.remove_child(ext_node)
|
||||||
ext_node.queue_free()
|
ext_node.queue_free()
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue