diff --git a/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs b/Editors/Audio/AudioEditor/Commands/AudioFilesExplorer/SetAudioFilesCommand.cs index 1d53fa222..6778ec05f 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,24 +17,16 @@ 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); - audioFile = AudioFile.Create(audioFileIds.Guid, audioFileIds.Id, wavFile.FileName, wavFile.FilePath); + audioFile = new AudioFile(audioFileIds.Guid, audioFileIds.Id, wavFile.FileName, wavFile.FilePath); } audioFiles.Add(audioFile); } 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/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/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/AudioEditorFileService.cs b/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs index d96c0fcdb..5730bb4b9 100644 --- a/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs @@ -82,7 +82,8 @@ public void Load(AudioProjectFile audioProject, string fileName, string filePath // We create a 'dirty' Audio Project to display the whole model in the Audio Project Explorer rather than // just the clean data from the loaded Audio Project as any unused parts are removed when it's saved var currentGame = _applicationSettingsService.CurrentSettings.CurrentGame; - var dirtyAudioProject = AudioProjectFile.Create(audioProject, currentGame, fileNameWithoutExtension); + var dirtyAudioProject = AudioProjectFile.Create(currentGame, audioProject.Language, fileNameWithoutExtension); + AudioProjectFileMerger.Merge(dirtyAudioProject, audioProject, fileNameWithoutExtension, fileNameWithoutExtension); _audioRepository.Load([audioProject.Language]); diff --git a/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs b/Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs index d3c71ebf5..e6d3339d7 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) @@ -244,10 +238,10 @@ public void CheckAudioProjectDataIntegrity(AudioProjectFile audioProject, string { ResolveSoundBankDataIntegrity(audioProject, audioProjectNameWithoutExtension, soundBank); - if (soundBank.ActionEvents != null) + if (soundBank.ActionEvents.Count != 0) ResolveActionEventDataIntegrity(usedHircIds, usedSourceIds, soundBank); - if (soundBank.DialogueEvents != null) + if (soundBank.DialogueEvents.Count != 0) ResolveDialogueEventDataIntegrity(usedHircIds, usedSourceIds, soundBank); } diff --git a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs index 12b3cc2cd..d8773d5db 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/ActionEventService.cs @@ -2,18 +2,20 @@ 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; 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); } @@ -23,23 +25,10 @@ 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 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,55 +64,72 @@ 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)) 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); - if (soundBank.GameSoundBank == Wh3SoundBank.GlobalMusic) + var actionEventSuffix = TableHelpers.RemoveActionEventPrefix(actionEventName); + var playActionEvent = soundBank.GetActionEvent($"Play_{actionEventSuffix}"); + + 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); } } 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); - 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) @@ -131,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()) { @@ -145,13 +151,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/Core/AudioProjectMutation/StateService.cs b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/StateService.cs index d23f6d4c4..acdeff069 100644 --- a/Editors/Audio/AudioEditor/Core/AudioProjectMutation/StateService.cs +++ b/Editors/Audio/AudioEditor/Core/AudioProjectMutation/StateService.cs @@ -15,7 +15,7 @@ public class StateService(IAudioEditorStateService audioEditorStateService) : IS public void AddState(string stateGroupName, string stateName) { var stateGroup = _audioEditorStateService.AudioProject.GetStateGroup(stateGroupName); - var state = State.Create(stateName); + var state = new State(stateName); stateGroup.States.InsertAlphabetically(state); } 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/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/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/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 26949bbe1..67a207440 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,20 +197,18 @@ 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))) { 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,12 +226,12 @@ 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(); - 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/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/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/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/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 @@