mirror of
https://github.com/4sval/FModel.git
synced 2026-04-18 15:47:43 -05:00
Improved audio/version exceptions
This commit is contained in:
parent
b434334b93
commit
96a2692994
|
|
@ -1 +1 @@
|
|||
Subproject commit b0ddd7ab172b306f5596a3371f5451aebe3272c9
|
||||
Subproject commit 8f9967c2a474b1db84400bff5bcb012f28965281
|
||||
|
|
@ -28,7 +28,6 @@ public static class Constants
|
|||
public const string YELLOW = "#E5C07B";
|
||||
public const string BLUE = "#528BCC";
|
||||
|
||||
public const string MAPPING_ISSUE_LINK = "https://github.com/4sval/FModel/discussions/418";
|
||||
public const string ISSUE_LINK = "https://github.com/4sval/FModel/discussions/categories/q-a";
|
||||
public const string GH_REPO = "https://api.github.com/repos/4sval/FModel";
|
||||
public const string GH_COMMITS_HISTORY = GH_REPO + "/commits";
|
||||
|
|
@ -41,6 +40,11 @@ public static class Constants
|
|||
|
||||
public const string _NO_PRESET_TRIGGER = "Hand Made";
|
||||
|
||||
// Common issues
|
||||
public const string MAPPING_ISSUE_LINK = "https://github.com/4sval/FModel/discussions/418";
|
||||
public const string AUDIO_ISSUE_LINK = DISCORD_LINK; // TODO: add me please
|
||||
public const string VERSION_ISSUE_LINK = "https://github.com/4sval/FModel/discussions/425";
|
||||
|
||||
public static int PALETTE_LENGTH => COLOR_PALETTE.Length;
|
||||
public static readonly Vector3[] COLOR_PALETTE =
|
||||
{
|
||||
|
|
|
|||
|
|
@ -298,13 +298,23 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
Save(a, true);
|
||||
}
|
||||
|
||||
FLogger.Append(ELog.Information, () =>
|
||||
{
|
||||
FLogger.Text("Successfully saved audio from ", Constants.WHITE);
|
||||
FLogger.Link(_audioFiles.First().FileName, _audioFiles.First().FilePath, true);
|
||||
});
|
||||
if (_audioFiles.Count > 1)
|
||||
FLogger.Append(ELog.Information, () => FLogger.Text($"Successfully saved {_audioFiles.Count} audio files", Constants.WHITE, true));
|
||||
{
|
||||
var dir = new DirectoryInfo(Path.GetDirectoryName(_audioFiles.First().FilePath));
|
||||
FLogger.Append(ELog.Information, () =>
|
||||
{
|
||||
FLogger.Text($"Successfully saved {_audioFiles.Count} audio files to ", Constants.WHITE);
|
||||
FLogger.Link(dir.Name, dir.FullName, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
FLogger.Append(ELog.Information, () =>
|
||||
{
|
||||
FLogger.Text("Successfully saved ", Constants.WHITE);
|
||||
FLogger.Link(_audioFiles.First().FileName, _audioFiles.First().FilePath, true);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -654,15 +664,24 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
}
|
||||
}
|
||||
|
||||
private bool TryConvert(out string wavFilePath) => TryConvert(SelectedAudioFile.FilePath, SelectedAudioFile.Data, out wavFilePath);
|
||||
public static bool TryConvert(string inputFilePath, byte[] inputFileData, out string wavFilePath)
|
||||
private bool TryConvert(out string wavFilePath) => TryConvert(SelectedAudioFile.FilePath, SelectedAudioFile.Data, out wavFilePath, true);
|
||||
public static bool TryConvert(string inputFilePath, byte[] inputFileData, out string wavFilePath, bool updateUi = false)
|
||||
{
|
||||
wavFilePath = string.Empty;
|
||||
var vgmFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "test.exe");
|
||||
if (!File.Exists(vgmFilePath))
|
||||
{
|
||||
vgmFilePath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", "vgmstream-cli.exe");
|
||||
if (!File.Exists(vgmFilePath)) return false;
|
||||
if (!File.Exists(vgmFilePath))
|
||||
{
|
||||
Log.Error($"Failed to convert {inputFilePath}, VgmStream is missing");
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Failed to convert audio. VgmStream is missing. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.AUDIO_ISSUE_LINK, true);
|
||||
});
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(inputFilePath.SubstringBeforeLast("/"));
|
||||
|
|
@ -679,7 +698,22 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
vgmProcess?.WaitForExit(5000);
|
||||
|
||||
File.Delete(inputFilePath);
|
||||
return vgmProcess?.ExitCode == 0 && File.Exists(wavFilePath);
|
||||
|
||||
var success = vgmProcess?.ExitCode == 0 && File.Exists(wavFilePath);
|
||||
if (!success)
|
||||
{
|
||||
Log.Error($"Failed to convert {inputFilePath} to .wav format");
|
||||
if (updateUi)
|
||||
{
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Failed to convert audio to .wav format. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.AUDIO_ISSUE_LINK, true);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
private bool TryDecode(string extension, out string rawFilePath)
|
||||
|
|
|
|||
|
|
@ -1179,7 +1179,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
case USoundWave when isNone || saveAudio:
|
||||
{
|
||||
// If UAkMediaAsset exists in the same package it should be used to handle the audio instead (because it contains actual audio name)
|
||||
if (pointer.Object.Value is UAkMediaAssetData dataObj && dataObj.Outer is UAkMediaAsset)
|
||||
if (pointer.Object.Value is UAkMediaAssetData dataObj && dataObj.Outer.Object.Value is UAkMediaAsset)
|
||||
return false;
|
||||
|
||||
var shouldDecompress = UserSettings.Default.CompressedAudioMode == ECompressedAudio.PlayDecompressed;
|
||||
|
|
@ -1416,25 +1416,15 @@ public class CUE4ParseViewModel : ViewModel
|
|||
writer.Flush();
|
||||
}
|
||||
|
||||
bool conversionSuccess = true;
|
||||
if (UserSettings.Default.ConvertAudioOnBulkExport)
|
||||
{
|
||||
AudioPlayerViewModel.TryConvert(savedAudioPath, data, out string wavFilePath);
|
||||
if (!string.IsNullOrEmpty(wavFilePath))
|
||||
{
|
||||
savedAudioPath = wavFilePath;
|
||||
}
|
||||
else if (updateUi)
|
||||
{
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Failed to convert audio to WAV format, aborting extraction.", Constants.WHITE, true);
|
||||
});
|
||||
return;
|
||||
}
|
||||
conversionSuccess = AudioPlayerViewModel.TryConvert(savedAudioPath, data, out string wavFilePath);
|
||||
if (conversionSuccess) savedAudioPath = wavFilePath;
|
||||
}
|
||||
|
||||
Log.Information("Successfully saved {FilePath}", savedAudioPath);
|
||||
if (updateUi)
|
||||
if (updateUi && conversionSuccess)
|
||||
{
|
||||
FLogger.Append(ELog.Information, () =>
|
||||
{
|
||||
|
|
|
|||
|
|
@ -101,17 +101,26 @@ public class ThreadWorkerViewModel : ViewModel
|
|||
CurrentCancellationTokenSource = null; // kill token
|
||||
|
||||
Log.Error("{Exception}", e);
|
||||
if (e is MappingException)
|
||||
switch (e)
|
||||
{
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Package has unversioned properties but mapping file (.usmap) is missing, can't serialize. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.MAPPING_ISSUE_LINK, true);
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
FLogger.Append(e);
|
||||
case MappingException:
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Package has unversioned properties but mapping file (.usmap) is missing, can't serialize. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.MAPPING_ISSUE_LINK, true);
|
||||
});
|
||||
break;
|
||||
case VersionException: // Error might be unrelated to version, but it's usually the case
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text("Can't serialize. Make sure you've configured correct UE version first. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.VERSION_ISSUE_LINK, true);
|
||||
});
|
||||
FLogger.Append(e);
|
||||
break;
|
||||
default:
|
||||
FLogger.Append(e);
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user