added forge addon
All checks were successful
Create tag and build when new code gets to main / BumpTag (push) Successful in 21s
Create tag and build when new code gets to main / Test (push) Successful in 6m56s
Create tag and build when new code gets to main / Export (push) Successful in 9m3s

This commit is contained in:
2026-02-08 15:16:01 +01:00
parent 2b74c9e70c
commit c4be97e0de
163 changed files with 6975 additions and 141 deletions

View File

@@ -0,0 +1,109 @@
// Copyright © Gamesmiths Guild.
#if TOOLS
using System.Diagnostics;
using Gamesmiths.Forge.Godot.Editor;
using Gamesmiths.Forge.Godot.Editor.Attributes;
using Gamesmiths.Forge.Godot.Editor.Cues;
using Gamesmiths.Forge.Godot.Editor.Tags;
using Godot;
namespace Gamesmiths.Forge.Godot;
[Tool]
public partial class ForgePluginLoader : EditorPlugin
{
private const string AutoloadPath = "uid://ba8fquhtwu5mu";
private const string PluginScenePath = "uid://pjscvogl6jak";
private EditorDock? _editorDock;
private PanelContainer? _dockedScene;
private TagContainerInspectorPlugin? _tagContainerInspectorPlugin;
private TagInspectorPlugin? _tagInspectorPlugin;
private AttributeSetInspectorPlugin? _attributeSetInspectorPlugin;
private CueHandlerInspectorPlugin? _cueHandlerInspectorPlugin;
private AttributeEditorPlugin? _attributeEditorPlugin;
public override void _EnterTree()
{
PackedScene pluginScene = ResourceLoader.Load<PackedScene>(PluginScenePath);
_editorDock = new EditorDock
{
Title = "Forge",
DockIcon = GD.Load<Texture2D>("uid://cu6ncpuumjo20"),
DefaultSlot = EditorDock.DockSlot.RightUl,
};
_dockedScene = (PanelContainer)pluginScene.Instantiate();
_dockedScene.GetNode<TagsEditor>("%Tags").IsPluginInstance = true;
_editorDock.AddChild(_dockedScene);
AddDock(_editorDock);
_tagContainerInspectorPlugin = new TagContainerInspectorPlugin();
AddInspectorPlugin(_tagContainerInspectorPlugin);
_tagInspectorPlugin = new TagInspectorPlugin();
AddInspectorPlugin(_tagInspectorPlugin);
_attributeSetInspectorPlugin = new AttributeSetInspectorPlugin();
AddInspectorPlugin(_attributeSetInspectorPlugin);
_cueHandlerInspectorPlugin = new CueHandlerInspectorPlugin();
AddInspectorPlugin(_cueHandlerInspectorPlugin);
_attributeEditorPlugin = new AttributeEditorPlugin();
AddInspectorPlugin(_attributeEditorPlugin);
AddToolMenuItem("Repair assets tags", new Callable(this, MethodName.CallAssetRepairTool));
}
public override void _ExitTree()
{
Debug.Assert(_editorDock is not null, $"{nameof(_editorDock)} should have been initialized on _Ready().");
Debug.Assert(_dockedScene is not null, $"{nameof(_dockedScene)} should have been initialized on _Ready().");
RemoveDock(_editorDock);
_editorDock.QueueFree();
_dockedScene.Free();
RemoveInspectorPlugin(_tagContainerInspectorPlugin);
RemoveInspectorPlugin(_tagInspectorPlugin);
RemoveInspectorPlugin(_attributeSetInspectorPlugin);
RemoveInspectorPlugin(_cueHandlerInspectorPlugin);
RemoveInspectorPlugin(_attributeEditorPlugin);
RemoveToolMenuItem("Repair assets tags");
}
public override void _EnablePlugin()
{
base._EnablePlugin();
var config = ProjectSettings.LoadResourcePack(AutoloadPath);
if (config)
{
GD.PrintErr("Failed to load script at res://addons/forge/core/ForgeBootstrap.cs");
return;
}
if (!ProjectSettings.HasSetting("autoload/Forge Bootstrap"))
{
ProjectSettings.SetSetting("autoload/Forge Bootstrap", AutoloadPath);
ProjectSettings.Save();
}
}
public override void _DisablePlugin()
{
if (ProjectSettings.HasSetting("autoload/Forge Bootstrap"))
{
ProjectSettings.Clear("autoload/Forge Bootstrap");
ProjectSettings.Save();
}
}
private static void CallAssetRepairTool()
{
AssetRepairTool.RepairAllAssetsTags();
}
}
#endif