diff --git a/addons/mpewsey.maniamap/ManiaMapPlugin.cs b/addons/mpewsey.maniamap/ManiaMapPlugin.cs index 434bfb6..a9c41f8 100644 --- a/addons/mpewsey.maniamap/ManiaMapPlugin.cs +++ b/addons/mpewsey.maniamap/ManiaMapPlugin.cs @@ -124,7 +124,7 @@ private static Node FindContainingRoom(GodotObject obj) private void AddGraphEditorDock() { - var scene = ResourceLoader.Load(ManiaMapResources.Scenes.LayoutGraphEditorScene); + var scene = ManiaMapResources.Scenes.LayoutGraphEditorScene.Load(); GraphEditor = scene.Instantiate(); GraphEditorDockButton = AddControlToBottomPanel(GraphEditor, GraphEditorDockButtonName); GraphEditorDockButton.Visible = false; @@ -155,7 +155,7 @@ private void CreateRoomNode2DToolbar() var mainScreen2d = EditorInterface.Singleton.GetEditorMainScreen().GetChild(0); var hFlowContainers = mainScreen2d.FindChildren("*", nameof(HFlowContainer), true, false); var buttonContainer = (HFlowContainer)hFlowContainers[0]; - var scene = ResourceLoader.Load(ManiaMapResources.Scenes.RoomNode2DToolbarScene); + var scene = ManiaMapResources.Scenes.RoomNode2DToolbarScene.Load(); var toolbar = scene.Instantiate(); RoomNode2DToolbar = toolbar; buttonContainer.AddChild(toolbar); @@ -167,7 +167,7 @@ private void CreateRoomNode3DToolbar() var mainScreen3d = EditorInterface.Singleton.GetEditorMainScreen().GetChild(1); var hFlowContainers = mainScreen3d.FindChildren("*", nameof(HFlowContainer), true, false); var buttonContainer = (HFlowContainer)hFlowContainers[0]; - var scene = ResourceLoader.Load(ManiaMapResources.Scenes.RoomNode3DToolbarScene); + var scene = ManiaMapResources.Scenes.RoomNode3DToolbarScene.Load(); var toolbar = scene.Instantiate(); RoomNode3DToolbar = toolbar; buttonContainer.AddChild(toolbar); diff --git a/addons/mpewsey.maniamap/plugin.cfg b/addons/mpewsey.maniamap/plugin.cfg index d4c277a..b91e86d 100644 --- a/addons/mpewsey.maniamap/plugin.cfg +++ b/addons/mpewsey.maniamap/plugin.cfg @@ -3,5 +3,5 @@ name="ManiaMap.Godot" description="Procedural generation of metroidvania style maps for Godot .NET." author="Matt Pewsey" -version="1.0.1" +version="1.0.2" script="ManiaMapPlugin.cs" diff --git a/addons/mpewsey.maniamap/scripts/runtime/ManiaMapResources.cs b/addons/mpewsey.maniamap/scripts/runtime/ManiaMapResources.cs index 5acb7c7..0c6aee1 100644 --- a/addons/mpewsey.maniamap/scripts/runtime/ManiaMapResources.cs +++ b/addons/mpewsey.maniamap/scripts/runtime/ManiaMapResources.cs @@ -23,9 +23,9 @@ public static class Enums /// public static class Scenes { - public const string LayoutGraphEditorScene = "uid://ckyjrhwvcs6fi"; - public const string RoomNode2DToolbarScene = "uid://ceij50wkmgvyi"; - public const string RoomNode3DToolbarScene = "uid://b25t77npx7a3l"; + public static PathRef LayoutGraphEditorScene { get; } = new PathRef("uid://ckyjrhwvcs6fi", "res://addons/mpewsey.maniamap/scenes/layout_graph_editor/layout_graph_editor.tscn"); + public static PathRef RoomNode2DToolbarScene { get; } = new PathRef("uid://ceij50wkmgvyi", "res://addons/mpewsey.maniamap/scenes/room_node_2d_toolbar/room_node_2d_toolbar.tscn"); + public static PathRef RoomNode3DToolbarScene { get; } = new PathRef("uid://b25t77npx7a3l", "res://addons/mpewsey.maniamap/scenes/room_node_3d_toolbar/room_node_3d_toolbar.tscn"); } /// @@ -33,7 +33,8 @@ public static class Scenes /// public static class Materials { - public static Material AlbedoMaterial { get; } = ResourceLoader.Load("uid://ppa2shs6thgv"); + public static PathRef AlbedoMaterialPath { get; } = new PathRef("uid://ppa2shs6thgv", "res://addons/mpewsey.maniamap/materials/albedo_material.tres"); + public static Material AlbedoMaterial { get; } = AlbedoMaterialPath.Load(); } /// diff --git a/addons/mpewsey.maniamap/scripts/runtime/PathRef.cs b/addons/mpewsey.maniamap/scripts/runtime/PathRef.cs new file mode 100644 index 0000000..0fd7008 --- /dev/null +++ b/addons/mpewsey.maniamap/scripts/runtime/PathRef.cs @@ -0,0 +1,26 @@ +using Godot; + +namespace MPewsey.ManiaMapGodot +{ + public readonly struct PathRef + { + public string UidPath { get; } + public string ResPath { get; } + + public PathRef(string uidPath, string resPath) + { + UidPath = uidPath; + ResPath = resPath; + } + + public string GetLoadPath() + { + return ResourceLoader.Exists(ResPath) ? ResPath : UidPath; + } + + public T Load() where T : class + { + return ResourceLoader.Load(GetLoadPath()); + } + } +} \ No newline at end of file