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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
23 changes: 19 additions & 4 deletions AssetEditor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,14 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Bmd", "Bmd", "{1D70E263-412
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editors.BmdEditor", "Editors\BmdEditor\Editors.BmdEditor.csproj", "{9CFEEAF2-8260-F2F5-50FB-8FDA9BD12CF9}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CampaignAnimationCreator", "CampaignAnimationCreator", "{97B5B2CE-D2E8-68AD-DABB-9986A92AD539}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CampaignAnimationCreator", "CampaignAnimationCreator", "{ED432A81-F5C7-0469-2ED7-3AF47D036060}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editor.CampaignAnimationCreator", "Editors\CampaignAnimationCreator\Editor.CampaignAnimationCreator\Editor.CampaignAnimationCreator.csproj", "{438E6F1B-F5A9-49F3-8516-CB5E9D316C81}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test.CampaignAnimationCreator", "Editors\CampaignAnimationCreator\Test.CampaignAnimationCreator\Test.CampaignAnimationCreator.csproj", "{91617891-AD16-423F-B56F-AC0D2CE82B95}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.CoreLog", "Shared\Logging\Shared.Core.Logging\Shared.CoreLog.csproj", "{C79EDB14-ED00-4474-B59F-9EED0AF39459}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -590,6 +592,18 @@ Global
{91617891-AD16-423F-B56F-AC0D2CE82B95}.Release|x64.Build.0 = Release|Any CPU
{91617891-AD16-423F-B56F-AC0D2CE82B95}.Release|x86.ActiveCfg = Release|Any CPU
{91617891-AD16-423F-B56F-AC0D2CE82B95}.Release|x86.Build.0 = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|x64.ActiveCfg = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|x64.Build.0 = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|x86.ActiveCfg = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Debug|x86.Build.0 = Debug|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|Any CPU.Build.0 = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|x64.ActiveCfg = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|x64.Build.0 = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|x86.ActiveCfg = Release|Any CPU
{C79EDB14-ED00-4474-B59F-9EED0AF39459}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -644,9 +658,10 @@ Global
{BB9F2AC1-680E-4289-B212-88744460383E} = {D84249ED-B24C-F001-6275-6713CC04DE13}
{1D70E263-4123-4F00-A6AB-A42611732697} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{9CFEEAF2-8260-F2F5-50FB-8FDA9BD12CF9} = {1D70E263-4123-4F00-A6AB-A42611732697}
{97B5B2CE-D2E8-68AD-DABB-9986A92AD539} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{438E6F1B-F5A9-49F3-8516-CB5E9D316C81} = {97B5B2CE-D2E8-68AD-DABB-9986A92AD539}
{91617891-AD16-423F-B56F-AC0D2CE82B95} = {97B5B2CE-D2E8-68AD-DABB-9986A92AD539}
{ED432A81-F5C7-0469-2ED7-3AF47D036060} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{438E6F1B-F5A9-49F3-8516-CB5E9D316C81} = {ED432A81-F5C7-0469-2ED7-3AF47D036060}
{91617891-AD16-423F-B56F-AC0D2CE82B95} = {ED432A81-F5C7-0469-2ED7-3AF47D036060}
{C79EDB14-ED00-4474-B59F-9EED0AF39459} = {58F19D12-FE6E-A99A-941B-96C21567964E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB5968F3-98ED-4AFF-98EA-0DBEDCACADF2}
Expand Down
10 changes: 5 additions & 5 deletions AssetEditor/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Diagnostics;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Windows;
using System.Windows.Threading;
using AssetEditor.Services;
Expand All @@ -10,14 +8,16 @@
using CommunityToolkit.Diagnostics;
using Editors.Ipc;
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.DependencyInjection;
using Shared.Core.DevConfig;
using Shared.Core.ErrorHandling;
using Shared.Core.Events;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.ErrorHandling;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Utility;
using Shared.Core.Services;
using Shared.Core.Settings;
using Shared.Core.ToolCreation;
using Shared.Ui.Common;

namespace AssetEditor
Expand Down Expand Up @@ -100,7 +100,7 @@ private void LoadCAPackFiles(ApplicationSettingsService settingsService)
{
var packfileService = _serviceProvider.GetRequiredService<IPackFileService>();
var containerLoader = _serviceProvider.GetRequiredService<IPackFileContainerLoader>();
var loadRes = containerLoader.CreateFromGameEnum(PackFileContainerType.Cached, settingsService.CurrentSettings.CurrentGame);
var loadRes = containerLoader.CreateFromGameEnum(PackFileContainerType.Database, settingsService.CurrentSettings.CurrentGame);

if (loadRes == null)
MessageBox.Show($"Unable to load all CA packfiles in {gamePath}");
Expand Down
8 changes: 6 additions & 2 deletions AssetEditor/DependencyInjectionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
using AssetEditor.Views.Settings;
using AssetEditor.Views.Updater;
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.Commands;
using Shared.Core.DependencyInjection;
using Shared.Core.DevConfig;
using Shared.Core.ErrorHandling.Exceptions;
using Shared.Core.Events.Global;
using Shared.Core.ToolCreation;

namespace AssetEditor
Expand All @@ -21,8 +21,11 @@ public override void Register(IServiceCollection serviceCollection)
serviceCollection.AddScoped<MainViewModel>();
serviceCollection.AddSingleton<IEditorManager, EditorManager>();

serviceCollection.AddTransient<CreateNewProjectCommand>();
serviceCollection.AddTransient<OpenGamePackCommand>();
serviceCollection.AddTransient<OpenPackFileCommand>();
serviceCollection.AddTransient<ImportPackAsAsProjectCommand>();
serviceCollection.AddTransient<ImportReferencePackCommand>();
serviceCollection.AddTransient<OpenProjectCommand>();
serviceCollection.AddTransient<OpenSettingsDialogCommand>();
serviceCollection.AddTransient<OpenUpdaterWindowCommand>();
serviceCollection.AddTransient<OpenWebpageCommand>();
Expand All @@ -40,6 +43,7 @@ public override void Register(IServiceCollection serviceCollection)
serviceCollection.AddScoped<MainWindow>();

serviceCollection.AddSingleton<RecentFilesTracker>();
serviceCollection.AddSingleton<TouchedFilesRecorder>();

serviceCollection.AddScoped<IExceptionInformationProvider, CurrentEditorExceptionInfoProvider>();

Expand Down
2 changes: 2 additions & 0 deletions AssetEditor/GlobalUsings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
global using Shared.CoreLog;
global using Serilog;
6 changes: 4 additions & 2 deletions AssetEditor/Language_En.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,13 @@
"SettingsWindow.GameDataPathHint": "Browse for game data location e.g. \"C:\\SteamLibrary\\steamapps\\common\\Total War WARHAMMER III\\data\"",

"MenuBar.File": "_File",
"MenuBar.File.NewPack": "New Pack",
"MenuBar.File.NewPack": "New Project/Pack",
"MenuBar.File.NewAnimPackWh3": "New AnimPack (Warhammer III)",
"MenuBar.File.NewAnimPack3K": "New AnimPack (Three Kingdoms)",
"MenuBar.File.SaveActivePack": "Save active pack",
"MenuBar.File.OpenPack": "Open Pack",
"MenuBar.File.OpenProjectFolder": "Open Project",
"MenuBar.File.ImportPackAsProject": "Import Pack as project",
"MenuBar.File.ImportReferencePack": "Import reference project",
"MenuBar.File.OpenRecentPacks": "Open Recent Packs",
"MenuBar.File.OpenGamePacks": "Open Game Packs",
"MenuBar.File.GameAttila": "Attila",
Expand Down
7 changes: 3 additions & 4 deletions AssetEditor/Services/DependencyInjectionConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection;
using Shared.Core.DependencyInjection;
using Shared.Core.ErrorHandling;
using Shared.Core.Misc;
using Shared.Core.ToolCreation;

namespace AssetEditor.Services
Expand Down Expand Up @@ -69,7 +68,7 @@ public IServiceProvider Build(bool forceValidateServiceScopes, Action<IServiceCo

private void ConfigureServices(IServiceCollection services, Action<IServiceCollection> replaceServices)
{
Logging.Configure(Serilog.Events.LogEventLevel.Information);
Logging.Configure(Serilog.Events.LogEventLevel.Information, DirectoryHelper.LogDirectory);

foreach (var container in _dependencyContainers)
container.Register(services);
Expand Down
8 changes: 2 additions & 6 deletions AssetEditor/Services/EditorManager.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Collections.ObjectModel;
using System.Windows;
using System.Windows.Controls;
using CommunityToolkit.Mvvm.ComponentModel;
using Serilog;
using Shared.Core.ErrorHandling;
using Shared.Core.Events;
using Shared.Core.Events.Global;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Events;
using Shared.Core.PackFiles.Models;
using Shared.Core.ToolCreation;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using GameWorld.Core.Services;
using Shared.Core.DependencyInjection;
using Shared.Core.ErrorHandling.Exceptions;
using Shared.Core.ToolCreation;

Expand Down
4 changes: 2 additions & 2 deletions AssetEditor/Services/RecentFilesTracker.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using System;
using Shared.Core.Events;
using Shared.Core.Events.Global;
using Shared.Core.PackFiles.Events;
using Shared.Core.Settings;

namespace AssetEditor.Services
Expand All @@ -25,7 +25,7 @@ private void Handler(PackFileContainerAddedEvent e)
if (string.IsNullOrEmpty(e.Container.SystemFilePath))
return;

_applicationSettingsService.AddRecentlyOpenedPackFile(e.Container.SystemFilePath);
_applicationSettingsService.AddRecentlyOpenedPackFile(e.Container.SystemFilePath, e.Container.ContainerType, e.Container.IsReadOnly);
_applicationSettingsService.Save();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
using Shared.Core.ErrorHandling;
using Shared.Core.Events;
using Shared.Core.Events.Global;
using Shared.Core.Events;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Events;
using Shared.Core.PackFiles.Models;
using Shared.Core.Settings;

namespace Shared.Core.Services
namespace AssetEditor.Services
{
public class TouchedFilesRecorder
{
Expand Down
5 changes: 1 addition & 4 deletions AssetEditor/Themes/Controls.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
using System;
using System.Diagnostics;
using System.Diagnostics;
using System.IO;
using System.Windows;
using Serilog;
using Shared.Core.ErrorHandling;
using WindowHandling;

namespace AssetEditor.Themes
Expand Down
42 changes: 42 additions & 0 deletions AssetEditor/UiCommands/CreateNewProjectCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using CommonControls.BaseDialogs;
using Shared.Core.Events;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Utility;
using Shared.Core.Services;

namespace AssetEditor.UiCommands
{
public class CreateNewProjectCommand : IAeCommand
{
private readonly IPackFileService _packFileService;
private readonly IStandardDialogs _standardDialogs;
private readonly ISystemFolderContainerFactory _systemFolderContainerFactory;

public CreateNewProjectCommand(
IPackFileService packFileService,
IStandardDialogs standardDialogs,
ISystemFolderContainerFactory systemFolderContainerFactory)
{
_packFileService = packFileService;
_standardDialogs = standardDialogs;
_systemFolderContainerFactory = systemFolderContainerFactory;
}

public void Execute()
{
var window = new NewPackFileWindow();
if (window.ShowDialog() != true)
return;

if (string.IsNullOrWhiteSpace(window.SelectedFolderPath))
{
_standardDialogs.ShowDialogBox("No folder was selected", "Error");
return;
}

var folderPack = _systemFolderContainerFactory.Create(window.SelectedFolderPath);
_packFileService.AddContainer(folderPack);
_packFileService.SetEditablePack(folderPack);
}
}
}
76 changes: 76 additions & 0 deletions AssetEditor/UiCommands/ImportPackAsAsProjectCommand.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System.IO;
using System.Windows.Forms;
using Shared.Core.Events;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Utility;
using Shared.Core.Services;

namespace AssetEditor.UiCommands
{
public class ImportPackAsAsProjectCommand : IAeCommand
{
private readonly IPackFileService _packFileService;
private readonly IPackFileContainerLoader _packFileContainerLoader;
private readonly ISystemFolderContainerFactory _systemFolderContainerFactory;
private readonly IStandardDialogs _standardDialogs;

public ImportPackAsAsProjectCommand(
IPackFileService packFileService,
IPackFileContainerLoader packFileContainerLoader,
ISystemFolderContainerFactory systemFolderContainerFactory,
IStandardDialogs standardDialogs)
{
_packFileService = packFileService;
_packFileContainerLoader = packFileContainerLoader;
_systemFolderContainerFactory = systemFolderContainerFactory;
_standardDialogs = standardDialogs;
}

public void Execute()
{
// Step 1: Select the .pack file
using var packDialog = new OpenFileDialog
{
Filter = "Pack files (*.pack)|*.pack|All files (*.*)|*.*",
Title = "Select pack file to convert"
};

if (packDialog.ShowDialog() != DialogResult.OK)
return;

// Step 2: Select destination folder
using var folderDialog = new FolderBrowserDialog
{
Description = "Select destination folder for extracted files",
UseDescriptionForTitle = true
};

if (folderDialog.ShowDialog() != DialogResult.OK)
return;

var destinationFolder = folderDialog.SelectedPath;

// Step 3: Load the pack and extract all files to the destination
var packContainer = _packFileContainerLoader.CreateFromPackFile(PackFileContainerType.Normal, packDialog.FileName, false);
var allFiles = packContainer.GetAllFiles();

foreach (var (relativePath, packFile) in allFiles)
{
var absolutePath = Path.Combine(destinationFolder, relativePath);
var directory = Path.GetDirectoryName(absolutePath);
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
Directory.CreateDirectory(directory);

var data = packFile.DataSource.ReadData();
File.WriteAllBytes(absolutePath, data);
}

// Step 4: Open the extracted folder as a SystemFolderContainer
var systemContainer = _systemFolderContainerFactory.Create(destinationFolder);
_packFileService.AddContainer(systemContainer);
_packFileService.SetEditablePack(systemContainer);

}
}
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,42 @@
using System.Windows.Forms;
using Shared.Core.Events;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Models;
using Shared.Core.PackFiles.Utility;
using Shared.Core.Services;

namespace AssetEditor.UiCommands
{
public class OpenPackFileCommand : IAeCommand
public class ImportReferencePackCommand : IAeCommand
{
private readonly IPackFileService _packFileService;
private readonly IPackFileContainerLoader _packFileContainerLoader;
private readonly ISystemFolderContainerFactory _systemFolderContainerFactory;
private readonly IStandardDialogs _standardDialogs;

public OpenPackFileCommand(IPackFileService packFileService, IPackFileContainerLoader packFileContainerLoader)
public ImportReferencePackCommand(
IPackFileService packFileService,
IPackFileContainerLoader packFileContainerLoader,
ISystemFolderContainerFactory systemFolderContainerFactory,
IStandardDialogs standardDialogs)
{
_packFileService = packFileService;
_packFileContainerLoader = packFileContainerLoader;
_systemFolderContainerFactory = systemFolderContainerFactory;
_standardDialogs = standardDialogs;
}

public void Execute()
{
var dialog = new OpenFileDialog()
using var dialog = new OpenFileDialog
{
Filter = "Pack files (*.pack)|*.pack|All files (*.*)|*.*"
};

if (dialog.ShowDialog() != DialogResult.OK)
return;
var container = _packFileContainerLoader.CreateFromPackFile(PackFileContainerType.Normal, dialog.FileName, false);

var container = _packFileContainerLoader.CreateFromPackFile(PackFileContainerType.Normal, dialog.FileName, true);
_packFileService.AddContainer(container, true);
}
}
Expand Down
Loading
Loading