update forge
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
|
||||
#if TOOLS
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Gamesmiths.Forge.Core;
|
||||
using Gamesmiths.Forge.Godot.Core;
|
||||
using Gamesmiths.Forge.Godot.Editor;
|
||||
@@ -69,31 +68,35 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
|
||||
public override void _ExitTree()
|
||||
{
|
||||
Debug.Assert(
|
||||
_tagsEditorDock is not null,
|
||||
$"{nameof(_tagsEditorDock)} should have been initialized on _Ready().");
|
||||
Debug.Assert(
|
||||
_statescriptGraphEditorDock is not null,
|
||||
$"{nameof(_statescriptGraphEditorDock)} should have been initialized on _Ready().");
|
||||
|
||||
if (_fileSystem?.IsConnected(EditorFileSystem.SignalName.ResourcesReimported, _resourcesReimportedCallable)
|
||||
== true)
|
||||
{
|
||||
_fileSystem.Disconnect(EditorFileSystem.SignalName.ResourcesReimported, _resourcesReimportedCallable);
|
||||
}
|
||||
|
||||
RemoveDock(_tagsEditorDock);
|
||||
_tagsEditorDock.Free();
|
||||
if (_tagsEditorDock is not null)
|
||||
{
|
||||
RemoveDock(_tagsEditorDock);
|
||||
_tagsEditorDock.Free();
|
||||
_tagsEditorDock = null;
|
||||
}
|
||||
|
||||
RemoveInspectorPlugin(_tagContainerInspectorPlugin);
|
||||
RemoveInspectorPlugin(_tagInspectorPlugin);
|
||||
RemoveInspectorPlugin(_attributeSetInspectorPlugin);
|
||||
RemoveInspectorPlugin(_cueHandlerInspectorPlugin);
|
||||
RemoveInspectorPlugin(_attributeEditorPlugin);
|
||||
RemoveInspectorPlugin(_sharedVariableSetInspectorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _tagContainerInspectorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _tagInspectorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _attributeSetInspectorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _cueHandlerInspectorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _attributeEditorPlugin);
|
||||
RemoveInspectorPluginAndRelease(ref _sharedVariableSetInspectorPlugin);
|
||||
|
||||
RemoveDock(_statescriptGraphEditorDock);
|
||||
_statescriptGraphEditorDock.Free();
|
||||
if (_statescriptGraphEditorDock is not null)
|
||||
{
|
||||
RemoveDock(_statescriptGraphEditorDock);
|
||||
_statescriptGraphEditorDock.Free();
|
||||
_statescriptGraphEditorDock = null;
|
||||
}
|
||||
|
||||
_fileSystem = null;
|
||||
_resourcesReimportedCallable = default;
|
||||
|
||||
RemoveToolMenuItem("Repair assets tags");
|
||||
}
|
||||
@@ -132,7 +135,7 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
|
||||
EnsureForgeDataExists();
|
||||
|
||||
var config = ProjectSettings.LoadResourcePack(AutoloadPath);
|
||||
bool config = ProjectSettings.LoadResourcePack(AutoloadPath);
|
||||
|
||||
if (config)
|
||||
{
|
||||
@@ -173,7 +176,7 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
return;
|
||||
}
|
||||
|
||||
var paths = _statescriptGraphEditorDock.GetOpenResourcePaths();
|
||||
string[] paths = _statescriptGraphEditorDock.GetOpenResourcePaths();
|
||||
|
||||
if (paths.Length == 0)
|
||||
{
|
||||
@@ -183,7 +186,7 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
configuration.SetValue("Forge", "open_tabs", string.Join(";", paths));
|
||||
configuration.SetValue("Forge", "active_tab", _statescriptGraphEditorDock.GetActiveTabIndex());
|
||||
|
||||
var varStates = _statescriptGraphEditorDock.GetVariablesPanelStates();
|
||||
bool[] varStates = _statescriptGraphEditorDock.GetVariablesPanelStates();
|
||||
configuration.SetValue("Forge", "variables_states", string.Join(";", varStates));
|
||||
}
|
||||
|
||||
@@ -197,26 +200,26 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
Variant tabsValue = configuration.GetValue("Forge", "open_tabs", string.Empty);
|
||||
Variant active = configuration.GetValue("Forge", "active_tab", -1);
|
||||
|
||||
var tabsString = tabsValue.AsString();
|
||||
string tabsString = tabsValue.AsString();
|
||||
if (string.IsNullOrEmpty(tabsString))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var paths = tabsString.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
var activeIndex = active.AsInt32();
|
||||
string[] paths = tabsString.Split(';', StringSplitOptions.RemoveEmptyEntries);
|
||||
int activeIndex = active.AsInt32();
|
||||
|
||||
bool[]? variablesStates = null;
|
||||
Variant varStatesValue = configuration.GetValue("Forge", "variables_states", string.Empty);
|
||||
var varString = varStatesValue.AsString();
|
||||
string varString = varStatesValue.AsString();
|
||||
|
||||
if (!string.IsNullOrEmpty(varString))
|
||||
{
|
||||
var parts = varString.Split(';');
|
||||
string[] parts = varString.Split(';');
|
||||
variablesStates = new bool[parts.Length];
|
||||
for (var i = 0; i < parts.Length; i++)
|
||||
for (int i = 0; i < parts.Length; i++)
|
||||
{
|
||||
variablesStates[i] = bool.TryParse(parts[i], out var v) && v;
|
||||
variablesStates[i] = bool.TryParse(parts[i], out bool v) && v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,16 +251,28 @@ public partial class ForgePluginLoader : EditorPlugin
|
||||
AssetRepairTool.RepairAllAssetsTags();
|
||||
}
|
||||
|
||||
private void RemoveInspectorPluginAndRelease<TPlugin>(ref TPlugin? plugin)
|
||||
where TPlugin : EditorInspectorPlugin
|
||||
{
|
||||
if (plugin is null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RemoveInspectorPlugin(plugin);
|
||||
plugin = null;
|
||||
}
|
||||
|
||||
private void OnResourcesReimported(string[] resources)
|
||||
{
|
||||
foreach (var path in resources)
|
||||
foreach (string path in resources)
|
||||
{
|
||||
if (!ResourceLoader.Exists(path))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var fileType = EditorInterface.Singleton.GetResourceFilesystem().GetFileType(path);
|
||||
string fileType = EditorInterface.Singleton.GetResourceFilesystem().GetFileType(path);
|
||||
if (fileType != "StatescriptGraph" && fileType != "Resource")
|
||||
{
|
||||
continue;
|
||||
|
||||
Reference in New Issue
Block a user