AWB json converter, fix paths

This commit is contained in:
Masusder 2025-11-07 22:47:21 +01:00
parent 2888c9261c
commit c525243c50
3 changed files with 24 additions and 24 deletions

@ -1 +1 @@
Subproject commit 40813f382f3f7ab92cbc3597b1f2ab8b29db836a
Subproject commit b4ac4238fea01ef2ca2cb3849d135552e320ea9a

View File

@ -586,11 +586,10 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
{
byte[] wavData = HcaWaveStream.ConvertHcaToWav(SelectedAudioFile.Data, UserSettings.Default.CurrentDir.CriwareDecryptionKey);
string outputDir = Path.Combine(UserSettings.Default.OutputDirectory, ".data");
Directory.CreateDirectory(outputDir);
string wavFilePath = Path.Combine(UserSettings.Default.AudioDirectory, SelectedAudioFile.FilePath.TrimStart('/'));
wavFilePath = Path.ChangeExtension(wavFilePath, ".wav");
string wavFilePath = Path.Combine(outputDir,
Path.ChangeExtension(SelectedAudioFile.FileName, ".wav"));
Directory.CreateDirectory(Path.GetDirectoryName(wavFilePath)!);
File.WriteAllBytes(wavFilePath, wavData);
@ -601,12 +600,13 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
}
catch (CriwareDecryptionException ex)
{
FLogger.Append(ELog.Error, () => FLogger.Text($"Failed to convert HCA: '{ex.Message}'", Constants.WHITE, true));
Log.Error($"Failed to convert HCA: {ex.Message}");
FLogger.Append(ELog.Error, () => FLogger.Text($"Encrypted HCA: {ex.Message}", Constants.WHITE, true));
Log.Error($"Encrypted HCA: {ex.Message}");
return false;
}
catch (Exception ex)
{
FLogger.Append(ELog.Error, () => FLogger.Text($"Failed to convert HCA: {ex.Message}", Constants.WHITE, true));
Log.Error($"Failed to convert HCA: {ex.Message}");
return false;
}

View File

@ -781,6 +781,8 @@ public class CUE4ParseViewModel : ViewModel
var archive = entry.CreateReader();
var awbReader = new AwbReader(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(awbReader, Formatting.Indented), saveProperties, updateUi);
var extractedSounds = CriWareProvider.ExtractCriWareSounds(awbReader, archive.Name);
foreach (var sound in extractedSounds)
{
@ -1029,26 +1031,24 @@ public class CUE4ParseViewModel : ViewModel
}
return false;
}
case USoundAtomCueSheet when isNone && pointer.Object.Value is USoundAtomCueSheet atomCueSheet:
case USoundAtomCueSheet or UAtomCueSheet or USoundAtomCue or UAtomWaveBank when (isNone || saveAudio) && pointer.Object.Value is UObject atomObject:
{
var extractedSounds = atomObject switch
{
var extractedSounds = CriWareProvider.ExtractCriWareSounds(atomCueSheet);
var directory = Path.GetDirectoryName(atomCueSheet.Owner?.Name) ?? "/Criware/";
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio);
}
return false;
}
case UAtomCueSheet when isNone && pointer.Object.Value is UAtomCueSheet atomCueSheet:
USoundAtomCueSheet cueSheet => CriWareProvider.ExtractCriWareSounds(cueSheet),
UAtomCueSheet cueSheet => CriWareProvider.ExtractCriWareSounds(cueSheet),
USoundAtomCue cue => CriWareProvider.ExtractCriWareSounds(cue),
UAtomWaveBank awb => CriWareProvider.ExtractCriWareSounds(awb),
_ => []
};
var directory = Path.GetDirectoryName(atomObject.Owner?.Name) ?? "/Criware/";
foreach (var sound in extractedSounds)
{
var extractedSounds = CriWareProvider.ExtractCriWareSounds(atomCueSheet);
var directory = Path.GetDirectoryName(atomCueSheet.Owner?.Name) ?? "/Criware/";
foreach (var sound in extractedSounds)
{
SaveAndPlaySound(Path.Combine(directory, sound.Name), sound.Extension, sound.Data, saveAudio);
}
return false;
SaveAndPlaySound(Path.Combine(directory, sound.Name).Replace("\\", "/"), sound.Extension, sound.Data, saveAudio);
}
return false;
}
case UAkMediaAssetData when isNone || saveAudio:
case USoundWave when isNone || saveAudio:
{