Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,24 +17,16 @@ public class SetAudioFilesCommand(IAudioEditorStateService audioEditorStateServi

public void Execute(List<AudioFilesTreeNode> selectedAudioFiles, bool addToExistingAudioFiles)
{
var usedSourceIds = new HashSet<uint>();
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<AudioFile>();
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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -7,7 +8,7 @@

namespace Editors.Audio.AudioEditor.Commands.AudioProjectEditor
{
public class AddEditorRowToViewerCommand(
public class AddRowsToViewerCommand(
IAudioEditorStateService audioEditorStateService,
IAudioProjectMutationUICommandFactory audioProjectMutationUICommandFactory,
IEventHub eventHub) : IUiCommand
Expand All @@ -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<DataRow> 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());
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<AudioFile>();

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<KeyValuePair<string, string>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Editors.Audio.AudioEditor.Commands.AudioProjectViewer
{
public class EditViewerRowCommand(
public class EditViewerRowsCommand(
IAudioEditorStateService audioEditorStateService,
IUiCommandFactory uiCommandFactory,
IEventHub eventHub) : IUiCommand
Expand All @@ -17,14 +17,14 @@ public class EditViewerRowCommand(
private readonly IUiCommandFactory _uiCommandFactory = uiCommandFactory;
private readonly IEventHub _eventHub = eventHub;

private readonly ILogger _logger = Logging.Create<EditViewerRowCommand>();
private readonly ILogger _logger = Logging.Create<EditViewerRowsCommand>();

public void Execute(List<DataRow> selectedViewerRows)
public void Execute(List<DataRow> 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<RemoveViewerRowsCommand>().Execute(selectedViewerRows);
_uiCommandFactory.Create<RemoveViewerRowsCommand>().Execute(rows);

var selectedAudioProjectExplorerNode = _audioEditorStateService.SelectedAudioProjectExplorerNode;
_logger.Here().Information($"Editing {selectedAudioProjectExplorerNode.Type} row in Audio Project Viewer table for {selectedAudioProjectExplorerNode.Name}");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ public class RemoveViewerRowsCommand(
private readonly IAudioProjectMutationUICommandFactory _audioProjectMutationUICommandFactory = audioProjectMutationUICommandFactory;
private readonly IEventHub _eventHub = eventHub;

public void Execute(List<DataRow> selectedViewerRows)
public void Execute(List<DataRow> 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());
Expand Down
3 changes: 2 additions & 1 deletion Editors/Audio/AudioEditor/Core/AudioEditorFileService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down
12 changes: 3 additions & 9 deletions Editors/Audio/AudioEditor/Core/AudioEditorIntegrityService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<uint>();
usedSourceIds.UnionWith(audioProjectSourceIds);
usedSourceIds.UnionWith(languageSourceIds);
var usedSourceIds = IdGenerator.GetUsedSourceIds(_audioRepository, audioProject);

var audioProjectSounds = audioProject.GetSounds();
foreach (var audioFile in audioProject.AudioFiles)
Expand Down Expand Up @@ -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);
}

Expand Down
Loading
Loading