Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions AssetEditor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetEditorUpdater", "Asset
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetEditorTests", "Testing\AssetEditorTests\AssetEditorTests.csproj", "{4E51AFDA-E5D2-9D14-22C8-F790FE265A65}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Ipc", "Ipc", "{60CD305C-A8D3-460D-9620-4B60E9BB0894}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editors.Ipc", "Editors\Ipc\IpcEditor\Editors.Ipc.csproj", "{8F022F40-E780-42CD-BB81-D59E9DAFC111}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.Ipc", "Editors\Ipc\Test.Ipc\Test.Ipc.csproj", "{34E82457-C19B-4EEF-B901-0E7CF1D97BCE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -240,6 +246,14 @@ Global
{4E51AFDA-E5D2-9D14-22C8-F790FE265A65}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4E51AFDA-E5D2-9D14-22C8-F790FE265A65}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4E51AFDA-E5D2-9D14-22C8-F790FE265A65}.Release|Any CPU.Build.0 = Release|Any CPU
{8F022F40-E780-42CD-BB81-D59E9DAFC111}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8F022F40-E780-42CD-BB81-D59E9DAFC111}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8F022F40-E780-42CD-BB81-D59E9DAFC111}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8F022F40-E780-42CD-BB81-D59E9DAFC111}.Release|Any CPU.Build.0 = Release|Any CPU
{34E82457-C19B-4EEF-B901-0E7CF1D97BCE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{34E82457-C19B-4EEF-B901-0E7CF1D97BCE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{34E82457-C19B-4EEF-B901-0E7CF1D97BCE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{34E82457-C19B-4EEF-B901-0E7CF1D97BCE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -286,6 +300,9 @@ Global
{0FCE7A0E-6478-A603-6491-6FE675F54000} = {3123DC8F-5FAD-45A9-8DCC-7C5E0E61FAEB}
{E759BE6D-E0A4-46B8-A02A-E8573F579E2F} = {3123DC8F-5FAD-45A9-8DCC-7C5E0E61FAEB}
{4E51AFDA-E5D2-9D14-22C8-F790FE265A65} = {18424B6A-CB8A-4CE1-935C-72459F31521B}
{60CD305C-A8D3-460D-9620-4B60E9BB0894} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{8F022F40-E780-42CD-BB81-D59E9DAFC111} = {60CD305C-A8D3-460D-9620-4B60E9BB0894}
{34E82457-C19B-4EEF-B901-0E7CF1D97BCE} = {60CD305C-A8D3-460D-9620-4B60E9BB0894}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB5968F3-98ED-4AFF-98EA-0DBEDCACADF2}
Expand Down
2 changes: 1 addition & 1 deletion AssetEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
using System.Windows;
using System.Windows.Threading;
using AssetEditor.Services;
using AssetEditor.Services.Ipc;
using AssetEditor.UiCommands;
using AssetEditor.ViewModels;
using AssetEditor.Views;
using CommunityToolkit.Diagnostics;
using Editors.Ipc;
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.DependencyInjection;
using Shared.Core.DevConfig;
Expand Down
1 change: 1 addition & 0 deletions AssetEditor/AssetEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
<ProjectReference Include="..\Editors\AnimationReTarget\Editors.AnimatioReTarget\Editors.AnimatioReTarget.csproj" />
<ProjectReference Include="..\Editors\Audio\Editors.Audio.csproj" />
<ProjectReference Include="..\Editors\ImportExportEditor\Editors.ImportExport\Editors.ImportExport.csproj" />
<ProjectReference Include="..\Editors\Ipc\IpcEditor\Editors.Ipc.csproj" />
<ProjectReference Include="..\Editors\Kitbashing\KitbasherEditor\Editors.KitbasherEditor.csproj" />
<ProjectReference Include="..\Editors\MetaDataEditor\AnimationMeta\Editors.AnimationMeta.csproj" />
<ProjectReference Include="..\Editors\Reports\Editors.Reports.csproj" />
Expand Down
7 changes: 0 additions & 7 deletions AssetEditor/DependencyInjectionContainer.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using AssetEditor.Services;
using AssetEditor.Services.Ipc;
using AssetEditor.UiCommands;
using AssetEditor.ViewModels;
using AssetEditor.Views;
Expand Down Expand Up @@ -31,12 +30,6 @@ public override void Register(IServiceCollection serviceCollection)
serviceCollection.AddTransient<PrintScopesCommand>();
serviceCollection.AddTransient<OpenEditorCommand>();
serviceCollection.AddTransient<TogglePackFileExplorerCommand>();
serviceCollection.AddTransient<IExternalPackFileLookup, ExternalPackFileLookup>();
serviceCollection.AddTransient<IExternalPackLoader, ExternalPackLoader>();
serviceCollection.AddTransient<IIpcUserNotifier, IpcUserNotifier>();
serviceCollection.AddTransient<IExternalFileOpenExecutor, ExternalFileOpenExecutor>();
serviceCollection.AddTransient<IIpcRequestHandler, IpcRequestHandler>();
serviceCollection.AddSingleton<AssetEditorIpcServer>();

serviceCollection.AddTransient<SettingsWindow>();
serviceCollection.AddTransient<SettingsViewModel>();
Expand Down
1 change: 1 addition & 0 deletions AssetEditor/Services/DependencyInjectionConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public DependencyInjectionConfig(bool loadResources = true)
new Editor.VisualSkeletonEditor.DependencyInjectionContainer(),
new Editors.AnimatioReTarget.DependencyInjectionContainer(),
new Editors.Twui.DependencyInjectionContainer(),
new Editors.Ipc.DependencyInjectionContainer(),

// Host application
new DependencyInjectionContainer(),
Expand Down
23 changes: 8 additions & 15 deletions AssetEditor/Services/EditorManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,6 @@

namespace AssetEditor.Services
{
public interface IEditorManager : IEditorCreator
{
IList<IEditorInterface> GetAllEditors();
int GetCurrentEditor();

public void CloseTool(IEditorInterface tool);
public bool ShouldBlockCloseCommand(IEditorInterface editor, bool hasUnsavedFiles);

public void CloseOtherTools(IEditorInterface tool);
public void CloseAllTools(IEditorInterface tool);
public void CloseToolsToLeft(IEditorInterface tool);
public void CloseToolsToRight(IEditorInterface tool);
public bool Drop(IEditorInterface node, IEditorInterface targetNode = default, bool insertAfterTargetNode = default);
}

public partial class EditorManager : ObservableObject, IEditorManager
{
private readonly ILogger _logger = Logging.Create<EditorManager>();
Expand All @@ -51,6 +36,14 @@ public EditorManager(IGlobalEventHub eventHub, IPackFileService packFileService,

public IList<IEditorInterface> GetAllEditors() => CurrentEditorsList;
public int GetCurrentEditor() => SelectedEditorIndex;

public void SetEditorAsCurrent(IEditorInterface editor)
{
var index = CurrentEditorsList.IndexOf(editor);
if (index >= 0)
SelectedEditorIndex = index;
}

public IEditorInterface CreateFromFile(PackFile file, EditorEnums? preferedEditor)
{
if (file == null)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
using System;
using System.IO;
using System.IO.Pipes;
using System.IO.Pipes;
using System.Text;
using System.Text.Json;
using System.Text.Json.Serialization;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.DependencyInjection;
using Serilog;
using Shared.Core.ErrorHandling;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class AssetEditorIpcServer : IDisposable
{
Expand Down
24 changes: 24 additions & 0 deletions Editors/Ipc/IpcEditor/DependencyInjectionContainer.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.DependencyInjection;
using Shared.Core.ToolCreation;

namespace Editors.Ipc
{
public class DependencyInjectionContainer : DependencyContainer
{
public override void Register(IServiceCollection serviceCollection)
{
serviceCollection.AddTransient<IExternalPackFileLookup, ExternalPackFileLookup>();
serviceCollection.AddTransient<IExternalPackLoader, ExternalPackLoader>();
serviceCollection.AddTransient<IIpcUserNotifier, IpcUserNotifier>();
serviceCollection.AddTransient<IExternalFileOpenExecutor, ExternalFileOpenExecutor>();
serviceCollection.AddTransient<IIpcRequestHandler, IpcRequestHandler>();
serviceCollection.AddSingleton<AssetEditorIpcServer>();
}

public override void RegisterTools(IEditorDatabase factory)
{

}
}
}
16 changes: 16 additions & 0 deletions Editors/Ipc/IpcEditor/Editors.Ipc.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\Shared\SharedCore\Shared.Core.csproj" />
<ProjectReference Include="..\..\Kitbashing\KitbasherEditor\Editors.KitbasherEditor.csproj" />
</ItemGroup>



</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using Shared.Core.PackFiles.Models;
using Shared.Core.ToolCreation;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class ExternalFileOpenExecutor : IExternalFileOpenExecutor
{
Expand Down Expand Up @@ -106,12 +106,10 @@ private bool TryImportIntoExistingKitbash(PackFile file)

private void SelectEditor(IEditorInterface editor)
{
if (_editorManager is not EditorManager concreteEditorManager)
if (_editorManager is not IEditorManager concreteEditorManager)
return;

var index = concreteEditorManager.CurrentEditorsList.IndexOf(editor);
if (index >= 0)
concreteEditorManager.SelectedEditorIndex = index;
_editorManager.SetEditorAsCurrent(editor);
}

public static bool ShouldForceKitbash(PackFile file)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Shared.Core.PackFiles;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Models;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class ExternalPackFileLookup : IExternalPackFileLookup
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
using System;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
using Serilog;
using Shared.Core.ErrorHandling;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Utility;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class ExternalPackLoader : IExternalPackLoader
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Models;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public interface IExternalFileOpenExecutor
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Threading;
using System.Threading.Tasks;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Models;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public interface IIpcRequestHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class IpcRequest
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Threading;
using System.Threading.Tasks;
using Serilog;
using Serilog;
using Shared.Core.ErrorHandling;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class IpcRequestHandler : IIpcRequestHandler
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class IpcResponse
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows;
using Shared.Core.Services;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public class IpcUserNotifier : IIpcUserNotifier
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;

namespace AssetEditor.Services.Ipc
namespace Editors.Ipc
{
public static class PackPathResolver
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,59 @@
using AssetEditor.Services.Ipc;
using Editors.Ipc;
using Shared.Core.PackFiles.Models;

namespace AssetEditorTests.Ipc
namespace Test.Ipc
{
[TestClass]

public class ExternalFileOpenExecutorTests
{
[TestMethod]
[Test]
public void ShouldForceKitbash_ReturnsTrue_ForWsmodel()
{
var file = PackFile.CreateFromBytes("arb_base_elephant_1.wsmodel", []);

var result = ExternalFileOpenExecutor.ShouldForceKitbash(file);

Assert.IsTrue(result);
Assert.That(result, Is.True);
}

[TestMethod]
[Test]
public void ShouldForceKitbash_ReturnsTrue_ForVariantMeshDefinition()
{
var file = PackFile.CreateFromBytes("arb_base_elephant.variantmeshdefinition", []);

var result = ExternalFileOpenExecutor.ShouldForceKitbash(file);

Assert.IsTrue(result);
Assert.That(result, Is.True);
}

[TestMethod]
[Test]
public void ShouldForceKitbash_ReturnsFalse_ForRigidModel()
{
var file = PackFile.CreateFromBytes("arb_base_elephant.rigid_model_v2", []);

var result = ExternalFileOpenExecutor.ShouldForceKitbash(file);

Assert.IsFalse(result);
Assert.That(result, Is.False);
}

[TestMethod]
[Test]
public void CanImportIntoKitbash_ReturnsTrue_ForRigidModel()
{
var file = PackFile.CreateFromBytes("arb_base_elephant.rigid_model_v2", []);

var result = ExternalFileOpenExecutor.CanImportIntoKitbash(file);

Assert.IsTrue(result);
Assert.That(result, Is.True);
}

[TestMethod]
[Test]
public void CanImportIntoKitbash_ReturnsFalse_ForUnsupportedFile()
{
var file = PackFile.CreateFromBytes("something.anim", []);

var result = ExternalFileOpenExecutor.CanImportIntoKitbash(file);

Assert.IsFalse(result);
Assert.That(result, Is.False);
}
}
}
Loading
Loading