From 42f130f532e95c524c08ab415330fa0993ca6131 Mon Sep 17 00:00:00 2001 From: Pear-231 <61670316+Pear-231@users.noreply.github.com> Date: Sat, 31 Jan 2026 11:24:08 +0000 Subject: [PATCH 1/5] General cleanup --- .../AudioFilesExplorer/AudioFilesExplorerView.xaml | 2 +- .../ValueConverters/ImageConverter.cs | 7 ++++--- .../AudioProjectEditor/AudioProjectEditorViewModel.cs | 4 ++-- .../Table/EditorActionEventTableService.cs | 4 ++-- .../Table/EditorTableServiceFactory.cs | 9 ++------- .../Table/ViewerActionEventTableService.cs | 4 ++-- .../Table/ViewerTableServiceFactory.cs | 9 ++------- .../Presentation/Shared/Table/TableHelpers.cs | 2 +- .../Presentation/Shared/Table/TableInformation.cs | 2 +- Editors/Audio/AudioExplorer/AudioExplorerView.xaml | 2 +- 10 files changed, 18 insertions(+), 27 deletions(-) rename Editors/Audio/{Shared/UI => AudioEditor/Presentation/AudioFilesExplorer}/ValueConverters/ImageConverter.cs (83%) diff --git a/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml index b6eb30ce..5b6fcf42 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml @@ -4,7 +4,7 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:ValueConverters="clr-namespace:Editors.Audio.Shared.UI.ValueConverters" + xmlns:ValueConverters="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioFilesExplorer.ValueConverters" xmlns:Models="clr-namespace:Editors.Audio.AudioEditor.Presentation.Shared.Models" xmlns:Controls="clr-namespace:Editors.Audio.AudioEditor.Presentation.Shared.Controls" xmlns:AudioFilesExplorer="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioFilesExplorer" diff --git a/Editors/Audio/Shared/UI/ValueConverters/ImageConverter.cs b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/ValueConverters/ImageConverter.cs similarity index 83% rename from Editors/Audio/Shared/UI/ValueConverters/ImageConverter.cs rename to Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/ValueConverters/ImageConverter.cs index d98df912..74591928 100644 --- a/Editors/Audio/Shared/UI/ValueConverters/ImageConverter.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/ValueConverters/ImageConverter.cs @@ -1,15 +1,16 @@ using System; +using System.Globalization; using System.Windows.Data; using System.Windows.Media.Imaging; using Editors.Audio.AudioEditor.Presentation.Shared.Models; using Shared.EmbeddedResources; -namespace Editors.Audio.Shared.UI.ValueConverters +namespace Editors.Audio.AudioEditor.Presentation.AudioFilesExplorer.ValueConverters { [ValueConversion(typeof(AudioFilesTreeNode), typeof(BitmapImage))] public class ImageConverter : IValueConverter { - public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { if (value is AudioFilesTreeNode node) { @@ -22,7 +23,7 @@ public object Convert(object value, Type targetType, object parameter, System.Gl throw new Exception("Unknown type " + value.GetType().FullName); } - public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotSupportedException(); } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs index 26949bbe..8dda9198 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs @@ -211,7 +211,7 @@ private void SetEventNameFromAudioFile(List audioFiles, bool addToExi var row = Table.Rows[0]; var wavFileName = Path.GetFileNameWithoutExtension(audioFiles[0].WavPackFileName); var eventName = $"Play_{wavFileName}"; - row[TableInformation.EventColumnName] = eventName; + row[TableInformation.ActionEventColumnName] = eventName; } SetAddRowButtonEnablement(); @@ -229,7 +229,7 @@ private void SetMovieFilePath(string movieFilePath) var eventName = $"Play_Movie_{slashesToUnderscores}"; var row = Table.Rows[0]; - row[TableInformation.EventColumnName] = eventName; + row[TableInformation.ActionEventColumnName] = eventName; } public void OnEditorAddRowButtonEnablementUpdateRequested(EditorAddRowButtonEnablementUpdateRequestedEvent e) => SetAddRowButtonEnablement(); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs index c5a496c8..868a304b 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs @@ -31,7 +31,7 @@ public void Load(DataTable table) public List DefineSchema() { var schema = new List(); - var columnName = TableInformation.EventColumnName; + var columnName = TableInformation.ActionEventColumnName; schema.Add(columnName); return schema; } @@ -86,7 +86,7 @@ public void InitialiseTable(DataTable editorTable) eventName = "Play_"; var row = editorTable.NewRow(); - row[TableInformation.EventColumnName] = eventName; + row[TableInformation.ActionEventColumnName] = eventName; _eventHub.Publish(new EditorTableRowAddRequestedEvent(row)); } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorTableServiceFactory.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorTableServiceFactory.cs index 902dde6f..faf1c339 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorTableServiceFactory.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorTableServiceFactory.cs @@ -11,14 +11,9 @@ public interface IEditorTableServiceFactory IEditorTableService GetService(AudioProjectTreeNodeType nodeType); } - public class EditorTableServiceFactory : IEditorTableServiceFactory + public class EditorTableServiceFactory(IEnumerable services) : IEditorTableServiceFactory { - private readonly Dictionary _services; - - public EditorTableServiceFactory(IEnumerable services) - { - _services = services.ToDictionary(service => service.NodeType); - } + private readonly Dictionary _services = services.ToDictionary(service => service.NodeType); public IEditorTableService GetService(AudioProjectTreeNodeType nodeType) { diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs index c66dd21e..4208093f 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs @@ -30,7 +30,7 @@ public void Load(DataTable table) public List DefineSchema() { var schema = new List(); - var columnName = TableInformation.EventColumnName; + var columnName = TableInformation.ActionEventColumnName; schema.Add(columnName); return schema; } @@ -73,7 +73,7 @@ public void InitialiseTable(DataTable table) continue; var row = table.NewRow(); - row[TableInformation.EventColumnName] = actionEvent.Name; + row[TableInformation.ActionEventColumnName] = actionEvent.Name; _eventHub.Publish(new ViewerTableRowAddRequestedEvent(row)); } } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerTableServiceFactory.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerTableServiceFactory.cs index 4e311359..fd94f2a2 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerTableServiceFactory.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerTableServiceFactory.cs @@ -11,14 +11,9 @@ public interface IViewerTableServiceFactory IViewerTableService GetService(AudioProjectTreeNodeType nodeType); } - public class ViewerTableServiceFactory : IViewerTableServiceFactory + public class ViewerTableServiceFactory(IEnumerable services) : IViewerTableServiceFactory { - private readonly Dictionary _services; - - public ViewerTableServiceFactory(IEnumerable services) - { - _services = services.ToDictionary(service => service.NodeType); - } + private readonly Dictionary _services = services.ToDictionary(service => service.NodeType); public IViewerTableService GetService(AudioProjectTreeNodeType nodeType) { diff --git a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs index b6b94e57..8eb87c8c 100644 --- a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs +++ b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs @@ -51,7 +51,7 @@ public static string GetStateGroupFromStateGroupWithQualifier(IAudioRepository a public static string GetValueFromRow(DataRow row, string columnName) => row[columnName].ToString(); - public static string GetActionEventNameFromRow(DataRow row) => GetValueFromRow(row, TableInformation.EventColumnName); + public static string GetActionEventNameFromRow(DataRow row) => GetValueFromRow(row, TableInformation.ActionEventColumnName); public static string GetStatePathNameFromRow(DataRow row, IAudioRepository audioRepository, string dialogueEventName) { diff --git a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableInformation.cs b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableInformation.cs index 4e5696af..16cf6795 100644 --- a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableInformation.cs +++ b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableInformation.cs @@ -2,7 +2,7 @@ { public static class TableInformation { - public const string EventColumnName = "Event"; + public const string ActionEventColumnName = "Action Event"; public const string BrowseMovieColumnName = "Browse Movie"; public const string StateColumnName = "State"; } diff --git a/Editors/Audio/AudioExplorer/AudioExplorerView.xaml b/Editors/Audio/AudioExplorer/AudioExplorerView.xaml index 1c8fefca..b6fcf73b 100644 --- a/Editors/Audio/AudioExplorer/AudioExplorerView.xaml +++ b/Editors/Audio/AudioExplorer/AudioExplorerView.xaml @@ -9,7 +9,7 @@ xmlns:Behaviors="clr-namespace:Shared.Ui.Common.Behaviors;assembly=Shared.Ui" xmlns:ValueConverters="clr-namespace:Editors.Audio.Shared.UI.ValueConverters" xmlns:AudioExplorer="clr-namespace:Editors.Audio.AudioExplorer" - d:DataContext="{d:DesignInstance Type=audioexplorer:AudioExplorerViewModel}" + d:DataContext="{d:DesignInstance Type=AudioExplorer:AudioExplorerViewModel}" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> From 8bc18f182bd274eb6a6e7101b015ed28b59f87ce Mon Sep 17 00:00:00 2001 From: Pear-231 <61670316+Pear-231@users.noreply.github.com> Date: Sun, 1 Feb 2026 12:16:27 +0000 Subject: [PATCH 2/5] Made pause, play, resume Action Events visible --- ...erCommand.cs => AddRowsToViewerCommand.cs} | 17 ++-- .../AddActionEventCommand.cs | 6 +- ...RowCommand.cs => EditViewerRowsCommand.cs} | 10 +- .../RemoveViewerRowsCommand.cs | 4 +- .../ActionEventService.cs | 96 ++++++++++++------- .../AudioProjectEditorViewModel.cs | 35 ++++++- .../AudioProjectViewerView.xaml | 55 ++++++++++- .../AudioProjectViewerViewModel.cs | 74 ++++++++++---- .../Table/ViewerActionEventTableService.cs | 8 -- .../ActionEventRowEnablementConverter.cs | 42 ++++++++ .../Shared/Models/AudioProjectTreeNode.cs | 71 ++++++++++---- .../Presentation/Shared/Table/TableHelpers.cs | 28 ++++++ Editors/Audio/DependencyInjectionContainer.cs | 6 +- .../Factories/ActionEventFactory.cs | 1 - 14 files changed, 356 insertions(+), 97 deletions(-) rename Editors/Audio/AudioEditor/Commands/AudioProjectEditor/{AddEditorRowToViewerCommand.cs => AddRowsToViewerCommand.cs} (61%) rename Editors/Audio/AudioEditor/Commands/AudioProjectViewer/{EditViewerRowCommand.cs => EditViewerRowsCommand.cs} (83%) create mode 100644 Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/ValueConverters/ActionEventRowEnablementConverter.cs diff --git a/Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddEditorRowToViewerCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddRowsToViewerCommand.cs similarity index 61% rename from Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddEditorRowToViewerCommand.cs rename to Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddRowsToViewerCommand.cs index afba03c9..8bc0082e 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddEditorRowToViewerCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioProjectEditor/AddRowsToViewerCommand.cs @@ -1,4 +1,5 @@ -using System.Data; +using System.Collections.Generic; +using System.Data; using Editors.Audio.AudioEditor.Commands.AudioProjectMutation; using Editors.Audio.AudioEditor.Core; using Editors.Audio.AudioEditor.Events.AudioProjectEditor.Table; @@ -7,7 +8,7 @@ namespace Editors.Audio.AudioEditor.Commands.AudioProjectEditor { - public class AddEditorRowToViewerCommand( + public class AddRowsToViewerCommand( IAudioEditorStateService audioEditorStateService, IAudioProjectMutationUICommandFactory audioProjectMutationUICommandFactory, IEventHub eventHub) : IUiCommand @@ -16,12 +17,14 @@ public class AddEditorRowToViewerCommand( private readonly IAudioProjectMutationUICommandFactory _audioProjectMutationUICommandFactory = audioProjectMutationUICommandFactory; private readonly IEventHub _eventHub = eventHub; - public void Execute(DataRow row) + public void Execute(List rows) { - var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - _audioProjectMutationUICommandFactory.Create(MutationType.Add, selectedAudioProjectExplorerNode.Type).Execute(row); - _eventHub.Publish(new ViewerTableRowAddRequestedEvent(row)); - _eventHub.Publish(new EditorTableRowAddedToViewerEvent()); + foreach (var row in rows) + { + _audioProjectMutationUICommandFactory.Create(MutationType.Add, _audioEditorStateService.SelectedAudioProjectExplorerNode.Type).Execute(row); + _eventHub.Publish(new ViewerTableRowAddRequestedEvent(row)); + _eventHub.Publish(new EditorTableRowAddedToViewerEvent()); + } } } } diff --git a/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddActionEventCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddActionEventCommand.cs index 10cfe93d..5da741ad 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddActionEventCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddActionEventCommand.cs @@ -20,7 +20,11 @@ public void Execute(DataRow row) var audioFiles = _audioEditorStateService.AudioFiles; var hircSettings = _audioEditorStateService.HircSettings; var actionEventName = TableHelpers.GetActionEventNameFromRow(row); - _actionEventService.AddActionEvent(actionEventTypeName, actionEventName, audioFiles, hircSettings); + + if (actionEventName.StartsWith("Play_")) + _actionEventService.AddPlayActionEvent(actionEventTypeName, actionEventName, audioFiles, hircSettings); + else if (actionEventName.StartsWith("Pause_") || actionEventName.StartsWith("Resume_") || actionEventName.StartsWith("Stop_")) + _actionEventService.AddPauseResumeStopActionEvent(actionEventTypeName, actionEventName); } } } diff --git a/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowsCommand.cs similarity index 83% rename from Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowCommand.cs rename to Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowsCommand.cs index c1bfa1af..c071edd7 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/EditViewerRowsCommand.cs @@ -8,7 +8,7 @@ namespace Editors.Audio.AudioEditor.Commands.AudioProjectViewer { - public class EditViewerRowCommand( + public class EditViewerRowsCommand( IAudioEditorStateService audioEditorStateService, IUiCommandFactory uiCommandFactory, IEventHub eventHub) : IUiCommand @@ -17,14 +17,14 @@ public class EditViewerRowCommand( private readonly IUiCommandFactory _uiCommandFactory = uiCommandFactory; private readonly IEventHub _eventHub = eventHub; - private readonly ILogger _logger = Logging.Create(); + private readonly ILogger _logger = Logging.Create(); - public void Execute(List selectedViewerRows) + public void Execute(List rows) { // Publish before removing to ensure that an item is still selected - _eventHub.Publish(new ViewerTableRowEditedEvent(selectedViewerRows[0])); + _eventHub.Publish(new ViewerTableRowEditedEvent(rows[0])); - _uiCommandFactory.Create().Execute(selectedViewerRows); + _uiCommandFactory.Create().Execute(rows); var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; _logger.Here().Information($"Editing {selectedAudioProjectExplorerNode.Type} row in Audio Project Viewer table for {selectedAudioProjectExplorerNode.Name}"); diff --git a/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/RemoveViewerRowsCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/RemoveViewerRowsCommand.cs index 604ac7d6..98d663af 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/RemoveViewerRowsCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioProjectViewer/RemoveViewerRowsCommand.cs @@ -16,10 +16,10 @@ public class RemoveViewerRowsCommand( private readonly IAudioProjectMutationUICommandFactory _audioProjectMutationUICommandFactory = audioProjectMutationUICommandFactory; private readonly IEventHub _eventHub = eventHub; - public void Execute(List selectedViewerRows) + public void Execute(List rows) { var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - foreach (var row in selectedViewerRows) + foreach (var row in rows) _audioProjectMutationUICommandFactory.Create(MutationType.Remove, selectedAudioProjectExplorerNode.Type).Execute(row); _eventHub.Publish(new EditorAddRowButtonEnablementUpdateRequestedEvent()); diff --git a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs index 12b3cc2c..b27e4c9d 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Editors.Audio.AudioEditor.Presentation.Shared.Table; using Editors.Audio.Shared.AudioProject.Factories; using Editors.Audio.Shared.AudioProject.Models; using Editors.Audio.Shared.GameInformation.Warhammer3; @@ -13,7 +14,8 @@ namespace Editors.Audio.AudioEditor.Core.AudioProjectMutation { public interface IActionEventService { - void AddActionEvent(string actionEventGroupName, string actionEventName, List audioFiles, HircSettings hircSettings); + void AddPlayActionEvent(string actionEventTypeName, string actionEventName, List audioFiles, HircSettings hircSettings); + void AddPauseResumeStopActionEvent(string actionEventTypeName, string actionEventName); void RemoveActionEvent(string actionEventNodeName, string actionEventName); } @@ -23,24 +25,14 @@ public class ActionEventService(IAudioEditorStateService audioEditorStateService private readonly IAudioRepository _audioRepository = audioRepository; private readonly IActionEventFactory _actionEventFactory = actionEventFactory; - public void AddActionEvent(string actionEventTypeName, string actionEventName, List audioFiles, HircSettings hircSettings) + public void AddPlayActionEvent(string actionEventTypeName, string actionEventName, List audioFiles, HircSettings hircSettings) { - var usedHircIds = new HashSet(); - var usedSourceIds = new HashSet(); + var usedHircIds = GetUsedHircIds(); + var usedSourceIds = GetUsedSourceIds(); var audioProject = _audioEditorStateService.AudioProject; var languageId = WwiseHash.Compute(audioProject.Language); - var audioProjectGeneratableItemIds = audioProject.GetGeneratableItemIds(); - var languageHircIds = _audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); - usedHircIds.UnionWith(audioProjectGeneratableItemIds); - usedHircIds.UnionWith(languageHircIds); - - var audioProjectSourceIds = audioProject.GetAudioFileIds(); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); - var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3ActionEventInformation.GetSoundBank(actionEventTypeName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); var soundBankName = $"{gameSoundBankName}_{audioProjectNameWithoutExtension}"; @@ -86,16 +78,32 @@ public void AddActionEvent(string actionEventTypeName, string actionEventName, L audioFile.Sounds.Add(sound.Id); } } + } + + public void AddPauseResumeStopActionEvent(string actionEventTypeName, string actionEventName) + { + var usedHircIds = GetUsedHircIds(); + var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3ActionEventInformation.GetSoundBank(actionEventTypeName)); + var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); + var soundBankName = $"{gameSoundBankName}_{audioProjectNameWithoutExtension}"; + var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); + + var actionEventSuffix = TableHelpers.RemoveActionEventPrefix(actionEventName); + var playActionEvent = soundBank.GetActionEvent($"Play_{actionEventSuffix}"); - if (soundBank.GameSoundBank == Wh3SoundBank.GlobalMusic) + if (actionEventName.StartsWith("Pause_")) { - var pauseActionEventResult = _actionEventFactory.CreatePauseActionEvent(usedHircIds, playActionEventResult.ActionEvent); + var pauseActionEventResult = _actionEventFactory.CreatePauseActionEvent(usedHircIds, playActionEvent); soundBank.ActionEvents.InsertAlphabetically(pauseActionEventResult.ActionEvent); - - var resumeActionEventResult = _actionEventFactory.CreateResumeActionEvent(usedHircIds, playActionEventResult.ActionEvent); + } + else if (actionEventName.StartsWith("Resume_")) + { + var resumeActionEventResult = _actionEventFactory.CreateResumeActionEvent(usedHircIds, playActionEvent); soundBank.ActionEvents.InsertAlphabetically(resumeActionEventResult.ActionEvent); - - var stopActionEventResult = _actionEventFactory.CreateStopActionEvent(usedHircIds, playActionEventResult.ActionEvent); + } + else if (actionEventName.StartsWith("Stop_")) + { + var stopActionEventResult = _actionEventFactory.CreateStopActionEvent(usedHircIds, playActionEvent); soundBank.ActionEvents.InsertAlphabetically(stopActionEventResult.ActionEvent); } } @@ -111,19 +119,21 @@ public void RemoveActionEvent(string actionEventNodeName, string actionEventName var actionEvent = soundBank.GetActionEvent(actionEventName); soundBank.ActionEvents.Remove(actionEvent); - if (soundBank.GameSoundBank == Wh3SoundBank.GlobalMusic) + // We let the Play Action Event remove the target objects rather than Pause / Resume / Stop Action Events as otherwise they'd + // be removing objects that the Play Action Event removal process has already removed. + if (TableHelpers.IsPauseResumeStopActionEvent(actionEventName)) { - var pauseActionEventName = string.Concat("Pause_", actionEvent.Name.AsSpan("Play_".Length)); - var pauseActionEvent = soundBank.GetActionEvent(pauseActionEventName); - soundBank.ActionEvents.Remove(pauseActionEvent); - - var resumeActionEventName = string.Concat("Resume_", actionEvent.Name.AsSpan("Play_".Length)); - var resumeActionEvent = soundBank.GetActionEvent(resumeActionEventName); - soundBank.ActionEvents.Remove(resumeActionEvent); - - var stopActionEventName = string.Concat("Stop_", actionEvent.Name.AsSpan("Play_".Length)); - var stopActionEvent = soundBank.GetActionEvent(stopActionEventName); - soundBank.ActionEvents.Remove(stopActionEvent); + var actionEventSuffix = TableHelpers.RemoveActionEventPrefix(actionEventName); + var playActionEventName = $"Play_{actionEventSuffix}"; + var playActionEvent = soundBank.GetActionEvent(playActionEventName); + + // To ensure the Play Action Event doesn't exist when it comes to handling the removal of Pause / Resume / Stop Action Events, + // in the View Model when we send the rows to remove to the command we put the Play Action Events at the top of the list + // so this should always be null but in case it somehow isn't we check here. + if (playActionEvent != null) + throw new InvalidOperationException("Cannot remove Pause / Resume / Stop Action Event target objects while the Play Action Event still exists."); + + return; } foreach (var action in actionEvent.Actions) @@ -158,5 +168,27 @@ public void RemoveActionEvent(string actionEventNodeName, string actionEventName } } } + + private HashSet GetUsedHircIds() + { + var usedHircIds = new HashSet(); + var languageId = WwiseHash.Compute(_audioEditorStateService.AudioProject.Language); + var audioProjectGeneratableItemIds = _audioEditorStateService.AudioProject.GetGeneratableItemIds(); + var languageHircIds = _audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); + usedHircIds.UnionWith(audioProjectGeneratableItemIds); + usedHircIds.UnionWith(languageHircIds); + return usedHircIds; + } + + private HashSet GetUsedSourceIds() + { + var usedSourceIds = new HashSet(); + var languageId = WwiseHash.Compute(_audioEditorStateService.AudioProject.Language); + var audioProjectSourceIds = _audioEditorStateService.AudioProject.GetAudioFileIds(); + var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); + usedSourceIds.UnionWith(audioProjectSourceIds); + usedSourceIds.UnionWith(languageSourceIds); + return usedSourceIds; + } } } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs index 8dda9198..b2eec1af 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs @@ -246,7 +246,40 @@ private void OnEditorAddRowShortcutActivated(EditorAddRowShortcutActivatedEvent AddRowToViewer(); } - [RelayCommand] public void AddRowToViewer() => _uiCommandFactory.Create().Execute(Table.Rows[0]); + [RelayCommand] public void AddRowToViewer() + { + var rows = new List(); + var row = Table.Rows[0]; + rows.Add(row); + + // TODO: Add support for vocalisation Action Events when implemented + // To hide the complexity of creating Pause / Resume / Stop Action Events + // from the user we create them for them for the necessary types of audio + var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; + if (selectedAudioProjectExplorerNode.IsActionEvent()) + { + var actionEventName = TableHelpers.GetActionEventNameFromRow(row); + var actionEventSuffix = TableHelpers.RemoveActionEventPrefix(actionEventName); + if (selectedAudioProjectExplorerNode.IsMusicActionEvent()) + { + var pauseActionEventRow = TableHelpers.CreateRow(Table, $"Pause_{actionEventSuffix}"); + rows.Add(pauseActionEventRow); + + var resumeActionEventRow = TableHelpers.CreateRow(Table, $"Resume_{actionEventSuffix}"); + rows.Add(resumeActionEventRow); + + var stopActionEventRow = TableHelpers.CreateRow(Table, $"Stop_{actionEventSuffix}"); + rows.Add(stopActionEventRow); + } + else if (selectedAudioProjectExplorerNode.IsBattleAbilityActionEvent()) + { + var stopActionEventRow = TableHelpers.CreateRow(Table, $"Stop_{actionEventSuffix}"); + rows.Add(stopActionEventRow); + } + } + + _uiCommandFactory.Create().Execute(rows); + } partial void OnShowModdedStatesOnlyChanged(bool value) { diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml index 4f4e6ee1..f42de3c7 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml @@ -6,12 +6,16 @@ xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Behaviours="clr-namespace:Shared.Ui.Common.Behaviors;assembly=Shared.Ui" xmlns:AudioProjectViewer="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioProjectViewer" + xmlns:ValueConverters="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioProjectViewer.ValueConverters" d:DataContext="{d:DesignInstance Type=AudioProjectViewer:AudioProjectViewerViewModel}" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + + + + + + diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs index d4bb98ab..8ce3a87e 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs @@ -40,6 +40,7 @@ public partial class AudioProjectViewerViewModel : ObservableObject [ObservableProperty] private ObservableCollection _dataGridColumns = []; [ObservableProperty] public ObservableCollection _soundBanks; [ObservableProperty] public List _selectedRows = []; + [ObservableProperty] private AudioProjectTreeNode _selectedAudioProjectExplorerNode; [ObservableProperty] private bool _isUpdateRowButtonEnabled = false; [ObservableProperty] private bool _isRemoveRowButtonEnabled = false; [ObservableProperty] private bool _isCopyEnabled = false; @@ -86,39 +87,41 @@ private void OnAudioProjectInitialised(AudioProjectLoadedEvent e) public void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelectedEvent e) { + var selectedAudioProjectExplorerNode = e.TreeNode; + SelectedAudioProjectExplorerNode = selectedAudioProjectExplorerNode; + ResetViewerVisibility(); ResetViewerLabel(); ResetButtonEnablement(); ResetContextMenuVisibility(); ResetTable(); - var selectedExplorerNode = e.TreeNode; - if (selectedExplorerNode.IsActionEvent()) + if (selectedAudioProjectExplorerNode.IsActionEvent()) { SetViewerVisible(); - SetViewerLabel(selectedExplorerNode.Name); - Load(selectedExplorerNode.Type); + SetViewerLabel(selectedAudioProjectExplorerNode.Name); + LoadTable(selectedAudioProjectExplorerNode.Type); } - else if (selectedExplorerNode.IsDialogueEvent()) + else if (selectedAudioProjectExplorerNode.IsDialogueEvent()) { SetViewerVisible(); - SetViewerLabel(WpfHelpers.DuplicateUnderscores(selectedExplorerNode.Name)); - Load(selectedExplorerNode.Type); + SetViewerLabel(WpfHelpers.DuplicateUnderscores(selectedAudioProjectExplorerNode.Name)); + LoadTable(selectedAudioProjectExplorerNode.Type); SetContextMenuVisible(); SetCopyEnablement(); SetPasteEnablement(); } - else if (selectedExplorerNode.IsStateGroup()) + else if (selectedAudioProjectExplorerNode.IsStateGroup()) { SetViewerVisible(); - SetViewerLabel(WpfHelpers.DuplicateUnderscores(selectedExplorerNode.Name)); - Load(selectedExplorerNode.Type); + SetViewerLabel(WpfHelpers.DuplicateUnderscores(selectedAudioProjectExplorerNode.Name)); + LoadTable(selectedAudioProjectExplorerNode.Type); } else return; - _logger.Here().Information($"Loaded {selectedExplorerNode.Type}: {selectedExplorerNode.Name}"); + _logger.Here().Information($"Loaded {selectedAudioProjectExplorerNode.Type}: {selectedAudioProjectExplorerNode.Name}"); } private void OnViewerTableColumnAddRequested(ViewerTableColumnAddRequestedEvent e) => AddTableColumn(e.Column); @@ -133,15 +136,15 @@ public void AddTableColumn(DataColumn column) public void AddTableRow(DataRow row) { - var selectedExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - if (selectedExplorerNode.IsActionEvent()) + var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; + if (selectedAudioProjectExplorerNode.IsActionEvent()) TableHelpers.InsertRowAlphabeticallyByActionEventName(Table, row); - else if (selectedExplorerNode.IsDialogueEvent()) - TableHelpers.InsertRowAlphabeticallyByStatePathName(Table, row, _audioRepository, selectedExplorerNode.Name); - else if (selectedExplorerNode.IsStateGroup()) + else if (selectedAudioProjectExplorerNode.IsDialogueEvent()) + TableHelpers.InsertRowAlphabeticallyByStatePathName(Table, row, _audioRepository, selectedAudioProjectExplorerNode.Name); + else if (selectedAudioProjectExplorerNode.IsStateGroup()) TableHelpers.InsertRowAlphabeticallyByStateName(Table, row); - _logger.Here().Information($"Added {selectedExplorerNode.Type} row to Audio Project Viewer table for {selectedExplorerNode.Name}"); + _logger.Here().Information($"Added {selectedAudioProjectExplorerNode.Type} row to Audio Project Viewer table for {selectedAudioProjectExplorerNode.Name}"); } private void OnViewerTableRowRemoveRequested(ViewerTableRowRemoveRequestedEvent e) => RemoveTableRow(e.Row); @@ -224,7 +227,8 @@ public void OnViewerRemoveRowsShortcutActivated(ViewerRemoveRowsShortcutActivate [RelayCommand] public void RemoveRow() { - _uiCommandFactory.Create().Execute(_audioEditorStateService.SelectedViewerRows); + var rowsToRemove = GetRowsToRemove(); + _uiCommandFactory.Create().Execute(rowsToRemove); SetPasteEnablement(); } @@ -236,11 +240,41 @@ private void OnViewerEditRowShortcutActivated(ViewerEditRowShortcutActivatedEven [RelayCommand] public void EditRow() { - _uiCommandFactory.Create().Execute(_audioEditorStateService.SelectedViewerRows); + var rowsToRemove = GetRowsToRemove(); + _uiCommandFactory.Create().Execute(rowsToRemove); SetPasteEnablement(); } - private void Load(AudioProjectTreeNodeType selectedNodeType) + private List GetRowsToRemove() + { + var rowsToRemove = _audioEditorStateService.SelectedViewerRows; + var actionEventsNamesWithoutSuffixes = rowsToRemove + .Select(TableHelpers.GetActionEventNameFromRow) + .Select(TableHelpers.RemoveActionEventPrefix) + .ToList(); + + foreach (DataRow row in Table.Rows) + { + var actionEventName = TableHelpers.GetActionEventNameFromRow(row); + var actionEventWithoutActionPrefix = TableHelpers.RemoveActionEventPrefix(actionEventName); + + if (rowsToRemove.Contains(row) || !actionEventsNamesWithoutSuffixes.Contains(actionEventWithoutActionPrefix)) + continue; + + if (TableHelpers.IsPauseResumeStopActionEvent(actionEventName)) + rowsToRemove.Add(row); + } + + // We put Play Action Events first so they're removed first to avoid issues with Pause / Resume / Stop + // Action Events trying to remove target objects that the Play Action Event has already removed. + var orderedRowsToRemove = rowsToRemove + .OrderByDescending(row => TableHelpers.GetActionEventNameFromRow(row).StartsWith("Play_", StringComparison.Ordinal)) + .ToList(); + + return orderedRowsToRemove; + } + + private void LoadTable(AudioProjectTreeNodeType selectedNodeType) { var tableService = _tableServiceFactory.GetService(selectedNodeType); tableService.Load(Table); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs index 4208093f..f06b1cf7 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/Table/ViewerActionEventTableService.cs @@ -1,14 +1,12 @@ using System.Collections.Generic; using System.Data; using System.IO; -using System.Linq; using Editors.Audio.AudioEditor.Core; using Editors.Audio.AudioEditor.Events.AudioProjectViewer.Table; using Editors.Audio.AudioEditor.Presentation.Shared.Models; using Editors.Audio.AudioEditor.Presentation.Shared.Table; using Editors.Audio.Shared.GameInformation.Warhammer3; using Shared.Core.Events; -using Shared.GameFormats.Wwise.Enums; namespace Editors.Audio.AudioEditor.Presentation.AudioProjectViewer.Table { @@ -66,12 +64,6 @@ public void InitialiseTable(DataTable table) var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); foreach (var actionEvent in soundBank.ActionEvents) { - // We don't want them visible as we only show "Play_" Action Events as we force all Action Events to start with "Play_" - if (actionEvent.Actions.Any(action => action.ActionType == AkActionType.Pause_E_O - || action.ActionType == AkActionType.Resume_E_O - || action.ActionType == AkActionType.Stop_E_O)) - continue; - var row = table.NewRow(); row[TableInformation.ActionEventColumnName] = actionEvent.Name; _eventHub.Publish(new ViewerTableRowAddRequestedEvent(row)); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/ValueConverters/ActionEventRowEnablementConverter.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/ValueConverters/ActionEventRowEnablementConverter.cs new file mode 100644 index 00000000..8e4fa629 --- /dev/null +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/ValueConverters/ActionEventRowEnablementConverter.cs @@ -0,0 +1,42 @@ +using System; +using System.Data; +using System.Globalization; +using System.Windows.Data; +using Editors.Audio.AudioEditor.Presentation.Shared.Models; +using Editors.Audio.AudioEditor.Presentation.Shared.Table; + +namespace Editors.Audio.AudioEditor.Presentation.AudioProjectViewer.ValueConverters +{ + [ValueConversion(typeof(object[]), typeof(bool))] + public class ActionEventRowEnablementConverter : IMultiValueConverter + { + public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) + { + if (values[0] is not DataRowView rowView || values[1] is not AudioProjectTreeNode selectedNode) + return false; + + if (!selectedNode.IsActionEvent()) + return false; + + var row = rowView.Row; + if (row == null) + return false; + + if (row.RowState == DataRowState.Detached || row.RowState == DataRowState.Deleted) + return false; + + var actionEventName = row[TableInformation.ActionEventColumnName] as string; + if (string.IsNullOrWhiteSpace(actionEventName)) + return false; + + return actionEventName.StartsWith("Stop_", StringComparison.Ordinal) + || actionEventName.StartsWith("Resume_", StringComparison.Ordinal) + || actionEventName.StartsWith("Pause_", StringComparison.Ordinal); + } + + public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) + { + throw new NotSupportedException(); + } + } +} diff --git a/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs b/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs index eb386bd0..dee67d89 100644 --- a/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs +++ b/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs @@ -8,13 +8,24 @@ namespace Editors.Audio.AudioEditor.Presentation.Shared.Models { public enum AudioProjectTreeNodeType { + // The container node for SoundBanks SoundBanks, + // The SoundBank node SoundBank, + + // The container node for ActionEvents ActionEvents, - DialogueEvents, + // The Action Event Type e.g. Movies or Music ActionEventType, + + // The container node for Dialogue Events + DialogueEvents, + // The Dialogue Event node DialogueEvent, + + // The container node for State Groups StateGroups, + // The State Group node StateGroup } @@ -42,21 +53,6 @@ public static AudioProjectTreeNode CreateNode(string name, AudioProjectTreeNodeT }; } - public static AudioProjectTreeNode GetNode(ObservableCollection audioProjectTree, string nodeName) - { - foreach (var node in audioProjectTree) - { - if (node.Name == nodeName) - return node; - - var childNode = GetNode(node.Children, nodeName); - if (childNode != null) - return childNode; - } - - return null; - } - public bool IsActionEvent() { if (Type == ActionEventType) @@ -84,5 +80,48 @@ public bool IsStateGroup() return true; return false; } + + public bool IsSoundBank() + { + if (Type == SoundBank) + return true; + return false; + } + + public bool IsMusicActionEvent() + { + if (IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.Music)) + return true; + return false; + } + + public bool IsBattleAbilityActionEvent() + { + if (IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.BattleAbilities)) + return true; + return false; + } + + public bool IsMovieActionEvent() + { + if (IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.Movies)) + return true; + return false; + } + + public AudioProjectTreeNode GetParentSoundBankNode() + { + var currentNode = Parent; + + while (currentNode != null) + { + if (currentNode.IsSoundBank()) + return currentNode; + + currentNode = currentNode.Parent; + } + + return null; + } } } diff --git a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs index 8eb87c8c..f7577abc 100644 --- a/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs +++ b/Editors/Audio/AudioEditor/Presentation/Shared/Table/TableHelpers.cs @@ -152,5 +152,33 @@ public static void InsertRowAlphabeticallyByActionEventName(DataTable table, Dat newRow.ItemArray = (object[])sourceRow.ItemArray.Clone(); table.Rows.InsertAt(newRow, insertAt); } + + public static DataRow CreateRow(DataTable table, string actionEventName) + { + var pseudoTable = table.Clone(); + var row = pseudoTable.NewRow(); + row[TableInformation.ActionEventColumnName] = actionEventName; + return row; + } + + public static string RemoveActionEventPrefix(string actionEventName) + { + if (actionEventName.StartsWith("Play_", StringComparison.Ordinal)) + return actionEventName.Substring("Play_".Length); + if (actionEventName.StartsWith("Pause_", StringComparison.Ordinal)) + return actionEventName.Substring("Pause_".Length); + if (actionEventName.StartsWith("Resume_", StringComparison.Ordinal)) + return actionEventName.Substring("Resume_".Length); + if (actionEventName.StartsWith("Stop_", StringComparison.Ordinal)) + return actionEventName.Substring("Stop_".Length); + return actionEventName; + } + + public static bool IsPauseResumeStopActionEvent(string actionEventName) + { + return actionEventName.StartsWith("Pause_", StringComparison.Ordinal) + || actionEventName.StartsWith("Resume_", StringComparison.Ordinal) + || actionEventName.StartsWith("Stop_", StringComparison.Ordinal); + } } } diff --git a/Editors/Audio/DependencyInjectionContainer.cs b/Editors/Audio/DependencyInjectionContainer.cs index c2234997..53526215 100644 --- a/Editors/Audio/DependencyInjectionContainer.cs +++ b/Editors/Audio/DependencyInjectionContainer.cs @@ -71,15 +71,15 @@ public override void Register(IServiceCollection serviceCollection) serviceCollection.AddTransient(); // Audio Editor Commands - serviceCollection.AddScoped(); - serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); - serviceCollection.AddScoped(); + serviceCollection.AddScoped(); + serviceCollection.AddScoped(); serviceCollection.AddScoped(); + serviceCollection.AddScoped(); serviceCollection.AddScoped(); serviceCollection.AddScoped(); RegisterAllAsInterface(serviceCollection, ServiceLifetime.Transient); diff --git a/Editors/Audio/Shared/AudioProject/Factories/ActionEventFactory.cs b/Editors/Audio/Shared/AudioProject/Factories/ActionEventFactory.cs index 6373b0a3..af609906 100644 --- a/Editors/Audio/Shared/AudioProject/Factories/ActionEventFactory.cs +++ b/Editors/Audio/Shared/AudioProject/Factories/ActionEventFactory.cs @@ -109,7 +109,6 @@ public ActionEventFactoryResult CreatePauseActionEvent(HashSet usedHircIds return new ActionEventFactoryResult { ActionEvent = actionEvent }; } - public ActionEventFactoryResult CreateResumeActionEvent(HashSet usedHircIds, ActionEvent playActionEvent) { var resumeActions = new List(); From 3b15beab0c124cb0ecefeb3bed523f199cad607c Mon Sep 17 00:00:00 2001 From: Pear-231 <61670316+Pear-231@users.noreply.github.com> Date: Sun, 1 Feb 2026 21:15:50 +0000 Subject: [PATCH 3/5] Made more use of encapsulated query functions --- .../SetAudioFilesCommand.cs | 13 +---- .../AddDialogueEventByPasteCommand.cs | 12 ++--- .../Core/AudioEditorIntegrityService.cs | 8 +-- .../ActionEventService.cs | 52 +++++-------------- .../DialogueEventService.cs | 38 +++++--------- .../Presentation/AudioEditorViewModel.cs | 3 +- .../AudioFilesExplorerViewModel.cs | 4 +- .../AudioProjectEditorView.xaml | 2 +- .../AudioProjectEditorViewModel.cs | 17 +++--- .../Table/EditorActionEventTableService.cs | 7 +-- .../AudioProjectExplorerViewModel.cs | 3 +- .../AudioProjectTreeSearchFilterService.cs | 2 +- .../AudioProjectViewerView.xaml | 27 ++++++---- .../Presentation/Settings/SettingsView.xaml | 9 ++-- .../Settings/SettingsViewModel.cs | 37 +++++-------- .../AudioProjectConverterViewModel.cs | 16 +----- .../AudioProject/Compiler/IdGenerator.cs | 30 +++++++++++ 17 files changed, 115 insertions(+), 165 deletions(-) diff --git a/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs index 1d53fa22..12b02874 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs @@ -5,7 +5,6 @@ using Editors.Audio.Shared.AudioProject.Compiler; using Editors.Audio.Shared.AudioProject.Models; using Editors.Audio.Shared.Storage; -using Editors.Audio.Shared.Wwise; using Shared.Core.Events; namespace Editors.Audio.AudioEditor.Commands.AudioFilesExplorer @@ -18,20 +17,12 @@ public class SetAudioFilesCommand(IAudioEditorStateService audioEditorStateServi public void Execute(List selectedAudioFiles, bool addToExistingAudioFiles) { - var usedSourceIds = new HashSet(); - var audioProject = _audioEditorStateService.AudioProject; - - var audioProjectSourceIds = audioProject.GetAudioFileIds(); - var languageId = WwiseHash.Compute(audioProject.Language); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); + var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, _audioEditorStateService.AudioProject); var audioFiles = new List(); foreach (var wavFile in selectedAudioFiles) { - var audioFile = audioProject.GetAudioFile(wavFile.FilePath); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(wavFile.FilePath); if (audioFile == null) { var audioFileIds = IdGenerator.GenerateIds(usedSourceIds); diff --git a/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddDialogueEventByPasteCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddDialogueEventByPasteCommand.cs index 549d531f..e7f9ac64 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddDialogueEventByPasteCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioProjectMutation/AddDialogueEventByPasteCommand.cs @@ -25,29 +25,27 @@ public class AddDialogueEventByPasteCommand( public void Execute(DataRow row) { - var audioProject = _audioEditorStateService.AudioProject; - var copiedFromAudioProjectExplorerNode = _audioEditorStateService.CopiedFromAudioProjectExplorerNode; - HircSettings hircSettings = null; var audioFiles = new List(); - var dialogueEventName = copiedFromAudioProjectExplorerNode.Name; + var dialogueEventName = _audioEditorStateService.CopiedFromAudioProjectExplorerNode.Name; var dialogueEvent = _audioEditorStateService.AudioProject.GetDialogueEvent(dialogueEventName); var statePathName = TableHelpers.GetStatePathNameFromRow(row, _audioRepository, dialogueEventName); var statePath = dialogueEvent.GetStatePath(statePathName); - var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(copiedFromAudioProjectExplorerNode.Parent.Parent.Name); + var soundBankName = _audioEditorStateService.CopiedFromAudioProjectExplorerNode.GetParentSoundBankNode().Name; + var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); if (statePath.TargetHircTypeIsSound()) { var sound = soundBank.GetSound(statePath.TargetHircId); hircSettings = sound.HircSettings; - audioFiles.Add(audioProject.GetAudioFile(sound.SourceId)); + audioFiles.Add(_audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId)); } else if (statePath.TargetHircTypeIsRandomSequenceContainer()) { var randomSequenceContainer = soundBank.GetRandomSequenceContainer(statePath.TargetHircId); hircSettings = randomSequenceContainer.HircSettings; - audioFiles = audioProject.GetAudioFiles(soundBank, randomSequenceContainer); + audioFiles = _audioEditorStateService.AudioProject.GetAudioFiles(soundBank, randomSequenceContainer); } var statePathList = new List>(); diff --git a/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs b/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs index d3c71ebf..c79df41f 100644 --- a/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs @@ -45,13 +45,7 @@ public void UpdateSoundBankNames(AudioProjectFile audioProject, string audioProj public void RefreshSourceIds(AudioProjectFile audioProject) { - var audioProjectSourceIds = audioProject.GetAudioFileIds(); - var languageId = WwiseHash.Compute(audioProject.Language); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - - var usedSourceIds = new HashSet(); - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); + var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, audioProject); var audioProjectSounds = audioProject.GetSounds(); foreach (var audioFile in audioProject.AudioFiles) diff --git a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs index b27e4c9d..d8773d5d 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs @@ -3,11 +3,11 @@ using System.IO; using System.Linq; using Editors.Audio.AudioEditor.Presentation.Shared.Table; +using Editors.Audio.Shared.AudioProject.Compiler; using Editors.Audio.Shared.AudioProject.Factories; using Editors.Audio.Shared.AudioProject.Models; using Editors.Audio.Shared.GameInformation.Warhammer3; using Editors.Audio.Shared.Storage; -using Editors.Audio.Shared.Wwise; using HircSettings = Editors.Audio.Shared.AudioProject.Models.HircSettings; namespace Editors.Audio.AudioEditor.Core.AudioProjectMutation @@ -27,11 +27,8 @@ public class ActionEventService(IAudioEditorStateService audioEditorStateService public void AddPlayActionEvent(string actionEventTypeName, string actionEventName, List audioFiles, HircSettings hircSettings) { - var usedHircIds = GetUsedHircIds(); - var usedSourceIds = GetUsedSourceIds(); - - var audioProject = _audioEditorStateService.AudioProject; - var languageId = WwiseHash.Compute(audioProject.Language); + var usedHircIds = IdGenerator.GetUsedHircIds(_audioRepository, _audioEditorStateService.AudioProject); + var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, _audioEditorStateService.AudioProject); var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3ActionEventInformation.GetSoundBank(actionEventTypeName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); @@ -50,11 +47,11 @@ public void AddPlayActionEvent(string actionEventTypeName, string actionEventNam { soundBank.Sounds.TryAdd(playActionEventResult.SoundTarget); - var audioFile = audioProject.GetAudioFile(playActionEventResult.SoundTarget.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(playActionEventResult.SoundTarget.SourceId); if (audioFile == null) { audioFile = audioFiles.FirstOrDefault(audioFile => audioFile.Id == playActionEventResult.SoundTarget.SourceId); - audioProject.AudioFiles.TryAdd(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.TryAdd(audioFile); } if (!audioFile.Sounds.Contains(playActionEventResult.SoundTarget.Id)) @@ -67,11 +64,11 @@ public void AddPlayActionEvent(string actionEventTypeName, string actionEventNam foreach (var sound in playActionEventResult.RandomSequenceContainerSounds) { - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); if (audioFile == null) { audioFile = audioFiles.FirstOrDefault(audioFile => audioFile.Id == sound.SourceId); - audioProject.AudioFiles.TryAdd(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.TryAdd(audioFile); } if (!audioFile.Sounds.Contains(sound.Id)) @@ -82,7 +79,7 @@ public void AddPlayActionEvent(string actionEventTypeName, string actionEventNam public void AddPauseResumeStopActionEvent(string actionEventTypeName, string actionEventName) { - var usedHircIds = GetUsedHircIds(); + var usedHircIds = IdGenerator.GetUsedHircIds(_audioRepository, _audioEditorStateService.AudioProject); var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3ActionEventInformation.GetSoundBank(actionEventTypeName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); var soundBankName = $"{gameSoundBankName}_{audioProjectNameWithoutExtension}"; @@ -110,12 +107,11 @@ public void AddPauseResumeStopActionEvent(string actionEventTypeName, string act public void RemoveActionEvent(string actionEventNodeName, string actionEventName) { - var audioProject = _audioEditorStateService.AudioProject; var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3ActionEventInformation.GetSoundBank(actionEventNodeName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); var soundBankName = $"{gameSoundBankName}_{audioProjectNameWithoutExtension}"; - var soundBank = audioProject.GetSoundBank(soundBankName); + var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); var actionEvent = soundBank.GetActionEvent(actionEventName); soundBank.ActionEvents.Remove(actionEvent); @@ -141,13 +137,13 @@ public void RemoveActionEvent(string actionEventNodeName, string actionEventName if (action.TargetHircTypeIsSound()) { var sound = soundBank.GetSound(action.TargetHircId); - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); soundBank.Sounds.Remove(sound); audioFile.Sounds.Remove(sound.Id); if (audioFile.Sounds.Count == 0) - audioProject.AudioFiles.Remove(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.Remove(audioFile); } else if (action.TargetHircTypeIsRandomSequenceContainer()) { @@ -155,40 +151,18 @@ public void RemoveActionEvent(string actionEventNodeName, string actionEventName var sounds = soundBank.GetSounds(randomSequenceContainer.Children); foreach (var sound in sounds) { - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); soundBank.Sounds.Remove(sound); audioFile.Sounds.Remove(sound.Id); if (audioFile.Sounds.Count == 0) - audioProject.AudioFiles.Remove(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.Remove(audioFile); } soundBank.RandomSequenceContainers.Remove(randomSequenceContainer); } } } - - private HashSet GetUsedHircIds() - { - var usedHircIds = new HashSet(); - var languageId = WwiseHash.Compute(_audioEditorStateService.AudioProject.Language); - var audioProjectGeneratableItemIds = _audioEditorStateService.AudioProject.GetGeneratableItemIds(); - var languageHircIds = _audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); - usedHircIds.UnionWith(audioProjectGeneratableItemIds); - usedHircIds.UnionWith(languageHircIds); - return usedHircIds; - } - - private HashSet GetUsedSourceIds() - { - var usedSourceIds = new HashSet(); - var languageId = WwiseHash.Compute(_audioEditorStateService.AudioProject.Language); - var audioProjectSourceIds = _audioEditorStateService.AudioProject.GetAudioFileIds(); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); - return usedSourceIds; - } } } diff --git a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs index c095906a..311e7b59 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs @@ -1,11 +1,11 @@ using System.Collections.Generic; using System.IO; using System.Linq; +using Editors.Audio.Shared.AudioProject.Compiler; using Editors.Audio.Shared.AudioProject.Factories; using Editors.Audio.Shared.AudioProject.Models; using Editors.Audio.Shared.GameInformation.Warhammer3; using Editors.Audio.Shared.Storage; -using Editors.Audio.Shared.Wwise; using HircSettings = Editors.Audio.Shared.AudioProject.Models.HircSettings; namespace Editors.Audio.AudioEditor.Core.AudioProjectMutation @@ -24,21 +24,8 @@ public class DialogueEventService(IAudioEditorStateService audioEditorStateServi public void AddStatePath(string dialogueEventName, List audioFiles, HircSettings hircSettings, List> statePathList) { - var usedHircIds = new HashSet(); - var usedSourceIds = new HashSet(); - - var audioProject = _audioEditorStateService.AudioProject; - var languageId = WwiseHash.Compute(audioProject.Language); - - var audioProjectGeneratableItemIds = audioProject.GetGeneratableItemIds(); - var languageHircIds = _audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); - usedHircIds.UnionWith(audioProjectGeneratableItemIds); - usedHircIds.UnionWith(languageHircIds); - - var audioProjectSourceIds = audioProject.GetAudioFileIds(); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); + var usedHircIds = IdGenerator.GetUsedHircIds(_audioRepository, _audioEditorStateService.AudioProject); + var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, _audioEditorStateService.AudioProject); var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3DialogueEventInformation.GetSoundBank(dialogueEventName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); @@ -54,11 +41,11 @@ public void AddStatePath(string dialogueEventName, List audioFiles, H { soundBank.Sounds.TryAdd(statePathFactoryResult.SoundTarget); - var audioFile = audioProject.GetAudioFile(statePathFactoryResult.SoundTarget.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(statePathFactoryResult.SoundTarget.SourceId); if (audioFile == null) { audioFile = audioFiles.FirstOrDefault(audioFile => audioFile.Id == statePathFactoryResult.SoundTarget.SourceId); - audioProject.AudioFiles.TryAdd(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.TryAdd(audioFile); } if (!audioFile.Sounds.Contains(statePathFactoryResult.SoundTarget.Id)) @@ -71,11 +58,11 @@ public void AddStatePath(string dialogueEventName, List audioFiles, H foreach (var sound in statePathFactoryResult.RandomSequenceContainerSounds) { - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); if (audioFile == null) { audioFile = audioFiles.FirstOrDefault(audioFile => audioFile.Id == sound.SourceId); - audioProject.AudioFiles.TryAdd(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.TryAdd(audioFile); } if (!audioFile.Sounds.Contains(sound.Id)) @@ -86,12 +73,11 @@ public void AddStatePath(string dialogueEventName, List audioFiles, H public bool RemoveStatePath(string dialogueEventName, string statePathName) { - var audioProject = _audioEditorStateService.AudioProject; var gameSoundBankName = Wh3SoundBankInformation.GetName(Wh3DialogueEventInformation.GetSoundBank(dialogueEventName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); var soundBankName = $"{gameSoundBankName}_{audioProjectNameWithoutExtension}"; - var soundBank = audioProject.GetSoundBank(soundBankName); + var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); var dialogueEvent = _audioEditorStateService.AudioProject.GetDialogueEvent(dialogueEventName); var statePath = dialogueEvent.GetStatePath(statePathName); @@ -102,14 +88,14 @@ public bool RemoveStatePath(string dialogueEventName, string statePathName) if (statePath.TargetHircTypeIsSound()) { var sound = soundBank.GetSound(statePath.TargetHircId); - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); audioFile.Sounds.Remove(sound.Id); soundBank.Sounds.Remove(sound); audioFile.Sounds.Remove(sound.Id); if (audioFile.Sounds.Count == 0) - audioProject.AudioFiles.Remove(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.Remove(audioFile); } else if (statePath.TargetHircTypeIsRandomSequenceContainer()) { @@ -117,13 +103,13 @@ public bool RemoveStatePath(string dialogueEventName, string statePathName) var sounds = soundBank.GetSounds(randomSequenceContainer.Children); foreach (var sound in sounds) { - var audioFile = audioProject.GetAudioFile(sound.SourceId); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(sound.SourceId); soundBank.Sounds.Remove(sound); audioFile.Sounds.Remove(sound.Id); if (audioFile.Sounds.Count == 0) - audioProject.AudioFiles.Remove(audioFile); + _audioEditorStateService.AudioProject.AudioFiles.Remove(audioFile); } soundBank.RandomSequenceContainers.Remove(randomSequenceContainer); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioEditorViewModel.cs index 1e8b7de0..2e56ce34 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioEditorViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioEditorViewModel.cs @@ -88,10 +88,9 @@ private void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelected [RelayCommand] public void SaveAudioProject() { - var audioProject = _audioEditorStateService.AudioProject; var fileName = _audioEditorStateService.AudioProjectFileName; var filePath = _audioEditorStateService.AudioProjectFilePath; - _audioEditorFileService.Save(audioProject, fileName, filePath); + _audioEditorFileService.Save(_audioEditorStateService.AudioProject, fileName, filePath); } [RelayCommand] public void LoadAudioProject() => _audioEditorFileService.LoadFromDialog(); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerViewModel.cs index 5862adee..670b3e72 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerViewModel.cs @@ -188,8 +188,8 @@ private void SetButtonEnablement() if (selectedWavNodes.Count > 0) { - if (selectedAudioProjectExplorerNode.Type == AudioProjectTreeNodeType.ActionEventType - || selectedAudioProjectExplorerNode.Type == AudioProjectTreeNodeType.DialogueEvent) + if (selectedAudioProjectExplorerNode.IsActionEvent() + || selectedAudioProjectExplorerNode.IsDialogueEvent()) { IsSetAudioFilesButtonEnabled = true; IsAddAudioFilesButtonEnabled = _audioEditorStateService.AudioFiles.Count > 0; diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml index 830ee87c..94242638 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml @@ -60,7 +60,7 @@ - + diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs index b2eec1af..d1259b56 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs @@ -21,7 +21,6 @@ using Editors.Audio.AudioEditor.Presentation.Shared.Models; using Editors.Audio.AudioEditor.Presentation.Shared.Table; using Editors.Audio.Shared.AudioProject.Models; -using Editors.Audio.Shared.GameInformation.Warhammer3; using Editors.Audio.Shared.Storage; using Serilog; using Shared.Core.ErrorHandling; @@ -99,13 +98,13 @@ private void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelected { MakeEditorVisible(); SetEditorLabel(selectedAudioProjectExplorerNode.Name); - Load(selectedAudioProjectExplorerNode.Type); + LoadTable(selectedAudioProjectExplorerNode.Type); } else if (selectedAudioProjectExplorerNode.IsDialogueEvent()) { MakeEditorVisible(); SetEditorLabel(WpfHelpers.DuplicateUnderscores(selectedAudioProjectExplorerNode.Name)); - Load(selectedAudioProjectExplorerNode.Type); + LoadTable(selectedAudioProjectExplorerNode.Type); var moddedStatesCount = _audioEditorStateService.AudioProject.StateGroups.SelectMany(stateGroup => stateGroup.States).Count(); if (moddedStatesCount > 0) @@ -115,7 +114,7 @@ private void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelected { MakeEditorVisible(); SetEditorLabel(WpfHelpers.DuplicateUnderscores(selectedAudioProjectExplorerNode.Name)); - Load(selectedAudioProjectExplorerNode.Type); + LoadTable(selectedAudioProjectExplorerNode.Type); } else return; @@ -198,13 +197,11 @@ private void OnViewerTableRowEdited(ViewerTableRowEditedEvent e) private void SetEventNameFromAudioFile(List audioFiles, bool addToExistingAudioFiles, bool isSetFromEditedViewerItem) { var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - var isActionEvent = selectedAudioProjectExplorerNode.IsActionEvent(); - var isNotMoviesActionEvent = selectedAudioProjectExplorerNode.Name != Wh3ActionEventInformation.GetName(Wh3ActionEventType.Movies); var hasExistingAudioFiles = _audioEditorStateService.AudioFiles.Count > 0; - if (isActionEvent + if (selectedAudioProjectExplorerNode.IsActionEvent() + && !selectedAudioProjectExplorerNode.IsMovieActionEvent() && isSetFromEditedViewerItem - && isNotMoviesActionEvent && audioFiles.Count == 1 && ((hasExistingAudioFiles && !addToExistingAudioFiles) || (!hasExistingAudioFiles && addToExistingAudioFiles))) { @@ -234,7 +231,7 @@ private void SetMovieFilePath(string movieFilePath) public void OnEditorAddRowButtonEnablementUpdateRequested(EditorAddRowButtonEnablementUpdateRequestedEvent e) => SetAddRowButtonEnablement(); - private void Load(AudioProjectTreeNodeType selectedNodeType) + private void LoadTable(AudioProjectTreeNodeType selectedNodeType) { var tableService = _tableServiceFactory.GetService(selectedNodeType); tableService.Load(Table); @@ -289,7 +286,7 @@ partial void OnShowModdedStatesOnlyChanged(bool value) if (selectedAudioProjectExplorerNode.IsDialogueEvent()) { Table.Clear(); - Load(selectedAudioProjectExplorerNode.Type); + LoadTable(selectedAudioProjectExplorerNode.Type); } } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs index 868a304b..488b932c 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorActionEventTableService.cs @@ -4,7 +4,6 @@ using Editors.Audio.AudioEditor.Events.AudioProjectEditor.Table; using Editors.Audio.AudioEditor.Presentation.Shared.Models; using Editors.Audio.AudioEditor.Presentation.Shared.Table; -using Editors.Audio.Shared.GameInformation.Warhammer3; using Shared.Core.Events; namespace Editors.Audio.AudioEditor.Presentation.AudioProjectEditor.Table @@ -50,8 +49,7 @@ public void ConfigureDataGrid(List schema) var columnsCount = 1; var columnWidth = 1.0 / columnsCount; - var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - if (selectedAudioProjectExplorerNode.Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.Movies)) + if (_audioEditorStateService.SelectedAudioProjectExplorerNode.IsMovieActionEvent()) { var fileSelectColumnHeader = TableInformation.BrowseMovieColumnName; var fileSelectColumn = DataGridTemplates.CreateColumnTemplate(fileSelectColumnHeader, 85, useAbsoluteWidth: true); @@ -81,8 +79,7 @@ public void InitialiseTable(DataTable editorTable) { var eventName = string.Empty; - var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode.Name; - if (selectedAudioProjectExplorerNode != Wh3ActionEventInformation.GetName(Wh3ActionEventType.Movies)) + if (!_audioEditorStateService.SelectedAudioProjectExplorerNode.IsMovieActionEvent()) eventName = "Play_"; var row = editorTable.NewRow(); diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs index 98ebf048..5c88efdb 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs @@ -59,8 +59,7 @@ private void OnAudioProjectInitialised(AudioProjectLoadedEvent e) { ResetFilters(); - var audioProject = _audioEditorStateService.AudioProject; - AudioProjectTree = _audioProjectTreeBuilder.BuildTree(audioProject, ShowEditedItemsOnly); + AudioProjectTree = _audioProjectTreeBuilder.BuildTree(_audioEditorStateService.AudioProject, ShowEditedItemsOnly); var audioProjectFileName = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); AudioProjectExplorerLabel = $"Audio Project Explorer - {WpfHelpers.DuplicateUnderscores(audioProjectFileName)}"; diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectTreeSearchFilterService.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectTreeSearchFilterService.cs index a26b9212..7e32cac2 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectTreeSearchFilterService.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectTreeSearchFilterService.cs @@ -149,7 +149,7 @@ private bool FilterNode(AudioProjectTreeNode node) var matchesEventType = MatchesEventType(node); var matchesDialogueEventFilters = true; - if (node.Type == AudioProjectTreeNodeType.DialogueEvent && _allowedDialogueEventsLookup.TryGetValue(node.Parent, out var allowedSet)) + if (node.IsDialogueEvent() && _allowedDialogueEventsLookup.TryGetValue(node.Parent, out var allowedSet)) matchesDialogueEventFilters = allowedSet.Contains(node.Name); var anyChildVisible = false; diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml index f42de3c7..bb1460c0 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml @@ -5,19 +5,19 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Behaviours="clr-namespace:Shared.Ui.Common.Behaviors;assembly=Shared.Ui" - xmlns:AudioProjectViewer="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioProjectViewer" + xmlns:AudioProjectViewer="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioProjectViewer" xmlns:ValueConverters="clr-namespace:Editors.Audio.AudioEditor.Presentation.AudioProjectViewer.ValueConverters" d:DataContext="{d:DesignInstance Type=AudioProjectViewer:AudioProjectViewerViewModel}" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800"> - + - + @@ -60,11 +60,14 @@ - - + + - + @@ -73,8 +76,8 @@