-
-
Notifications
You must be signed in to change notification settings - Fork 251
Support loading user plugin from .pck #655
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Airyzz
wants to merge
13
commits into
RodZill4:master
Choose a base branch
from
Airyzz:feat/user-plugins
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
331e4cf
Load user plugin from pck
Airyzz d295586
Add a way for plugins to store arbitrary data in the node graph
Airyzz d07187c
Update loader.gd
Airyzz 520a95c
Move animation export to a separate file so it's callable by user plu…
Airyzz cf70da5
Update main_window.tscn
Airyzz 53e30ee
Update library_manager.gd
Airyzz df35519
Merge branch 'master' into feat/user-plugins
Airyzz bfd266e
tweak to load from directory instead of zip/pck
Airyzz e51b2f5
Update loader.gd
Airyzz eb5b0c8
load resources from a subdirectory to avoid conflicts
Airyzz 0afb2ba
add uid
Airyzz 04ef1a5
Update export_presets.cfg
Airyzz a0016a2
Update plugin_context.gd
Airyzz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,29 @@ | ||
class PluginContext: | ||
|
||
var plugin_path: String | ||
func _init(file_path: String) -> void: | ||
plugin_path = file_path | ||
|
||
func load_resource(resource_path: String) -> Variant: | ||
|
||
if ResourceLoader.exists(resource_path): | ||
print("Dependency already exists, either its been loaded or there is a dependency collision") | ||
return ResourceLoader.load(resource_path) | ||
|
||
var res_path = resource_path.get_slice("::", 2) | ||
var file_path = res_path.replace("res://", plugin_path + "/") | ||
|
||
var dependencies = ResourceLoader.get_dependencies(file_path) | ||
for dependency in dependencies: | ||
load_resource(dependency) | ||
|
||
print("Loading dependency: " + file_path) | ||
var resource = ResourceLoader.load(file_path) | ||
if resource == null: | ||
return null | ||
|
||
print(resource) | ||
resource.take_over_path(resource_path) | ||
resource.take_over_path(resource_path.get_slice("::", 0)) | ||
resource.take_over_path(resource_path.get_slice("::", 2)) | ||
return resource |
This file contains hidden or 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 @@ | ||
uid://demftccswppj6 |
This file contains hidden or 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,13 @@ | ||
extends Node | ||
|
||
const PluginContext = preload("res://addons/material_maker/engine/plugin/plugin_context.gd") | ||
|
||
var context: PluginContext.PluginContext = null | ||
|
||
signal on_ui_loaded | ||
|
||
func load(resource_path): | ||
return context.load_resource(resource_path) | ||
|
||
func ui_ready(): | ||
on_ui_loaded.emit() |
This file contains hidden or 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 @@ | ||
uid://tjn43ecqeoar |
This file contains hidden or 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,6 @@ | ||
[gd_scene load_steps=2 format=3 uid="uid://bct66q7hliai2"] | ||
|
||
[ext_resource type="Script" path="res://addons/material_maker/engine/plugin/plugin_instance.gd" id="1_51jwo"] | ||
|
||
[node name="plugin_instance" type="Node"] | ||
script = ExtResource("1_51jwo") |
This file contains hidden or 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,55 @@ | ||
extends Node | ||
|
||
const PluginContext = preload("res://addons/material_maker/engine/plugin/plugin_context.gd") | ||
const instance = preload("res://addons/material_maker/engine/plugin/plugin_instance.tscn") | ||
@onready var mm_plugins = get_node("/root/mm_plugins") | ||
|
||
func _ready()-> void: | ||
load_plugins() | ||
|
||
func load_plugins(): | ||
var plugin_dir = DirAccess.open("user://plugins") | ||
if not plugin_dir: | ||
return | ||
|
||
var any_plugins_loaded = false | ||
|
||
var directories = plugin_dir.get_directories() | ||
print(directories) | ||
|
||
for directory in directories: | ||
|
||
print(directory) | ||
var plugin_folder = "user://plugins/" + directory | ||
var plugin_content = DirAccess.open(plugin_folder) | ||
var plugin_directories = plugin_content.get_directories() | ||
print(plugin_directories) | ||
|
||
var plugin_id = plugin_directories[0] | ||
var scene_path = "user://plugins/" + directory + "/" + plugin_id + "/plugin.tscn" | ||
print(scene_path) | ||
|
||
var real_path = "user://plugins/" + directory | ||
|
||
var context = PluginContext.PluginContext.new(real_path) | ||
|
||
var dependencies = ResourceLoader.get_dependencies(scene_path) | ||
for dependency in dependencies: | ||
context.load_resource(dependency) | ||
|
||
var scene = ResourceLoader.load(scene_path) | ||
if scene == null: | ||
continue | ||
|
||
if not scene is PackedScene: | ||
continue | ||
|
||
var plugin_node = scene.instantiate() | ||
var addon_instance = instance.instantiate() | ||
|
||
addon_instance.name = plugin_id | ||
addon_instance.context = context | ||
|
||
mm_plugins.add_child(addon_instance) | ||
addon_instance.add_child(plugin_node) | ||
print("Finished loading plugin: " + plugin_id) |
This file contains hidden or 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 @@ | ||
uid://dstdde4y0gqmm |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.