mirror of
https://github.com/4sval/FModel.git
synced 2026-06-21 07:20:05 -05:00
Undawn lua, Fixed Criware/Rada bulk audio conversion
Some checks are pending
FModel QA Builder / build (push) Waiting to run
Some checks are pending
FModel QA Builder / build (push) Waiting to run
This commit is contained in:
parent
2c2123d601
commit
b1c7734957
|
|
@ -1 +1 @@
|
|||
Subproject commit ecc4878950336126f125af0747190edf474b2a21
|
||||
Subproject commit cf74fc32fe1b40e9fd3440032508c5e1d50cf58d
|
||||
|
|
@ -1,58 +1,76 @@
|
|||
<SyntaxDefinition name="Lua" extensions=".lua;.luac" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
|
||||
<Color name="Keyword1" foreground="#C586C0" fontWeight="bold" />
|
||||
<Color name="Keyword2" foreground="#569CD6" fontWeight="bold" />
|
||||
<Color name="Comment" foreground="#6A9955" />
|
||||
<Color name="String" foreground="#D69D85" />
|
||||
<Color name="Number" foreground="#B5CEA8" />
|
||||
<Color name="Function" foreground="#DCDCAA" />
|
||||
<Color name="Punctuation" foreground="#89DDFF" />
|
||||
<Color name="ObjectName" foreground="#3DC9B0" />
|
||||
<Color name="Constant" foreground="#9CDCFE" />
|
||||
<Color name="Keyword1" foreground="#d8a0df" fontWeight="bold" />
|
||||
<Color name="Keyword2" foreground="#569cd6" fontWeight="bold" />
|
||||
<Color name="Self" foreground="#569cd6" fontStyle="italic" />
|
||||
<Color name="Function" foreground="#dcdcaa" />
|
||||
<Color name="ObjectName" foreground="#4ec9b0" />
|
||||
<Color name="Property" foreground="#abd4a2" />
|
||||
<Color name="String" foreground="#f4ab6b" />
|
||||
<Color name="Number" foreground="#ff9e64" />
|
||||
<Color name="Comment" foreground="#565f89" fontStyle="italic" />
|
||||
<Color name="Punctuation" foreground="#89ddff" />
|
||||
<Color name="Constant" foreground="#e0af68" />
|
||||
<Color name="Metamethod" foreground="#bb9af7" fontStyle="italic" />
|
||||
<Color name="GotoLabel" foreground="#7dcfff" />
|
||||
<Color name="Discard" foreground="#3b4261" />
|
||||
|
||||
<RuleSet>
|
||||
<Rule color="Comment">--\[\[(.|\n)*?\]\]</Rule>
|
||||
<Rule color="Comment">--.*$</Rule>
|
||||
|
||||
<Rule color="String">\[\[(.|\n)*?\]\]</Rule>
|
||||
<Rule color="String">"([^"\\]|\\.)*"</Rule>
|
||||
<Rule color="String">'([^'\\]|\\.)*'</Rule>
|
||||
|
||||
<Rule color="Number">\b0[xX][0-9A-Fa-f]+\b</Rule>
|
||||
<Rule color="Number">\b\d+\.\d+([eE][+-]?\d+)?\b</Rule>
|
||||
<Rule color="Number">\b\d+[eE][+-]?\d+\b</Rule>
|
||||
<Rule color="Number">\b\d+\b</Rule>
|
||||
|
||||
<Keywords color="Keyword1">
|
||||
<Word>return</Word>
|
||||
<Word>function</Word>
|
||||
<Word>goto</Word>
|
||||
<Word>end</Word>
|
||||
<Word>if</Word>
|
||||
<Word>and</Word>
|
||||
<Word>break</Word>
|
||||
<Word>do</Word>
|
||||
<Word>else</Word>
|
||||
<Word>elseif</Word>
|
||||
<Word>then</Word>
|
||||
<Word>end</Word>
|
||||
<Word>for</Word>
|
||||
<Word>function</Word>
|
||||
<Word>goto</Word>
|
||||
<Word>if</Word>
|
||||
<Word>in</Word>
|
||||
<Word>or</Word>
|
||||
<Word>repeat</Word>
|
||||
<Word>return</Word>
|
||||
<Word>then</Word>
|
||||
<Word>until</Word>
|
||||
<Word>while</Word>
|
||||
<Word>break</Word>
|
||||
<Word>or</Word>
|
||||
<Word>and</Word>
|
||||
<Word>repeat</Word>
|
||||
<Word>do</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="Keyword2">
|
||||
<Word>false</Word>
|
||||
<Word>local</Word>
|
||||
<Word>nil</Word>
|
||||
<Word>not</Word>
|
||||
<Word>true</Word>
|
||||
<Word>false</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="Self">
|
||||
<Word>self</Word>
|
||||
<Word>_G</Word>
|
||||
<Word>_ENV</Word>
|
||||
</Keywords>
|
||||
|
||||
<Keywords color="Function">
|
||||
<!-- Core functions -->
|
||||
<Word>assert</Word>
|
||||
<Word>collectgarbage</Word>
|
||||
<Word>dofile</Word>
|
||||
<Word>error</Word>
|
||||
<Word>getmetatable</Word>
|
||||
<Word>ipairs</Word>
|
||||
<Word>load</Word>
|
||||
<Word>loadfile</Word>
|
||||
<Word>module</Word>
|
||||
<Word>next</Word>
|
||||
<Word>pairs</Word>
|
||||
<Word>pcall</Word>
|
||||
|
|
@ -61,128 +79,24 @@
|
|||
<Word>rawget</Word>
|
||||
<Word>rawlen</Word>
|
||||
<Word>rawset</Word>
|
||||
<Word>require</Word>
|
||||
<Word>select</Word>
|
||||
<Word>setmetatable</Word>
|
||||
<Word>tonumber</Word>
|
||||
<Word>tostring</Word>
|
||||
<Word>type</Word>
|
||||
<Word>unpack</Word>
|
||||
<Word>xpcall</Word>
|
||||
<Word>getmetatable</Word>
|
||||
<Word>require</Word>
|
||||
<Word>module</Word>
|
||||
|
||||
<!-- Modules / tables -->
|
||||
<Word>bit32</Word>
|
||||
<Word>coroutine</Word>
|
||||
<Word>debug</Word>
|
||||
<Word>io</Word>
|
||||
<Word>math</Word>
|
||||
<Word>os</Word>
|
||||
<Word>package</Word>
|
||||
<Word>string</Word>
|
||||
<Word>table</Word>
|
||||
<Word>coroutine</Word>
|
||||
<Word>os</Word>
|
||||
<Word>io</Word>
|
||||
<Word>utf8</Word>
|
||||
<Word>bit32</Word>
|
||||
<Word>package</Word>
|
||||
<Word>debug</Word>
|
||||
|
||||
<!-- Bit32 / bitwise functions -->
|
||||
<Word>arshift</Word>
|
||||
<Word>band</Word>
|
||||
<Word>bnot</Word>
|
||||
<Word>bor</Word>
|
||||
<Word>bxor</Word>
|
||||
<Word>btest</Word>
|
||||
<Word>extract</Word>
|
||||
<Word>lrotate</Word>
|
||||
<Word>lshift</Word>
|
||||
<Word>replace</Word>
|
||||
<Word>rrotate</Word>
|
||||
<Word>rshift</Word>
|
||||
|
||||
<!-- Coroutine functions -->
|
||||
<Word>create</Word>
|
||||
<Word>resume</Word>
|
||||
<Word>running</Word>
|
||||
<Word>status</Word>
|
||||
<Word>wrap</Word>
|
||||
<Word>yield</Word>
|
||||
<Word>isyieldable</Word>
|
||||
|
||||
<!-- Debug functions -->
|
||||
<Word>getuservalue</Word>
|
||||
<Word>gethook</Word>
|
||||
<Word>getinfo</Word>
|
||||
<Word>getlocal</Word>
|
||||
<Word>getregistry</Word>
|
||||
<Word>getupvalue</Word>
|
||||
<Word>upvaluejoin</Word>
|
||||
<Word>upvalueid</Word>
|
||||
<Word>setuservalue</Word>
|
||||
<Word>sethook</Word>
|
||||
<Word>setlocal</Word>
|
||||
<Word>setupvalue</Word>
|
||||
<Word>traceback</Word>
|
||||
|
||||
<!-- IO functions -->
|
||||
<Word>close</Word>
|
||||
<Word>flush</Word>
|
||||
<Word>input</Word>
|
||||
<Word>lines</Word>
|
||||
<Word>open</Word>
|
||||
<Word>output</Word>
|
||||
<Word>popen</Word>
|
||||
<Word>read</Word>
|
||||
<Word>tmpfile</Word>
|
||||
<Word>seek</Word>
|
||||
<Word>setvbuf</Word>
|
||||
<Word>write</Word>
|
||||
|
||||
<!-- String functions -->
|
||||
<Word>byte</Word>
|
||||
<Word>char</Word>
|
||||
<Word>dump</Word>
|
||||
<Word>find</Word>
|
||||
<Word>format</Word>
|
||||
<Word>gmatch</Word>
|
||||
<Word>gsub</Word>
|
||||
<Word>len</Word>
|
||||
<Word>lower</Word>
|
||||
<Word>match</Word>
|
||||
<Word>rep</Word>
|
||||
<Word>reverse</Word>
|
||||
<Word>sub</Word>
|
||||
<Word>upper</Word>
|
||||
<Word>pack</Word>
|
||||
<Word>packsize</Word>
|
||||
<Word>unpack</Word>
|
||||
<Word>concat</Word>
|
||||
<Word>maxn</Word>
|
||||
<Word>insert</Word>
|
||||
<Word>move</Word>
|
||||
<Word>offset</Word>
|
||||
<Word>codepoint</Word>
|
||||
<Word>codes</Word>
|
||||
<Word>charpattern</Word>
|
||||
|
||||
<!-- OS / Time functions -->
|
||||
<Word>clock</Word>
|
||||
<Word>date</Word>
|
||||
<Word>difftime</Word>
|
||||
<Word>execute</Word>
|
||||
<Word>exit</Word>
|
||||
<Word>getenv</Word>
|
||||
<Word>remove</Word>
|
||||
<Word>rename</Word>
|
||||
<Word>setlocale</Word>
|
||||
<Word>time</Word>
|
||||
<Word>loadlib</Word>
|
||||
<Word>searchpath</Word>
|
||||
<Word>seeall</Word>
|
||||
<Word>preload</Word>
|
||||
<Word>cpath</Word>
|
||||
<Word>path</Word>
|
||||
<Word>searchers</Word>
|
||||
<Word>loaded</Word>
|
||||
|
||||
<!-- Math functions / constants -->
|
||||
<Word>abs</Word>
|
||||
<Word>acos</Word>
|
||||
<Word>asin</Word>
|
||||
|
|
@ -195,36 +109,140 @@
|
|||
<Word>exp</Word>
|
||||
<Word>floor</Word>
|
||||
<Word>fmod</Word>
|
||||
<Word>ult</Word>
|
||||
<Word>frexp</Word>
|
||||
<Word>huge</Word>
|
||||
<Word>ldexp</Word>
|
||||
<Word>log</Word>
|
||||
<Word>log10</Word>
|
||||
<Word>max</Word>
|
||||
<Word>maxinteger</Word>
|
||||
<Word>min</Word>
|
||||
<Word>mininteger</Word>
|
||||
<Word>modf</Word>
|
||||
<Word>pi</Word>
|
||||
<Word>pow</Word>
|
||||
<Word>rad</Word>
|
||||
<Word>random</Word>
|
||||
<Word>randomseed</Word>
|
||||
<Word>sin</Word>
|
||||
<Word>sinh</Word>
|
||||
<Word>sqrt</Word>
|
||||
<Word>tan</Word>
|
||||
<Word>sinh</Word>
|
||||
<Word>tanh</Word>
|
||||
<Word>pow</Word>
|
||||
<Word>frexp</Word>
|
||||
<Word>ldexp</Word>
|
||||
<Word>huge</Word>
|
||||
<Word>maxinteger</Word>
|
||||
<Word>mininteger</Word>
|
||||
<Word>tointeger</Word>
|
||||
<Word>ult</Word>
|
||||
<Word>byte</Word>
|
||||
<Word>char</Word>
|
||||
<Word>dump</Word>
|
||||
<Word>find</Word>
|
||||
<Word>format</Word>
|
||||
<Word>gmatch</Word>
|
||||
<Word>gsub</Word>
|
||||
<Word>len</Word>
|
||||
<Word>lower</Word>
|
||||
<Word>match</Word>
|
||||
<Word>pack</Word>
|
||||
<Word>packsize</Word>
|
||||
<Word>rep</Word>
|
||||
<Word>reverse</Word>
|
||||
<Word>sub</Word>
|
||||
<Word>upper</Word>
|
||||
<Word>concat</Word>
|
||||
<Word>insert</Word>
|
||||
<Word>maxn</Word>
|
||||
<Word>move</Word>
|
||||
<Word>remove</Word>
|
||||
<Word>sort</Word>
|
||||
<Word>close</Word>
|
||||
<Word>flush</Word>
|
||||
<Word>input</Word>
|
||||
<Word>lines</Word>
|
||||
<Word>open</Word>
|
||||
<Word>output</Word>
|
||||
<Word>popen</Word>
|
||||
<Word>read</Word>
|
||||
<Word>seek</Word>
|
||||
<Word>setvbuf</Word>
|
||||
<Word>tmpfile</Word>
|
||||
<Word>write</Word>
|
||||
<Word>clock</Word>
|
||||
<Word>date</Word>
|
||||
<Word>difftime</Word>
|
||||
<Word>execute</Word>
|
||||
<Word>exit</Word>
|
||||
<Word>getenv</Word>
|
||||
<Word>rename</Word>
|
||||
<Word>setlocale</Word>
|
||||
<Word>time</Word>
|
||||
<Word>create</Word>
|
||||
<Word>isyieldable</Word>
|
||||
<Word>resume</Word>
|
||||
<Word>running</Word>
|
||||
<Word>status</Word>
|
||||
<Word>wrap</Word>
|
||||
<Word>yield</Word>
|
||||
<Word>arshift</Word>
|
||||
<Word>band</Word>
|
||||
<Word>bnot</Word>
|
||||
<Word>bor</Word>
|
||||
<Word>btest</Word>
|
||||
<Word>bxor</Word>
|
||||
<Word>extract</Word>
|
||||
<Word>lrotate</Word>
|
||||
<Word>lshift</Word>
|
||||
<Word>replace</Word>
|
||||
<Word>rrotate</Word>
|
||||
<Word>rshift</Word>
|
||||
<Word>charpattern</Word>
|
||||
<Word>codepoint</Word>
|
||||
<Word>codes</Word>
|
||||
<Word>offset</Word>
|
||||
<Word>gethook</Word>
|
||||
<Word>getinfo</Word>
|
||||
<Word>getlocal</Word>
|
||||
<Word>getregistry</Word>
|
||||
<Word>getupvalue</Word>
|
||||
<Word>getuservalue</Word>
|
||||
<Word>sethook</Word>
|
||||
<Word>setlocal</Word>
|
||||
<Word>setupvalue</Word>
|
||||
<Word>setuservalue</Word>
|
||||
<Word>traceback</Word>
|
||||
<Word>upvalueid</Word>
|
||||
<Word>upvaluejoin</Word>
|
||||
<Word>cpath</Word>
|
||||
<Word>loaded</Word>
|
||||
<Word>loadlib</Word>
|
||||
<Word>path</Word>
|
||||
<Word>preload</Word>
|
||||
<Word>searchers</Word>
|
||||
<Word>searchpath</Word>
|
||||
<Word>seeall</Word>
|
||||
</Keywords>
|
||||
|
||||
<Rule color="Punctuation">(\|)|(<<)|(>>)|(\/\/)|(==)|(~=)|(<=)|(>=)|(<)|(>)|(=)|(\()|(\))|(\{)|(\})|(\[)|(\])|(::)|(:)|(;)|(,)|(\.\.\.)|(\.\.)|(\.)|[+\-*%\^#&~]</Rule>
|
||||
|
||||
<Rule color="ObjectName">(?<=function\s)[A-Za-z0-9_]+(?=\.)</Rule>
|
||||
|
||||
<Rule color="Function">(?<=\.)[A-Za-z0-9_]+(?=\()</Rule>
|
||||
<Rule color="Function">(?<=function\s)[A-Za-z0-9_]+(?=\s*\()</Rule> <!-- Standalone function name -->
|
||||
<Rule color="Metamethod">__[A-Za-z_][A-Za-z0-9_]*__</Rule>
|
||||
|
||||
<Rule color="Constant">\b[A-Z_][A-Z0-9_]*\b</Rule>
|
||||
<Rule color="GotoLabel">(?<=::)[A-Za-z_][A-Za-z0-9_]*(?=::)</Rule>
|
||||
|
||||
<Rule color="Discard">(?<![A-Za-z0-9_])_(?![A-Za-z0-9_])</Rule>
|
||||
|
||||
<Rule color="ObjectName">(?<=function\s)[A-Za-z_][A-Za-z0-9_]*(?=\.)</Rule>
|
||||
<Rule color="ObjectName">(?<=function\s)[A-Za-z_][A-Za-z0-9_]*(?=:)</Rule>
|
||||
|
||||
<Rule color="Function">(?<=function\s)[A-Za-z_][A-Za-z0-9_]*(?=\s*\()</Rule>
|
||||
|
||||
<Rule color="ObjectName">[A-Za-z_][A-Za-z0-9_]*(?=\.)</Rule>
|
||||
<Rule color="ObjectName">[A-Za-z_][A-Za-z0-9_]*(?=:)</Rule>
|
||||
|
||||
<Rule color="Function">(?<=:)[A-Za-z_][A-Za-z0-9_]*(?=\s*\()</Rule>
|
||||
<Rule color="Function">(?<=\.)[A-Za-z_][A-Za-z0-9_]*(?=\s*\()</Rule>
|
||||
<Rule color="Function">\b[A-Za-z_][A-Za-z0-9_]*(?=\s*\()</Rule>
|
||||
|
||||
<Rule color="Property">(?<=\.)[A-Za-z_][A-Za-z0-9_]*</Rule>
|
||||
|
||||
<Rule color="Constant">\b[A-Z][A-Z0-9]*_[A-Z0-9_]*\b</Rule>
|
||||
<Rule color="Constant">\b[A-Z]{2}[A-Z0-9_]*\b</Rule>
|
||||
</RuleSet>
|
||||
</SyntaxDefinition>
|
||||
|
|
|
|||
|
|
@ -570,139 +570,126 @@ public class AudioPlayerViewModel : ViewModel, ISource, IDisposable
|
|||
{
|
||||
if (SelectedAudioFile?.Data == null)
|
||||
return false;
|
||||
if (SelectedAudioFile.Extension == "wav")
|
||||
return false;
|
||||
|
||||
switch (SelectedAudioFile.Extension)
|
||||
{
|
||||
case "binka":
|
||||
case "adpcm":
|
||||
case "xvag":
|
||||
case "opus":
|
||||
case "wem":
|
||||
case "at9":
|
||||
case "raw":
|
||||
{
|
||||
if (TryConvert(out var wavFilePath))
|
||||
{
|
||||
var newAudio = new AudioFile(SelectedAudioFile.Id, new FileInfo(wavFilePath));
|
||||
Replace(newAudio);
|
||||
return true;
|
||||
}
|
||||
if (!TryConvert(SelectedAudioFile.FilePath, SelectedAudioFile.Data, SelectedAudioFile.Extension, out var convertedFilePath, true))
|
||||
return false;
|
||||
|
||||
return false;
|
||||
}
|
||||
case "adx":
|
||||
case "hca":
|
||||
return TryConvertCriware();
|
||||
case "rada":
|
||||
{
|
||||
if (TryDecode(SelectedAudioFile.Extension, out var rawFilePath))
|
||||
{
|
||||
var newAudio = new AudioFile(SelectedAudioFile.Id, new FileInfo(rawFilePath));
|
||||
Replace(newAudio);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
var newAudio = new AudioFile(SelectedAudioFile.Id, new FileInfo(convertedFilePath));
|
||||
Replace(newAudio);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryConvertCriware()
|
||||
public static bool TryConvert(string inputFilePath, byte[] inputFileData, string extension, out string wavFilePath, bool updateUi = false)
|
||||
{
|
||||
wavFilePath = string.Empty;
|
||||
|
||||
switch (extension.ToLowerInvariant())
|
||||
{
|
||||
case "hca":
|
||||
case "adx":
|
||||
return TryConvertCriware(inputFilePath, inputFileData, extension, out wavFilePath);
|
||||
case "rada":
|
||||
return TryConvertRada(inputFilePath, inputFileData, extension, out wavFilePath, updateUi);
|
||||
default:
|
||||
{
|
||||
var vgmStreamPath = TryGetVgmstreamPath();
|
||||
if (string.IsNullOrEmpty(vgmStreamPath))
|
||||
return false;
|
||||
|
||||
var success = TryConvertToWav(inputFilePath, inputFileData, vgmStreamPath, true, out wavFilePath);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Log.Error("Failed to convert {InputFilePath} to .wav format", Path.GetFileName(inputFilePath));
|
||||
|
||||
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 static bool TryConvertCriware(string inputFilePath, byte[] inputFileData, string extension, out string wavFilePath)
|
||||
{
|
||||
wavFilePath = string.Empty;
|
||||
|
||||
try
|
||||
{
|
||||
byte[] wavData = SelectedAudioFile.Extension switch
|
||||
byte[] wavData = extension switch
|
||||
{
|
||||
"hca" => HcaWaveStream.ConvertHcaToWav(
|
||||
SelectedAudioFile.Data,
|
||||
UserSettings.Default.CurrentDir.CriwareDecryptionKey),
|
||||
"adx" => AdxDecoder.ConvertAdxToWav(
|
||||
SelectedAudioFile.Data,
|
||||
UserSettings.Default.CurrentDir.CriwareDecryptionKey),
|
||||
"hca" => HcaWaveStream.ConvertHcaToWav(inputFileData, UserSettings.Default.CurrentDir.CriwareDecryptionKey),
|
||||
"adx" => AdxDecoder.ConvertAdxToWav(inputFileData, UserSettings.Default.CurrentDir.CriwareDecryptionKey),
|
||||
_ => throw new NotSupportedException()
|
||||
};
|
||||
|
||||
if (wavData.Length is 0)
|
||||
// Fallback for ADX
|
||||
if (wavData.Length == 0)
|
||||
{
|
||||
if (TryConvert(out var wavFilePathFallback))
|
||||
{
|
||||
var newAudioFallback = new AudioFile(SelectedAudioFile.Id, new FileInfo(wavFilePathFallback));
|
||||
Replace(newAudioFallback);
|
||||
return true;
|
||||
}
|
||||
var vgmStreamPath = TryGetVgmstreamPath();
|
||||
if (string.IsNullOrEmpty(vgmStreamPath))
|
||||
return false;
|
||||
|
||||
return TryConvertToWav(inputFilePath, inputFileData, vgmStreamPath, true, out wavFilePath);
|
||||
}
|
||||
|
||||
string wavFilePath = Path.Combine(
|
||||
UserSettings.Default.AudioDirectory,
|
||||
SelectedAudioFile.FilePath.TrimStart('/'));
|
||||
wavFilePath = Path.ChangeExtension(wavFilePath, ".wav");
|
||||
wavFilePath = Path.ChangeExtension(inputFilePath, ".wav");
|
||||
|
||||
var directory = Path.GetDirectoryName(wavFilePath);
|
||||
if (!string.IsNullOrEmpty(directory))
|
||||
Directory.CreateDirectory(directory);
|
||||
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(wavFilePath)!);
|
||||
File.WriteAllBytes(wavFilePath, wavData);
|
||||
|
||||
var newAudio = new AudioFile(SelectedAudioFile.Id, new FileInfo(wavFilePath));
|
||||
Replace(newAudio);
|
||||
|
||||
return true;
|
||||
}
|
||||
catch (CriwareDecryptionException ex)
|
||||
{
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text($"Encrypted {SelectedAudioFile.Extension.ToUpper()}: {ex.Message}", Constants.WHITE, true));
|
||||
Log.Error($"Encrypted {SelectedAudioFile.Extension.ToUpper()}: {ex.Message}");
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text($"Encrypted {extension.ToUpper()}: {ex.Message}", Constants.WHITE, true));
|
||||
Log.Error($"Encrypted {extension.ToUpper()}: {ex.Message}");
|
||||
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text($"Failed to convert {SelectedAudioFile.Extension.ToUpper()}: {ex.Message}", Constants.WHITE, true));
|
||||
Log.Error($"Failed to convert {SelectedAudioFile.Extension.ToUpper()}: {ex.Message}");
|
||||
FLogger.Append(ELog.Error, () => FLogger.Text($"Failed to convert {extension.ToUpper()}: {ex.Message}", Constants.WHITE, true));
|
||||
Log.Error($"Failed to convert {extension.ToUpper()}: {ex.Message}");
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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 vgmStreamPath = TryGetVgmstreamPath();
|
||||
if (string.IsNullOrEmpty(vgmStreamPath))
|
||||
return false;
|
||||
|
||||
var success = TryConvertToWav(inputFilePath, inputFileData, vgmStreamPath, true, out wavFilePath);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
Log.Error("Failed to convert {InputFilePath} to .wav format", Path.GetFileName(inputFilePath));
|
||||
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)
|
||||
private static bool TryConvertRada(string inputFilePath, byte[] inputFileData, string extension, out string rawFilePath, bool updateUi = false)
|
||||
{
|
||||
rawFilePath = string.Empty;
|
||||
var decoderPath = Path.Combine(UserSettings.Default.OutputDirectory, ".data", $"{extension}dec.exe");
|
||||
if (!File.Exists(decoderPath))
|
||||
{
|
||||
Log.Error("Failed to convert {FilePath}, rada decoder is missing", SelectedAudioFile.FilePath);
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
Log.Error("Failed to convert {FilePath}, {Extension} decoder is missing", inputFilePath, extension);
|
||||
|
||||
if (updateUi)
|
||||
{
|
||||
FLogger.Text("Failed to convert audio because rada decoder is missing. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.RADA_ISSUE_LINK, true);
|
||||
});
|
||||
FLogger.Append(ELog.Error, () =>
|
||||
{
|
||||
FLogger.Text($"Failed to convert audio because {extension} decoder is missing. See: ", Constants.WHITE);
|
||||
FLogger.Link("→ link ←", Constants.RADA_ISSUE_LINK, true);
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return TryConvertToWav(SelectedAudioFile.FilePath, SelectedAudioFile.Data, decoderPath, false, out rawFilePath);
|
||||
return TryConvertToWav(inputFilePath, inputFileData, decoderPath, false, out rawFilePath);
|
||||
}
|
||||
|
||||
private static bool TryConvertToWav(string inputFilePath, byte[] inputFileData, string converterPath, bool usevgmstream, out string wavFilePath)
|
||||
|
|
|
|||
|
|
@ -733,6 +733,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
case "archive":
|
||||
case "dnearchive": // Banishers: Ghosts of New Eden
|
||||
case "gitignore":
|
||||
case "gitattributes":
|
||||
case "LICENSE":
|
||||
case "playstats": // Dispatch
|
||||
case "template":
|
||||
|
|
@ -791,6 +792,8 @@ public class CUE4ParseViewModel : ViewModel
|
|||
case "bl":
|
||||
case "bm":
|
||||
case "br":
|
||||
case "sql":
|
||||
case "cs":
|
||||
{
|
||||
var data = Provider.SaveAsset(entry);
|
||||
using var stream = new MemoryStream(data) { Position = 0 };
|
||||
|
|
@ -1321,8 +1324,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
_ => []
|
||||
};
|
||||
|
||||
var directory = Path.GetDirectoryName(atomObject.Owner?.Name) ?? "/Criware/";
|
||||
directory = Path.GetDirectoryName(atomObject.Owner.Provider.FixPath(directory));
|
||||
var directory = Path.GetDirectoryName(Provider.FixPath(atomObject.Owner?.Name ?? "/Criware/"));
|
||||
foreach (var sound in extractedSounds)
|
||||
{
|
||||
SaveAndPlaySound(cancellationToken, Path.Combine(directory, sound.Name).Replace("\\", "/"), sound.Extension, sound.Data, saveAudio, updateUi);
|
||||
|
|
@ -1616,7 +1618,7 @@ public class CUE4ParseViewModel : ViewModel
|
|||
bool conversionSuccess = true;
|
||||
if (UserSettings.Default.ConvertAudioOnBulkExport && extLower is not "wav")
|
||||
{
|
||||
if (AudioPlayerViewModel.TryConvert(savedAudioPath, data, out string wavFilePath))
|
||||
if (AudioPlayerViewModel.TryConvert(savedAudioPath, data, extLower, out string wavFilePath))
|
||||
savedAudioPath = wavFilePath;
|
||||
else
|
||||
{
|
||||
|
|
|
|||
|
|
@ -350,11 +350,15 @@ public class GameFileViewModel(GameFile asset) : ViewModel
|
|||
case "pem":
|
||||
case "xml":
|
||||
case "gitignore":
|
||||
case "gitattributes":
|
||||
case "html":
|
||||
case "css":
|
||||
case "js":
|
||||
case "data":
|
||||
case "csv":
|
||||
case "sql":
|
||||
case "py":
|
||||
case "cs":
|
||||
AssetCategory = EAssetCategory.Data;
|
||||
break;
|
||||
case "stinfo":
|
||||
|
|
|
|||
|
|
@ -48,6 +48,9 @@
|
|||
<SolidColorBrush x:Key="GitBrush" Color="Coral" />
|
||||
<SolidColorBrush x:Key="CsvBrush" Color="ForestGreen" />
|
||||
<SolidColorBrush x:Key="AIBrush" Color="LightGray" />
|
||||
<SolidColorBrush x:Key="SQLBrush" Color="#00758f" />
|
||||
<SolidColorBrush x:Key="PythonBrush" Color="#3d77a8" />
|
||||
<SolidColorBrush x:Key="CSharpBrush" Color="#9e559a" />
|
||||
|
||||
<!-- For specific games -->
|
||||
<SolidColorBrush x:Key="BorderlandsBrush" Color="Yellow"></SolidColorBrush>
|
||||
|
|
|
|||
|
|
@ -80,10 +80,14 @@ public class FileToGeometryConverter : IMultiValueConverter
|
|||
"bin" => ("DataTableIcon", "BinaryBrush"),
|
||||
"xml" => ("XmlIcon", "JsonXmlBrush"),
|
||||
"gitignore" => ("GitIcon", "GitBrush"),
|
||||
"gitattributes" => ("GitIcon", "GitBrush"),
|
||||
"html" => ("HtmlIcon", "HtmlBrush"),
|
||||
"js" => ("JavaScriptIcon", "JavaScriptBrush"),
|
||||
"css" => ("CssIcon", "CssBrush"),
|
||||
"csv" => ("CsvIcon", "CsvBrush"),
|
||||
"sql" => ("SQLIcon", "SQLBrush"),
|
||||
"py" => ("PythonIcon", "PythonBrush"),
|
||||
"cs" => ("CSharpIcon", "CSharpBrush"),
|
||||
_ => ("DataTableIcon", "NeutralBrush")
|
||||
},
|
||||
|
||||
|
|
|
|||
|
|
@ -99,6 +99,9 @@
|
|||
<Geometry x:Key="CsvIcon">M14 2H6C4.9 2 4 2.9 4 4V20C4 21.1 4.9 22 6 22H18C19.1 22 20 21.1 20 20V8L14 2M15 16L13 20H10L12 16H9V11H15V16M13 9V3.5L18.5 9H13Z</Geometry>
|
||||
<Geometry x:Key="AIIcon">M12,2A2,2 0 0,1 14,4C14,4.74 13.6,5.39 13,5.73V7H14A7,7 0 0,1 21,14H22A1,1 0 0,1 23,15V18A1,1 0 0,1 22,19H21V20A2,2 0 0,1 19,22H5A2,2 0 0,1 3,20V19H2A1,1 0 0,1 1,18V15A1,1 0 0,1 2,14H3A7,7 0 0,1 10,7H11V5.73C10.4,5.39 10,4.74 10,4A2,2 0 0,1 12,2M7.5,13A2.5,2.5 0 0,0 5,15.5A2.5,2.5 0 0,0 7.5,18A2.5,2.5 0 0,0 10,15.5A2.5,2.5 0 0,0 7.5,13M16.5,13A2.5,2.5 0 0,0 14,15.5A2.5,2.5 0 0,0 16.5,18A2.5,2.5 0 0,0 19,15.5A2.5,2.5 0 0,0 16.5,13Z</Geometry>
|
||||
<Geometry x:Key="ImportIcon">M14,12L10,8V11H2V13H10V16M20,18V6C20,4.89 19.1,4 18,4H6A2,2 0 0,0 4,6V9H6V6H18V18H6V15H4V18A2,2 0 0,0 6,20H18A2,2 0 0,0 20,18Z</Geometry>
|
||||
<Geometry x:Key="SQLIcon">M231.822 132.778c1.2-5.152 6.352-8.357 11.505-7.158 5.153 1.2 8.357 6.352 7.158 11.505l-20.773 88.972c-1.199 5.153-6.352 8.358-11.504 7.158-5.153-1.199-8.358-6.352-7.158-11.505l20.772-88.972zM21.123 259.247h16.714V52.395C37.837 23.601 61.438 0 90.232 0h230.505a7.998 7.998 0 016.39 3.183l96.876 104.809a7.937 7.937 0 012.118 5.411h.041v145.844h16.714c11.618 0 21.124 9.525 21.124 21.124v163.863c0 11.599-9.526 21.124-21.124 21.124h-17.058c-3.001 25.877-25.473 46.505-52.051 46.505H90.232c-26.72 0-49.082-20.526-52.055-46.505H21.123C9.526 465.358 0 455.853 0 444.234V280.371c0-11.619 9.506-21.124 21.123-21.124zm32.731 0h356.292V136.525h-32.219v-.033h-.124c-19.111-.302-34.068-5.373-44.736-14.486-11.073-9.458-17.282-22.969-18.52-39.763l-.075-1.098V16.016H90.232c-20.032 0-36.378 16.346-36.378 36.379v206.852zm355.795 206.111H54.344c2.862 17.157 17.981 30.488 35.888 30.488h283.535c17.803 0 32.993-13.394 35.882-30.488zM330.467 30.272V81.11c.913 12.412 5.265 22.192 12.97 28.775 7.822 6.682 19.34 10.418 34.49 10.676v-.03h32.219v-4.052l-79.679-86.207zM199.303 204.095c3.972 3.477 4.377 9.521.9 13.493-3.478 3.973-9.521 4.377-13.494.9l-36.354-31.854c-3.972-3.477-4.377-9.521-.9-13.493.295-.336.606-.644.933-.927l36.321-31.826c3.973-3.478 10.016-3.073 13.494.899 3.477 3.973 3.072 10.016-.9 13.494l-28.14 24.656 28.14 24.658zm77.99 14.393c-3.972 3.477-10.016 3.073-13.493-.9-3.478-3.972-3.073-10.016.899-13.493l28.14-24.658-28.14-24.656c-3.972-3.478-4.377-9.521-.899-13.494 3.477-3.972 9.521-4.377 13.493-.899l36.318 31.826c.328.283.639.591.933.927 3.477 3.972 3.073 10.016-.899 13.493l-36.352 31.854zM120.405 400.89l3.805-19.455c8.333 2.083 15.827 3.123 22.484 3.123 6.66 0 12.024-.27 16.101-.815v-9.755l-12.228-1.086c-11.051-.999-18.635-3.648-22.759-7.951-4.121-4.302-6.181-10.665-6.181-19.089 0-11.592 2.514-19.565 7.54-23.911 5.029-4.35 13.565-6.523 25.612-6.523 12.047 0 22.915 1.134 32.61 3.398l-3.398 18.978c-8.423-1.358-15.171-2.038-20.244-2.038s-9.375.226-12.908.68v9.416l9.783.952c11.865 1.177 20.063 4.008 24.591 8.492 4.531 4.484 6.795 10.71 6.795 18.682 0 5.706-.77 10.528-2.311 14.47-1.541 3.94-3.373 6.927-5.502 8.966-2.129 2.038-5.141 3.601-9.037 4.687-3.892 1.087-7.312 1.745-10.255 1.97-2.944.228-6.864.341-11.755.341-11.775 0-22.688-1.177-32.743-3.532zm128.036-1.631l-11.548 3.125c-15.219 0-25.414-3.926-30.707-11.684-2.674-3.923-4.621-8.266-5.708-13.111-1.087-4.844-1.628-10.712-1.628-17.595 0-15.491 2.899-26.789 8.695-33.9 5.797-7.109 16.212-10.666 31.249-10.666 15.036 0 25.498 3.579 31.386 10.734 5.887 7.156 8.83 18.432 8.83 33.832 0 11.502-2.399 20.786-7.199 27.851l9.782 5.708-7.067 15.623-26.085-4.754v-5.163zm-20.382-18.072h11.279c3.714 0 6.407-.429 8.083-1.29 1.675-.861 2.514-2.83 2.514-5.909v-35.325h-11.414c-3.62 0-6.272.429-7.947 1.29-1.675.861-2.515 2.834-2.515 5.909v35.325zm115.536 21.197h-54.349v-84.917h27.175v63.179h27.174v21.738z</Geometry>
|
||||
<Geometry x:Key="PythonIcon">M19.14,7.5A2.86,2.86 0 0,1 22,10.36V14.14A2.86,2.86 0 0,1 19.14,17H12C12,17.39 12.32,17.96 12.71,17.96H17V19.64A2.86,2.86 0 0,1 14.14,22.5H9.86A2.86,2.86 0 0,1 7,19.64V15.89C7,14.31 8.28,13.04 9.86,13.04H15.11C16.69,13.04 17.96,11.76 17.96,10.18V7.5H19.14M14.86,19.29C14.46,19.29 14.14,19.59 14.14,20.18C14.14,20.77 14.46,20.89 14.86,20.89A0.71,0.71 0 0,0 15.57,20.18C15.57,19.59 15.25,19.29 14.86,19.29M4.86,17.5C3.28,17.5 2,16.22 2,14.64V10.86C2,9.28 3.28,8 4.86,8H12C12,7.61 11.68,7.04 11.29,7.04H7V5.36C7,3.78 8.28,2.5 9.86,2.5H14.14C15.72,2.5 17,3.78 17,5.36V9.11C17,10.69 15.72,11.96 14.14,11.96H8.89C7.31,11.96 6.04,13.24 6.04,14.82V17.5H4.86M9.14,5.71C9.54,5.71 9.86,5.41 9.86,4.82C9.86,4.23 9.54,4.11 9.14,4.11C8.75,4.11 8.43,4.23 8.43,4.82C8.43,5.41 8.75,5.71 9.14,5.71Z</Geometry>
|
||||
<Geometry x:Key="CSharpIcon">M7878 15350 c-162 -15 -335 -63 -471 -131 -146 -74 -5492 -3082 -5567 -3133 -41 -28 -120 -96 -175 -151 -189 -189 -307 -411 -362 -682 -17 -84 -18 -245 -18 -3253 0 -3008 1 -3169 18 -3253 50 -249 159 -466 323 -645 64 -71 188 -173 269 -224 102 -64 5469 -3075 5535 -3106 367 -170 814 -166 1165 10 75 38 5370 3012 5482 3079 326 196 543 505 620 886 17 84 18 245 18 3253 0 3008 -1 3169 -18 3253 -55 271 -173 493 -362 682 -55 55 -134 123 -175 151 -75 51 -5421 3059 -5568 3133 -203 102 -479 152 -714 131z m591 -3534 c526 -70 1018 -235 1456 -489 298 -172 642 -446 866 -689 117 -126 259 -298 259 -312 -1 -6 -301 -184 -667 -396 -366 -212 -680 -393 -697 -403 l-31 -18 -85 82 c-583 568 -1404 778 -2184 559 -501 -141 -952 -471 -1245 -910 -249 -373 -374 -786 -374 -1240 0 -372 82 -709 250 -1030 337 -644 947 -1075 1678 -1185 133 -21 439 -23 570 -6 499 66 958 288 1304 631 l84 82 32 -18 c892 -514 1364 -791 1365 -800 1 -32 -300 -365 -462 -511 -583 -528 -1275 -856 -2043 -967 -200 -29 -382 -39 -638 -33 -277 6 -411 20 -672 72 -1512 301 -2719 1521 -3009 3040 -52 276 -61 378 -61 725 0 355 9 453 66 747 255 1307 1201 2410 2461 2867 312 113 669 190 1018 220 118 10 641 -2 759 -18z m3371 -2536 l0 -320 320 0 320 0 0 320 0 320 320 0 320 0 0 -320 0 -320 320 0 320 0 0 -320 0 -320 -320 0 -320 0 0 -320 0 -320 320 0 320 0 0 -320 0 -320 -320 0 -320 0 0 -320 0 -320 -320 0 -320 0 0 320 0 320 -320 0 -320 0 0 -320 0 -320 -320 0 -320 0 0 320 0 320 -320 0 -320 0 0 320 0 320 320 0 320 0 0 320 0 320 -320 0 -320 0 0 320 0 320 320 0 320 0 0 320 0 320 320 0 320 0 0 -320z M11840 8000 l0 -320 320 0 320 0 0 320 0 320 -320 0 -320 0 0 -320z</Geometry>
|
||||
|
||||
<!-- For specific games-->
|
||||
<Geometry x:Key="BorderlandsIcon">M13,9V3.5L18.5,9M6,2C4.89,2 4,2.89 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2H6 ZM12,11A3,3 0 1,0 12,17A3,3 0 0,0 12,11 ZM12,12.5L14,16H13L12,14.5L11,16H10L12,12.5Z</Geometry>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user