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: 10 additions & 7 deletions AssetEditor.sln
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{17E1BB
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Editors.Shared.Core", "Editors\Shared\Editors.Shared.Core\Editors.Shared.Core.csproj", "{C130109A-1D52-4F5E-A760-24AEF648CE93}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Editors.AnimationTextEditors", "Editors\SimpleAnimationEditors\Editors.AnimationTextEditors.csproj", "{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Editors.Reports", "Editors\Reports\Editors.Reports.csproj", "{EAFBC3D8-A146-4BA3-8024-DE4E20D3C884}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Editors.TextureEditor", "Editors\TextureEditor\Editors.TextureEditor.csproj", "{8E55B123-C8E5-4D65-AAAA-C4DC4713CB8E}"
Expand Down Expand Up @@ -92,6 +90,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.ByteParsing", "Share
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Shared.ByteParsingTest", "Shared\ByteParsing\Shared.ByteParsingTest\Shared.ByteParsingTest.csproj", "{328485AF-4B94-47CE-B9EF-5D267F9E3F74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "AnimationFragmentEditor", "AnimationFragmentEditor", "{9859545E-76FC-4790-AF99-E1BCB1D4739D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Editors.AnimationFragmentEditor", "Editors\AnimationFragmentEditor\Editor.AnimationFragmentEditor\Editors.AnimationFragmentEditor.csproj", "{37C9C29E-1353-1519-BBC0-D7827A8AF636}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -130,10 +132,6 @@ Global
{C130109A-1D52-4F5E-A760-24AEF648CE93}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C130109A-1D52-4F5E-A760-24AEF648CE93}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C130109A-1D52-4F5E-A760-24AEF648CE93}.Release|Any CPU.Build.0 = Release|Any CPU
{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B}.Release|Any CPU.Build.0 = Release|Any CPU
{EAFBC3D8-A146-4BA3-8024-DE4E20D3C884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{EAFBC3D8-A146-4BA3-8024-DE4E20D3C884}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAFBC3D8-A146-4BA3-8024-DE4E20D3C884}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -218,6 +216,10 @@ Global
{328485AF-4B94-47CE-B9EF-5D267F9E3F74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{328485AF-4B94-47CE-B9EF-5D267F9E3F74}.Release|Any CPU.ActiveCfg = Release|Any CPU
{328485AF-4B94-47CE-B9EF-5D267F9E3F74}.Release|Any CPU.Build.0 = Release|Any CPU
{37C9C29E-1353-1519-BBC0-D7827A8AF636}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{37C9C29E-1353-1519-BBC0-D7827A8AF636}.Debug|Any CPU.Build.0 = Debug|Any CPU
{37C9C29E-1353-1519-BBC0-D7827A8AF636}.Release|Any CPU.ActiveCfg = Release|Any CPU
{37C9C29E-1353-1519-BBC0-D7827A8AF636}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -231,7 +233,6 @@ Global
{13EB0C34-99A7-49B2-BA93-B93073A43F45} = {7070A990-1A62-46A9-ABDF-BE030E3A4336}
{17E1BB4D-00DF-4323-80C7-B8A8EDF2A5AA} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{C130109A-1D52-4F5E-A760-24AEF648CE93} = {17E1BB4D-00DF-4323-80C7-B8A8EDF2A5AA}
{CAEB33BF-48DF-4388-BE6B-7D7ABBB9414B} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{EAFBC3D8-A146-4BA3-8024-DE4E20D3C884} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{8E55B123-C8E5-4D65-AAAA-C4DC4713CB8E} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{410AC3F4-021C-4993-BCCA-1810D153075D} = {4D35FFE2-8490-4694-8981-654016F2BD3D}
Expand Down Expand Up @@ -260,6 +261,8 @@ Global
{786DB586-5DF5-4CF9-A485-A20A7BC184F7} = {7070A990-1A62-46A9-ABDF-BE030E3A4336}
{BE02D945-E70C-4A0E-A16D-8BFA3CB1A877} = {786DB586-5DF5-4CF9-A485-A20A7BC184F7}
{328485AF-4B94-47CE-B9EF-5D267F9E3F74} = {786DB586-5DF5-4CF9-A485-A20A7BC184F7}
{9859545E-76FC-4790-AF99-E1BCB1D4739D} = {07AC615B-A8FC-4E1A-BDD5-BC11452429A0}
{37C9C29E-1353-1519-BBC0-D7827A8AF636} = {9859545E-76FC-4790-AF99-E1BCB1D4739D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {AB5968F3-98ED-4AFF-98EA-0DBEDCACADF2}
Expand Down
1 change: 1 addition & 0 deletions AssetEditor/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public partial class App : Application
protected override void OnStartup(StartupEventArgs e)
{
ApplicationStateRecorder.Initialize();
PackFileLog.IsLoggingEnabled = false;

ShutdownMode = ShutdownMode.OnExplicitShutdown;
VersionChecker.CheckVersion();
Expand Down
1 change: 1 addition & 0 deletions AssetEditor/AssetEditor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

<ItemGroup>
<ProjectReference Include="..\Editors\AnimationEditor\Editors.AnimationVisualEditors.csproj" />
<ProjectReference Include="..\Editors\AnimationFragmentEditor\Editor.AnimationFragmentEditor\Editors.AnimationFragmentEditor.csproj" />
<ProjectReference Include="..\Editors\AnimationMeta\Editors.AnimationMeta.csproj" />
<ProjectReference Include="..\Editors\AnimationReTarget\Editors.AnimatioReTarget\Editors.AnimatioReTarget.csproj" />
<ProjectReference Include="..\Editors\Audio\Editors.Audio.csproj" />
Expand Down
5 changes: 5 additions & 0 deletions AssetEditor/Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@
"commandLineArgs": "-devcfg Kitbash_Karl",
"nativeDebugging": false
},
"AE-AnimPack_Wh3": {
"commandName": "Project",
"commandLineArgs": "-devcfg AnimPack_WH3",
"nativeDebugging": false
},
"AE-KitbashRat": {
"commandName": "Project",
"commandLineArgs": "-devcfg Kitbash_Rat",
Expand Down
2 changes: 1 addition & 1 deletion AssetEditor/Services/DependencyInjectionConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public DependencyInjectionConfig(bool loadResources = true)

// Domains
new Editors.Shared.Core.DependencyInjectionContainer(),
new Editors.AnimationTextEditors.DependencyInjectionContainer(),
new Editors.AnimationFragmentEditor.DependencyInjectionContainer(),
new Editors.Reports.DependencyInjectionContainer(),
new Editors.KitbasherEditor.DependencyInjectionContainer(),
new Editors.AnimationMeta.DependencyInjectionContainer(),
Expand Down
8 changes: 4 additions & 4 deletions AssetEditor/ViewModels/MenuBarViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
using System.Linq;
using AssetEditor.UiCommands;
using CommonControls.BaseDialogs;
using CommonControls.Editors.AnimationPack;
using CommunityToolkit.Mvvm.Input;
using Editors.AnimationFragmentEditor.AnimationPack.Commands;
using Editors.Reports.Animation;
using Editors.Reports.Audio;
using Editors.Reports.DeepSearch;
Expand Down Expand Up @@ -79,9 +79,9 @@ [RelayCommand] private void CreateNewPackFile()
_packfileService.SetEditablePack(newPackFile);
}
}

[RelayCommand] private void CreateAnimPackWarhammer3() => AnimationPackSampleDataCreator.CreateAnimationDbWarhammer3(_packFileSaveService, _packfileService);
[RelayCommand] private void CreateAnimPack3k() => AnimationPackSampleDataCreator.CreateAnimationDb3k(_packfileService, _packFileSaveService);
[RelayCommand] private void CreateAnimPackWarhammer3() => _uiCommandFactory.Create<CreateExampleAnimationDbCommand>().CreateAnimationDbWarhammer3();
[RelayCommand] private void CreateAnimPack3k() => _uiCommandFactory.Create<CreateExampleAnimationDbCommand>().CreateAnimationDb3k();
[RelayCommand] private void SaveActivePack() => _uiCommandFactory.Create<SavePackFileContainerCommand>().Execute();
[RelayCommand] private void OpenWh2AnimpackUpdater() => new AnimPackUpdaterService(_packfileService).Process();
[RelayCommand] private void GenerateRmv2Report() => _uiCommandFactory.Create<Rmv2ReportCommand>().Execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class BatchProcessorService
IAnimationBinGenericFormat _riderFragment;

uint _animationOutputFormat;
AnimationPackFile _outAnimPack;
AnimationPackFileDatabase _outAnimPack;
AnimationBinWh3 _riderOutputBin;


Expand Down Expand Up @@ -204,7 +204,7 @@ List<string> GetAnimationsThatRequireNoChanges()

void CreateAnimPackFile()
{
_outAnimPack = new AnimationPackFile("Placeholder");
_outAnimPack = new AnimationPackFileDatabase("Placeholder");
_riderOutputBin = new AnimationBinWh3(@"animations/database/battle/bin/" + _animBinName)
{
SkeletonName = _riderFragment.SkeletonName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Shared.GameFormats.Animation;
using Shared.Ui.Editors.TextEditor;

namespace CommonControls.Editors.AnimationFilePreviewEditor
namespace Editors.AnimationFragmentEditor.AnimationFilePreviewEditor
{
class AnimFileToTextConverter : ITextConverter
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using Shared.GameFormats.Animation;
using Shared.Ui.Editors.TextEditor;

namespace CommonControls.Editors.AnimationFilePreviewEditor
namespace Editors.AnimationFragmentEditor.AnimationFilePreviewEditor
{
public class InvMatrixToTextConverter : ITextConverter
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
using System.Windows;
using CommunityToolkit.Mvvm.Input;
using Editors.AnimationFragmentEditor.AnimationPack.Commands;
using Editors.AnimationFragmentEditor.AnimationPack.Converters.AnimationBinConverter;
using Editors.AnimationFragmentEditor.AnimationPack.Converters.AnimationBinWh3Converter;
using Editors.AnimationFragmentEditor.AnimationPack.Converters.AnimationFragmentConverter;
using GameWorld.Core.Services;
using Shared.Core.Events;
using Shared.Core.Misc;
using Shared.Core.PackFiles;
using Shared.Core.PackFiles.Models;
using Shared.Core.Services;
using Shared.Core.Settings;
using Shared.Core.ToolCreation;
using Shared.GameFormats.AnimationMeta.Parsing;
using Shared.GameFormats.AnimationPack;
using Shared.GameFormats.AnimationPack.AnimPackFileTypes;
using Shared.GameFormats.AnimationPack.AnimPackFileTypes.Wh3;
using Shared.Ui.Common;
using Shared.Ui.Editors.TextEditor;

namespace CommonControls.Editors.AnimationPack
{
public partial class AnimPackViewModel : NotifyPropertyChangedImpl, IEditorInterface, ISaveableEditor, IFileEditor
{
private readonly IUiCommandFactory _uiCommandFactory;
private readonly IPackFileService _pfs;
private readonly ISkeletonAnimationLookUpHelper _skeletonAnimationLookUpHelper;
private ITextConverter? _activeConverter;
private readonly ApplicationSettingsService _appSettings;
private readonly IFileSaveService _packFileSaveService;
private readonly MetaDataTagDeSerializer _metaDataTagDeSerializer;

public string DisplayName { get; set; } = "Not set";

PackFile _packFile;

public FilterCollection<IAnimationPackFile> AnimationPackItems { get; set; }

SimpleTextEditorViewModel _selectedItemViewModel;
public SimpleTextEditorViewModel SelectedItemViewModel { get => _selectedItemViewModel; set => SetAndNotify(ref _selectedItemViewModel, value); }

public AnimPackViewModel(IUiCommandFactory uiCommandFactory, IPackFileService pfs, ISkeletonAnimationLookUpHelper skeletonAnimationLookUpHelper, ApplicationSettingsService appSettings, IFileSaveService packFileSaveService, MetaDataTagDeSerializer metaDataTagDeSerializer)
{
_uiCommandFactory = uiCommandFactory;
_pfs = pfs;
_skeletonAnimationLookUpHelper = skeletonAnimationLookUpHelper;
_appSettings = appSettings;
_packFileSaveService = packFileSaveService;
_metaDataTagDeSerializer = metaDataTagDeSerializer;

AnimationPackItems = new FilterCollection<IAnimationPackFile>(new List<IAnimationPackFile>(), OnItemSelected, BeforeItemSelected)
{
SearchFilter = (value, rx) => { return rx.Match(value.FileName).Success; }
};
}

[RelayCommand] private void RenameAction() => _uiCommandFactory.Create<RenameSelectedFileCommand>().Execute(this);
[RelayCommand] private void RemoveAction() => _uiCommandFactory.Create<RemoveSelectedFileCommand>().Execute(this);
[RelayCommand] private void CopyFullPathAction() => Clipboard.SetText(AnimationPackItems.SelectedItem.FileName);
[RelayCommand] private void CreateEmptyWarhammer3AnimSetFileAction() => _uiCommandFactory.Create<CreateEmptyWarhammer3AnimSetFileCommand>().Execute(this);
[RelayCommand] private void ExportAnimationSlotsWh3Action() => _uiCommandFactory.Create<ExportAnimationSlotCommand>().Warhammer3();
[RelayCommand] private void ExportAnimationSlotsWh2Action() => _uiCommandFactory.Create<ExportAnimationSlotCommand>().Warhammer2();

bool BeforeItemSelected(IAnimationPackFile item)
{
if (SelectedItemViewModel != null && SelectedItemViewModel.HasUnsavedChanges())
{
if (MessageBox.Show("Editor has unsaved changes that will be lost.\nContinue?", "", MessageBoxButton.YesNo) == MessageBoxResult.No)
return false;
}

return true;
}

void OnItemSelected(IAnimationPackFile seletedFile)
{
_activeConverter = null;
if (seletedFile is AnimationFragmentFile typedFragment)
_activeConverter = new AnimationFragmentFileToXmlConverter(_skeletonAnimationLookUpHelper, _appSettings.CurrentSettings.CurrentGame);
else if (seletedFile is AnimationBin typedBin)
_activeConverter = new AnimationBinFileToXmlConverter();
else if (seletedFile is AnimationBinWh3 wh3Bin)
_activeConverter = new AnimationBinWh3FileToXmlConverter(_skeletonAnimationLookUpHelper, _metaDataTagDeSerializer, CurrentFile);

if (seletedFile == null || _activeConverter == null || seletedFile.IsUnknownFile)
{
SelectedItemViewModel = new SimpleTextEditorViewModel();
SelectedItemViewModel.SaveCommand = null;
SelectedItemViewModel.TextEditor?.ShowLineNumbers(true);
SelectedItemViewModel.TextEditor?.SetSyntaxHighlighting("XML");
SelectedItemViewModel.Text = "";
SelectedItemViewModel.ResetChangeLog();
}
else
{
SelectedItemViewModel = new SimpleTextEditorViewModel();
SelectedItemViewModel.SaveCommand = new RelayCommand(() => SaveActiveFile());
SelectedItemViewModel.TextEditor?.ShowLineNumbers(true);
SelectedItemViewModel.TextEditor?.SetSyntaxHighlighting(_activeConverter.GetSyntaxType());
SelectedItemViewModel.Text = _activeConverter.GetText(seletedFile.ToByteArray());
SelectedItemViewModel.ResetChangeLog();
}

}
public void Close() { }
public bool HasUnsavedChanges { get; set; }

public PackFile CurrentFile => _packFile;

public bool SaveActiveFile()
{
if (_packFile == null)
{
MessageBox.Show("Can not save in this mode - Open the file normally");
return false;
}

var fileName = AnimationPackItems.SelectedItem.FileName;
var bytes = _activeConverter.ToBytes(SelectedItemViewModel.Text, fileName, _pfs, out var error);

if (bytes == null || error != null)
{
SelectedItemViewModel.TextEditor.HightLightText(error.ErrorLineNumber, error.ErrorPosition, error.ErrorLength);
MessageBox.Show(error.Text, "Error");
return false;
}

var seletedFile = AnimationPackItems.SelectedItem;
seletedFile.CreateFromBytes(bytes);
seletedFile.IsChanged.Value = true;

SelectedItemViewModel.ResetChangeLog();
HasUnsavedChanges = true;

return true;
}


public bool Save()
{
if (_packFile == null)
{
MessageBox.Show("Can not save in this mode - Open the file normally");
return false;
}

if (SelectedItemViewModel != null && SelectedItemViewModel.HasUnsavedChanges())
{
if (MessageBox.Show("Editor has unsaved changes.\nSave anyway?", "", MessageBoxButton.YesNo) == MessageBoxResult.No)
return false;
}

var newAnimPack = new AnimationPackFileDatabase(_pfs.GetFullPath(_packFile));

foreach (var file in AnimationPackItems.PossibleValues)
newAnimPack.AddFile(file);

var savePath = _pfs.GetFullPath(_packFile);

var result = _packFileSaveService.Save(savePath, AnimationPackSerializer.ConvertToBytes(newAnimPack), false);
if (result != null)
{
HasUnsavedChanges = false;
foreach (var file in AnimationPackItems.PossibleValues)
file.IsChanged.Value = false;
}

return true;
}


public void LoadFile(PackFile file)
{
_packFile = file;
var animPack = AnimationPackSerializer.Load(_packFile, _pfs);
var itemNames = animPack.Files.ToList();
AnimationPackItems.UpdatePossibleValues(itemNames);
DisplayName = animPack.FileName;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,12 @@
<DockPanel Grid.Column="0" Grid.ColumnSpan="3" Grid.Row="0">
<Menu DockPanel.Dock="Top">
<MenuItem Header="_File">
<MenuItem Header="Save" Click="{s:MethodBinding Save}"/>
<MenuItem Header="Save" Command="{Binding Save}"/>
<Separator/>
<MenuItem Header="New AnimationSet (Wh3/3K)" Click="{s:MethodBinding CreateEmptyWarhammer3AnimSetFile}" />
<MenuItem Header="View Selected As Table" Click="{s:MethodBinding ViewSelectedAsTable}" Visibility="Collapsed"/>
<MenuItem Header="New AnimationSet (Wh3/3K)" Command="{Binding CreateEmptyWarhammer3AnimSetFileActionCommand}" />
<Separator/>
<MenuItem Header="Export animation slots (Wh3)" Click="{s:MethodBinding ExportAnimationSlotsWh3Action}" />
<MenuItem Header="Export animation slots (Wh2)" Click="{s:MethodBinding ExportAnimationSlotsWh2Action}" />
<MenuItem Header="Export animation slots (Wh3)" Command="{Binding ExportAnimationSlotsWh3ActionCommand}" />
<MenuItem Header="Export animation slots (Wh2)" Command="{Binding ExportAnimationSlotsWh2ActionCommand}" />
</MenuItem>
</Menu>
</DockPanel>
Expand Down Expand Up @@ -71,9 +70,9 @@

<ListView.ContextMenu>
<ContextMenu>
<MenuItem Header="Rename" Command="{Binding RenameCommand}" />
<MenuItem Header="Remove" Command="{Binding RemoveCommand}"/>
<MenuItem Header="Copy Full Path" Command="{Binding CopyFullPathCommand}"/>
<MenuItem Header="Rename" Command="{Binding RenameActionCommand}" />
<MenuItem Header="Remove" Command="{Binding RemoveActionCommand}"/>
<MenuItem Header="Copy Full Path" Command="{Binding CopyFullPathActionCommand}"/>
</ContextMenu>
</ListView.ContextMenu>

Expand Down
Loading
Loading