From 552b4a070fd53bfaf232870f847cc15d83e7122a Mon Sep 17 00:00:00 2001 From: Pear-231 <61670316+Pear-231@users.noreply.github.com> Date: Mon, 2 Feb 2026 08:11:20 +0000 Subject: [PATCH 1/4] Removed duplication and made more use of encapsulated query functions --- .../SetAudioFilesCommand.cs | 12 +--- .../AddDialogueEventByPasteCommand.cs | 12 ++-- .../Core/AudioEditorFileService.cs | 1 + .../Core/AudioEditorIntegrityService.cs | 8 +-- .../ActionEventService.cs | 38 ++++------ .../DialogueEventService.cs | 38 ++++------ .../Presentation/AudioEditorViewModel.cs | 3 +- .../AudioFilesExplorerViewModel.cs | 4 +- .../AudioProjectEditorViewModel.cs | 8 +-- .../Table/EditorActionEventTableService.cs | 11 ++- .../AudioProjectExplorerViewModel.cs | 3 +- .../AudioProjectTreeSearchFilterService.cs | 2 +- .../AudioProjectViewerViewModel.cs | 35 +++++----- .../Table/ViewerActionEventTableService.cs | 4 +- .../Settings/SettingsViewModel.cs | 35 ++++------ .../Shared/Models/AudioProjectTreeNode.cs | 69 +++++++++---------- .../Presentation/Shared/Table/TableHelpers.cs | 2 +- .../Shared/Table/TableInformation.cs | 2 +- .../AudioProjectConverterViewModel.cs | 16 +---- .../AudioProject/Compiler/IdGenerator.cs | 30 ++++++++ .../Generators/Hirc/HircChunkGenerator.cs | 1 - .../Hirc/V136/ActionHircGenerator_V136.cs | 5 +- .../V136/AkBankSourceDataGenerator_V136.cs | 4 +- .../Hirc/V136/CAkEventGenerator_V136.cs | 1 - .../Hirc/V136/CAkSoundGenerator_V136.cs | 1 - .../Generators/SoundBankGeneratorService.cs | 1 - 26 files changed, 152 insertions(+), 194 deletions(-) diff --git a/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs index 1d53fa222..6b28c8dcd 100644 --- a/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs +++ b/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs @@ -18,20 +18,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 549d531f0..e7f9ac64b 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/AudioEditorFileService.cs b/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs index d96c0fcdb..c69ae7f41 100644 --- a/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using System.Text.Json; using System.Text.Json.Serialization; diff --git a/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs b/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs index d3c71ebf5..c79df41f2 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 12b3cc2cd..6d64c69cf 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs @@ -2,6 +2,8 @@ using System.Collections.Generic; 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; @@ -25,21 +27,8 @@ public class ActionEventService(IAudioEditorStateService audioEditorStateService public void AddActionEvent(string actionEventTypeName, string actionEventName, List audioFiles, HircSettings hircSettings) { - 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(Wh3ActionEventInformation.GetSoundBank(actionEventTypeName)); var audioProjectNameWithoutExtension = Path.GetFileNameWithoutExtension(_audioEditorStateService.AudioProjectFileName); @@ -58,11 +47,11 @@ public void AddActionEvent(string actionEventTypeName, string actionEventName, L { 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)) @@ -75,11 +64,11 @@ public void AddActionEvent(string actionEventTypeName, string actionEventName, L 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)) @@ -102,12 +91,11 @@ public void AddActionEvent(string actionEventTypeName, string actionEventName, L 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); @@ -131,13 +119,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()) { @@ -145,13 +133,13 @@ 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); diff --git a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/DialogueEventService.cs index c095906af..311e7b59e 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 1e8b7de04..2e56ce346 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 5862adee8..670b3e728 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/AudioProjectEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs index 26949bbe1..5f1744c2e 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; @@ -202,7 +201,8 @@ private void SetEventNameFromAudioFile(List audioFiles, bool addToExi 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 @@ -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 c5a496c8b..488b932c8 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 @@ -31,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; } @@ -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,12 +79,11 @@ 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(); - row[TableInformation.EventColumnName] = eventName; + row[TableInformation.ActionEventColumnName] = eventName; _eventHub.Publish(new EditorTableRowAddRequestedEvent(row)); } diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectExplorer/AudioProjectExplorerViewModel.cs index 98ebf048b..5c88efdbe 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 a26b92126..7e32cac2a 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/AudioProjectViewerViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs index d4bb98abe..f65d6e91a 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerViewModel.cs @@ -86,39 +86,39 @@ private void OnAudioProjectInitialised(AudioProjectLoadedEvent e) public void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelectedEvent e) { + var selectedAudioProjectExplorerNode = e.TreeNode; 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 +133,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); @@ -241,6 +241,7 @@ [RelayCommand] public void EditRow() } private void Load(AudioProjectTreeNodeType selectedNodeType) + 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 c66dd21ef..4208093ff 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/Settings/SettingsViewModel.cs b/Editors/Audio/AudioEditor/Presentation/Settings/SettingsViewModel.cs index 66a7f526d..c32c1d164 100644 --- a/Editors/Audio/AudioEditor/Presentation/Settings/SettingsViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/Settings/SettingsViewModel.cs @@ -153,20 +153,12 @@ private void OnViewerRowEdited(ViewerTableRowEditedEvent e) public void SetAudioFilesViaDrop(IEnumerable audioFilesTreeNodes) { - 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 node in audioFilesTreeNodes) { - var audioFile = audioProject.GetAudioFile(node.FilePath); + var audioFile = _audioEditorStateService.AudioProject.GetAudioFile(node.FilePath); if (audioFile == null) { var audioFileIds = IdGenerator.GenerateIds(usedSourceIds); @@ -467,9 +459,8 @@ private void GetActionEventSettings(ref HircSettings hircSettings, ref List audioFiles) { - var audioProject = _audioEditorStateService.AudioProject; var selectedViewerRow = _audioEditorStateService.SelectedViewerRows[0]; - var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode; - var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(selectedAudioProjectExplorerNode.Parent.Parent.Name); - var dialogueEvent = _audioEditorStateService.AudioProject.GetDialogueEvent(selectedAudioProjectExplorerNode.Name); - var statePathName = TableHelpers.GetStatePathNameFromRow(selectedViewerRow, _audioRepository, selectedAudioProjectExplorerNode.Name); + var soundBankName = _audioEditorStateService.SelectedAudioProjectExplorerNode.GetParentSoundBankNode().Name; + var soundBank = _audioEditorStateService.AudioProject.GetSoundBank(soundBankName); + + var dialogueEvent = _audioEditorStateService.AudioProject.GetDialogueEvent(_audioEditorStateService.SelectedAudioProjectExplorerNode.Name); + var statePathName = TableHelpers.GetStatePathNameFromRow(selectedViewerRow, _audioRepository, _audioEditorStateService.SelectedAudioProjectExplorerNode.Name); var statePath = dialogueEvent.GetStatePath(statePathName); 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); } } diff --git a/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs b/Editors/Audio/AudioEditor/Presentation/Shared/Models/AudioProjectTreeNode.cs index eb386bd08..ca5317e97 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,47 +53,35 @@ 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; + public bool IsActionEvent() => Type == ActionEventType; - var childNode = GetNode(node.Children, nodeName); - if (childNode != null) - return childNode; - } + public bool IsDialogueEvents() => Name == AudioProjectTreeBuilderService.DialogueEventsNodeName; - return null; - } + public bool IsDialogueEvent() => Type == DialogueEvent; - public bool IsActionEvent() - { - if (Type == ActionEventType) - return true; - return false; - } + public bool IsStateGroup() => Type == StateGroup; - public bool IsDialogueEvents() - { - if (Name == AudioProjectTreeBuilderService.DialogueEventsNodeName) - return true; - return false; - } + public bool IsSoundBank() => Type == SoundBank; - public bool IsDialogueEvent() - { - if (Type == DialogueEvent) - return true; - return false; - } + public bool IsMusicActionEvent() => IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.Music); + + public bool IsBattleAbilityActionEvent() => IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.BattleAbilities); + + public bool IsMovieActionEvent() => IsActionEvent() && Name == Wh3ActionEventInformation.GetName(Wh3ActionEventType.Movies); - public bool IsStateGroup() + public AudioProjectTreeNode GetParentSoundBankNode() { - if (Type == StateGroup) - return true; - return false; + 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 b6b94e57b..8eb87c8c6 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 4e5696af4..16cf6795e 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/AudioProjectConverter/AudioProjectConverterViewModel.cs b/Editors/Audio/AudioProjectConverter/AudioProjectConverterViewModel.cs index 3dfbbadff..34bf26a6a 100644 --- a/Editors/Audio/AudioProjectConverter/AudioProjectConverterViewModel.cs +++ b/Editors/Audio/AudioProjectConverter/AudioProjectConverterViewModel.cs @@ -110,20 +110,8 @@ [RelayCommand] public void ProcessAudioProjectConversion() dialogueEventsToProcess, moddedStateGroups); - var usedHircIds = new HashSet(); - var usedSourceIds = new HashSet(); - - var audioProjectGeneratableItemIds = audioProject.GetGeneratableItemIds(); - var audioProjectSourceIds = audioProject.GetAudioFileIds(); - - var languageId = WwiseHash.Compute(audioProject.Language); - var languageHircIds = _audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); - var languageSourceIds = _audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); - - usedHircIds.UnionWith(audioProjectGeneratableItemIds); - usedHircIds.UnionWith(languageHircIds); - usedSourceIds.UnionWith(audioProjectSourceIds); - usedSourceIds.UnionWith(languageSourceIds); + var usedHircIds = IdGenerator.GetUsedHircIds(_audioRepository, audioProject); + var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, audioProject); foreach (var dialogueEvent in dialogueEventsToProcess) ProcessDialogueEvent( diff --git a/Editors/Audio/Shared/AudioProject/Compiler/IdGenerator.cs b/Editors/Audio/Shared/AudioProject/Compiler/IdGenerator.cs index 58a6ee043..23e4589fb 100644 --- a/Editors/Audio/Shared/AudioProject/Compiler/IdGenerator.cs +++ b/Editors/Audio/Shared/AudioProject/Compiler/IdGenerator.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using Editors.Audio.Shared.AudioProject.Models; +using Editors.Audio.Shared.Storage; using Editors.Audio.Shared.Wwise; namespace Editors.Audio.Shared.AudioProject.Compiler @@ -29,5 +31,33 @@ public static uint GenerateActionEventId(HashSet usedIds, string actionEve else return id; } + + public static HashSet GetUsedHircIds(IAudioRepository audioRepository, AudioProjectFile audioProject) + { + var usedHircIds = new HashSet(); + + var languageId = WwiseHash.Compute(audioProject.Language); + var languageHircIds = audioRepository.GetUsedVanillaHircIdsByLanguageId(languageId); + usedHircIds.UnionWith(languageHircIds); + + var audioProjectGeneratableItemIds = audioProject.GetGeneratableItemIds(); + usedHircIds.UnionWith(audioProjectGeneratableItemIds); + + return usedHircIds; + } + + public static HashSet GetUsedSourceIds(IAudioRepository audioRepository, AudioProjectFile audioProject) + { + var usedSourceIds = new HashSet(); + + var languageId = WwiseHash.Compute(audioProject.Language); + var languageSourceIds = audioRepository.GetUsedVanillaSourceIdsByLanguageId(languageId); + usedSourceIds.UnionWith(languageSourceIds); + + var audioProjectSourceIds = audioProject.GetAudioFileIds(); + usedSourceIds.UnionWith(audioProjectSourceIds); + + return usedSourceIds; + } } } diff --git a/Editors/Audio/Shared/Wwise/Generators/Hirc/HircChunkGenerator.cs b/Editors/Audio/Shared/Wwise/Generators/Hirc/HircChunkGenerator.cs index e42426d7c..3c055de83 100644 --- a/Editors/Audio/Shared/Wwise/Generators/Hirc/HircChunkGenerator.cs +++ b/Editors/Audio/Shared/Wwise/Generators/Hirc/HircChunkGenerator.cs @@ -1,6 +1,5 @@ using System.Collections.Generic; using System.Linq; -using Editors.Audio.Shared.Wwise.Generators; using Shared.GameFormats.Wwise.Enums; using Shared.GameFormats.Wwise.Hirc; diff --git a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/ActionHircGenerator_V136.cs b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/ActionHircGenerator_V136.cs index ba2463b6c..a84db3646 100644 --- a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/ActionHircGenerator_V136.cs +++ b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/ActionHircGenerator_V136.cs @@ -1,10 +1,9 @@ -using Editors.Audio.Shared.GameInformation.Warhammer3; +using Editors.Audio.Shared.AudioProject.Models; +using Editors.Audio.Shared.GameInformation.Warhammer3; using Shared.GameFormats.Wwise.Enums; using Shared.GameFormats.Wwise.Hirc; using Shared.GameFormats.Wwise.Hirc.V136; using static Shared.GameFormats.Wwise.Hirc.V136.Shared.AkPropBundle_V136; -using Editors.Audio.Shared.AudioProject.Models; -using Editors.Audio.Shared.Wwise.Generators; namespace Editors.Audio.Shared.Wwise.Generators.Hirc.V136 { diff --git a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/AkBankSourceDataGenerator_V136.cs b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/AkBankSourceDataGenerator_V136.cs index 38ca3d4f9..b6d785ee8 100644 --- a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/AkBankSourceDataGenerator_V136.cs +++ b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/AkBankSourceDataGenerator_V136.cs @@ -1,7 +1,7 @@ -using Editors.Audio.Shared.GameInformation.Warhammer3; +using Editors.Audio.Shared.AudioProject.Models; +using Editors.Audio.Shared.GameInformation.Warhammer3; using Shared.GameFormats.Wwise.Enums; using Shared.GameFormats.Wwise.Hirc.V136.Shared; -using Editors.Audio.Shared.AudioProject.Models; namespace Editors.Audio.Shared.Wwise.Generators.Hirc.V136 { diff --git a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkEventGenerator_V136.cs b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkEventGenerator_V136.cs index 234c88db3..9f7229255 100644 --- a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkEventGenerator_V136.cs +++ b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkEventGenerator_V136.cs @@ -1,6 +1,5 @@ using System.Linq; using Editors.Audio.Shared.AudioProject.Models; -using Editors.Audio.Shared.Wwise.Generators; using Shared.GameFormats.Wwise.Hirc; using Shared.GameFormats.Wwise.Hirc.V136; diff --git a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkSoundGenerator_V136.cs b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkSoundGenerator_V136.cs index 0bf0d69ed..1ee5ee292 100644 --- a/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkSoundGenerator_V136.cs +++ b/Editors/Audio/Shared/Wwise/Generators/Hirc/V136/CAkSoundGenerator_V136.cs @@ -1,5 +1,4 @@ using Editors.Audio.Shared.AudioProject.Models; -using Editors.Audio.Shared.Wwise.Generators; using Shared.GameFormats.Wwise.Hirc; using Shared.GameFormats.Wwise.Hirc.V136; diff --git a/Editors/Audio/Shared/Wwise/Generators/SoundBankGeneratorService.cs b/Editors/Audio/Shared/Wwise/Generators/SoundBankGeneratorService.cs index ebad2eb68..331852ca6 100644 --- a/Editors/Audio/Shared/Wwise/Generators/SoundBankGeneratorService.cs +++ b/Editors/Audio/Shared/Wwise/Generators/SoundBankGeneratorService.cs @@ -7,7 +7,6 @@ using Editors.Audio.Shared.AudioProject.Models; using Editors.Audio.Shared.GameInformation.Warhammer3; using Editors.Audio.Shared.Storage; -using Editors.Audio.Shared.Wwise; using Editors.Audio.Shared.Wwise.Generators.Bkhd; using Editors.Audio.Shared.Wwise.Generators.Hirc; using Serilog; From 528de65bd237eba75ae70ab9db63043b8a31ce0a Mon Sep 17 00:00:00 2001 From: Pear-231 <61670316+Pear-231@users.noreply.github.com> Date: Mon, 2 Feb 2026 09:01:43 +0000 Subject: [PATCH 2/4] Made pause / resume / stop Action Events visible and added stop for battle abilities --- ...erCommand.cs => AddRowsToViewerCommand.cs} | 17 ++-- .../AddActionEventCommand.cs | 6 +- ...RowCommand.cs => EditViewerRowsCommand.cs} | 10 +-- .../RemoveViewerRowsCommand.cs | 4 +- .../ActionEventService.cs | 60 +++++++++----- .../AudioFilesExplorerView.xaml | 2 +- .../ValueConverters/ImageConverter.cs | 7 +- .../AudioProjectEditorView.xaml | 4 +- .../AudioProjectEditorViewModel.cs | 51 +++++++++--- .../Table/EditorTableServiceFactory.cs | 9 +- .../AudioProjectViewerView.xaml | 82 ++++++++++++++++--- .../AudioProjectViewerViewModel.cs | 47 ++++++++++- .../Table/ViewerActionEventTableService.cs | 8 -- .../Table/ViewerTableServiceFactory.cs | 9 +- .../ActionEventRowEnablementConverter.cs | 42 ++++++++++ .../Presentation/Settings/SettingsView.xaml | 9 +- .../Presentation/Shared/Table/TableHelpers.cs | 28 +++++++ .../AudioExplorer/AudioExplorerView.xaml | 2 +- Editors/Audio/DependencyInjectionContainer.cs | 6 +- 19 files changed, 307 insertions(+), 96 deletions(-) rename Editors/Audio/AudioEditor/Commands/AudioProjectEditor/{AddEditorRowToViewerCommand.cs => AddRowsToViewerCommand.cs} (61%) rename Editors/Audio/AudioEditor/Commands/AudioProjectViewer/{EditViewerRowCommand.cs => EditViewerRowsCommand.cs} (83%) rename Editors/Audio/{Shared/UI => AudioEditor/Presentation/AudioFilesExplorer}/ValueConverters/ImageConverter.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 afba03c92..8bc0082ef 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 10cfe93d3..5da741ad0 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 c1bfa1af3..c071edd7c 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 604ac7d63..98d663af2 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 6d64c69cf..d8773d5db 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs @@ -8,14 +8,14 @@ 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 { 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); } @@ -25,7 +25,7 @@ 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 = IdGenerator.GetUsedHircIds(_audioRepository, _audioEditorStateService.AudioProject); var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, _audioEditorStateService.AudioProject); @@ -75,16 +75,32 @@ public void AddActionEvent(string actionEventTypeName, string actionEventName, L audioFile.Sounds.Add(sound.Id); } } + } + + public void AddPauseResumeStopActionEvent(string actionEventTypeName, string actionEventName) + { + var usedHircIds = IdGenerator.GetUsedHircIds(_audioRepository, _audioEditorStateService.AudioProject); + 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); } } @@ -99,19 +115,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) diff --git a/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioFilesExplorer/AudioFilesExplorerView.xaml index b6eb30ce3..5b6fcf429 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 d98df912f..745919288 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/AudioProjectEditorView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml index 830ee87c4..089580332 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorView.xaml @@ -47,7 +47,7 @@ Grid.Column="0" Content="Add Row" ToolTipService.ShowOnDisabled="True" - Command="{Binding AddRowToViewerCommand}" + Command="{Binding AddRowsToViewerCommand}" Margin="5, 0, 0, 0" Width="70" VerticalAlignment="Center" @@ -60,7 +60,7 @@ - + diff --git a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs index 5f1744c2e..67a207440 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/AudioProjectEditorViewModel.cs @@ -98,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) @@ -114,7 +114,7 @@ private void OnAudioProjectExplorerNodeSelected(AudioProjectExplorerNodeSelected { MakeEditorVisible(); SetEditorLabel(WpfHelpers.DuplicateUnderscores(selectedAudioProjectExplorerNode.Name)); - Load(selectedAudioProjectExplorerNode.Type); + LoadTable(selectedAudioProjectExplorerNode.Type); } else return; @@ -197,14 +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 (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); @@ -243,10 +240,44 @@ private void Load(AudioProjectTreeNodeType selectedNodeType) private void OnEditorAddRowShortcutActivated(EditorAddRowShortcutActivatedEvent e) { if (_audioEditorStateService.EditorRow != null) - AddRowToViewer(); + AddRowsToViewer(); } - [RelayCommand] public void AddRowToViewer() => _uiCommandFactory.Create().Execute(Table.Rows[0]); + [RelayCommand] public void AddRowsToViewer() + { + 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 + // We put the Play Action Event first in the list so it's created before the others as they need to reference it + 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) { @@ -256,7 +287,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/EditorTableServiceFactory.cs b/Editors/Audio/AudioEditor/Presentation/AudioProjectEditor/Table/EditorTableServiceFactory.cs index 902dde6f5..faf1c3396 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/AudioProjectViewerView.xaml b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml index 4f4e6ee1d..bb1460c05 100644 --- a/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml +++ b/Editors/Audio/AudioEditor/Presentation/AudioProjectViewer/AudioProjectViewerView.xaml @@ -5,15 +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"> - + - + + - + @@ -56,11 +60,14 @@ - - + + - + @@ -69,8 +76,8 @@