Throne and Liberty, Farlight84 and Mafia fixes
Some checks failed
FModel QA Builder / build (push) Has been cancelled

This commit is contained in:
Valentin 2025-08-17 22:16:10 +02:00 committed by GitHub
commit 0cc8da95e1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
17 changed files with 501 additions and 216 deletions

@ -1 +1 @@
Subproject commit fc2abf20867c2bd0079d46cdc7eaa4f521a61376
Subproject commit 1b82397777d33851781e96134e5afef03028b557

View File

@ -89,6 +89,7 @@ public class BaseIconStats : BaseIcon
weaponRowValue.TryGetValue(out float dmgCritical, "DamageZone_Critical"); //Headshot multiplier
weaponRowValue.TryGetValue(out int clipSize, "ClipSize"); //Item magazine size
weaponRowValue.TryGetValue(out float firingRate, "FiringRate"); //Item firing rate, value is shots per second
weaponRowValue.TryGetValue(out float swingTime, "SwingTime"); //Item swing rate, value is swing per second
weaponRowValue.TryGetValue(out float armTime, "ArmTime"); //Time it takes for traps to be able to be set off
weaponRowValue.TryGetValue(out float reloadTime, "ReloadTime"); //Time it takes for a weapon to reload
weaponRowValue.TryGetValue(out int bpc, "BulletsPerCartridge"); //Amount of pellets shot by a weapon at once, usually for shotguns
@ -124,7 +125,7 @@ public class BaseIconStats : BaseIcon
_statistics.Add(new IconStat(Utils.GetLocalizedResource("", "068239DD4327B36124498C9C5F61C038", "Magazine Size"), clipSize, 40));
}
var burstEquation = cartridgePerFire / (((cartridgePerFire - 1f) / burstFiringRate) + (1f / firingRate));
var burstEquation = cartridgePerFire != 0f && burstFiringRate != 0f ? (cartridgePerFire / (((cartridgePerFire - 1f) / burstFiringRate) + (1f / firingRate))) : 0f;
if (burstEquation != 0f)
{
_statistics.Add(new IconStat(Utils.GetLocalizedResource("", "27B80BA44805ABD5A2D2BAB2902B250C", "Fire Rate"), burstEquation, 11));
@ -133,6 +134,10 @@ public class BaseIconStats : BaseIcon
{
_statistics.Add(new IconStat(Utils.GetLocalizedResource("", "27B80BA44805ABD5A2D2BAB2902B250C", "Fire Rate"), firingRate, 11));
}
else if (swingTime != 0f)
{
_statistics.Add(new IconStat(Utils.GetLocalizedResource("", "27B80BA44805ABD5A2D2BAB2902B250C", "Fire Rate"), swingTime, 11));
}
if (armTime != 0f)
{

View File

@ -29,10 +29,16 @@ public static partial class StringExtensions
{
if (KismetRegex().IsMatch(lineToFind))
return s.GetKismetLineNumber(lineToFind);
if (int.TryParse(lineToFind, out var index))
return s.GetLineNumber(index);
lineToFind = $" \"Name\": \"{lineToFind}\",";
return s.GetNameLineNumberText($" \"Name\": \"{lineToFind}\",");
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetNameLineNumberText(this string s, string lineToFind)
{
using var reader = new StringReader(s);
var lineNum = 0;
while (reader.ReadLine() is { } line)
@ -41,7 +47,6 @@ public static partial class StringExtensions
if (line.Equals(lineToFind, StringComparison.OrdinalIgnoreCase))
return lineNum;
}
return -1;
}

View File

@ -501,6 +501,30 @@
</Viewbox>
</MenuItem.Icon>
</MenuItem>
<MenuItem Header="Decompile Blueprint" Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.CommandParameter>
<MultiBinding Converter="{x:Static converters:MultiParameterConverter.Instance}">
<Binding Source="Assets_Decompile" />
<Binding Path="SelectedItems" />
</MultiBinding>
</MenuItem.CommandParameter>
<MenuItem.Icon>
<Viewbox Width="16" Height="16">
<Canvas Width="24" Height="24">
<Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource InfoIcon}" />
</Canvas>
</Viewbox>
</MenuItem.Icon>
<MenuItem.Style>
<Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
<Style.Triggers>
<DataTrigger Binding="{Binding ShowDecompileOption, Source={x:Static settings:UserSettings.Default}}" Value="False">
<Setter Property="Visibility" Value="Collapsed" />
</DataTrigger>
</Style.Triggers>
</Style>
</MenuItem.Style>
</MenuItem>
<Separator />
<MenuItem Command="{Binding DataContext.RightClickMenuCommand}">
<MenuItem.Header>

View File

@ -1,195 +1,150 @@
<?xml version="1.0"?>
<!-- syntaxdefinition for C/C++ 2001 by Andrea Paatz and Mike Krueger -->
<!-- converted to AvalonEdit format by Siegfried Pammer in 2010 -->
<SyntaxDefinition name="C++" extensions=".c;.h;.cc;.cpp;.hpp" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="Green" />
<Color name="Character" foreground="Fuchsia" />
<Color name="String" foreground="Fuchsia" />
<Color name="Preprocessor" foreground="Green" />
<Color name="Punctuation" foreground="DarkGreen" />
<Color name="MethodName" foreground="MidnightBlue" fontWeight="bold" />
<Color name="Digits" foreground="#F78C6C" />
<Color name="CompoundKeywords" foreground="Black" fontWeight="bold" />
<Color name="This" foreground="Black" fontWeight="bold" />
<Color name="Operators" foreground="#FF008B8B" fontWeight="bold" />
<Color name="Namespace" foreground="#FF008000" fontWeight="bold" />
<Color name="Friend" foreground="#FFA52A2A" />
<Color name="Modifiers" foreground="#FF0000FF" fontWeight="bold" />
<Color name="TypeKeywords" foreground="#FFFF0000" />
<Color name="BooleanConstants" foreground="#FF000000" fontWeight="bold" />
<Color name="Keywords" foreground="#FF0000FF" fontWeight="bold" />
<Color name="LoopKeywords" foreground="#FF0000FF" fontWeight="bold" />
<Color name="JumpKeywords" foreground="#FF000080" />
<Color name="ExceptionHandling" foreground="#FF008080" fontWeight="bold" />
<Color name="ControlFlow" foreground="#FF0000FF" fontWeight="bold" />
<RuleSet ignoreCase="false">
<Rule color="Punctuation">
[?,.;()\[\]{}+\-/%*&lt;&gt;^=~!&amp;]+
</Rule>
<Keywords color="CompoundKeywords">
<Word>__abstract</Word>
<Word>__box</Word>
<Word>__delegate</Word>
<Word>__gc</Word>
<Word>__identifier</Word>
<Word>__nogc</Word>
<Word>__pin</Word>
<Word>__property</Word>
<Word>__sealed</Word>
<Word>__try_cast</Word>
<Word>__typeof</Word>
<Word>__value</Word>
<Word>__event</Word>
<Word>__hook</Word>
<Word>__raise</Word>
<Word>__unhook</Word>
<Word>__interface</Word>
<Word>ref class</Word>
<Word>ref struct</Word>
<Word>value class</Word>
<Word>value struct</Word>
<Word>interface class</Word>
<Word>interface struct</Word>
<Word>enum class</Word>
<Word>enum struct</Word>
<Word>delegate</Word>
<Word>event</Word>
<Word>property</Word>
<Word>abstract</Word>
<Word>override</Word>
<Word>sealed</Word>
<Word>generic</Word>
<Word>where</Word>
<Word>finally</Word>
<Word>for each</Word>
<Word>gcnew</Word>
<Word>in</Word>
<Word>initonly</Word>
<Word>literal</Word>
<Word>nullptr</Word>
</Keywords>
<Keywords color="This">
<Word>this</Word>
</Keywords>
<Keywords color="Operators">
<Word>and</Word>
<Word>and_eq</Word>
<Word>bitand</Word>
<Word>bitor</Word>
<Word>new</Word>
<Word>not</Word>
<Word>not_eq</Word>
<Word>or</Word>
<Word>or_eq</Word>
<Word>xor</Word>
<Word>xor_eq</Word>
</Keywords>
<Keywords color="Namespace">
<Word>using</Word>
<Word>namespace</Word>
</Keywords>
<Keywords color="Friend">
<Word>friend</Word>
</Keywords>
<Keywords color="Modifiers">
<Word>private</Word>
<Word>protected</Word>
<Word>public</Word>
<Word>const</Word>
<Word>volatile</Word>
<Word>static</Word>
</Keywords>
<Keywords color="TypeKeywords">
<Word>bool</Word>
<Word>char</Word>
<Word>unsigned</Word>
<Word>union</Word>
<Word>virtual</Word>
<Word>double</Word>
<Word>float</Word>
<Word>short</Word>
<Word>signed</Word>
<Word>void</Word>
<Word>class</Word>
<Word>enum</Word>
<Word>struct</Word>
</Keywords>
<Keywords color="BooleanConstants">
<Word>false</Word>
<Word>true</Word>
</Keywords>
<Keywords color="LoopKeywords">
<Word>do</Word>
<Word>for</Word>
<Word>while</Word>
</Keywords>
<Keywords color="JumpKeywords">
<Word>break</Word>
<Word>continue</Word>
<Word>goto</Word>
<Word>return</Word>
</Keywords>
<Keywords color="ExceptionHandling">
<Word>catch</Word>
<Word>throw</Word>
<Word>try</Word>
</Keywords>
<Keywords color="ControlFlow">
<Word>case</Word>
<Word>else</Word>
<Word>if</Word>
<Word>switch</Word>
<Word>default</Word>
</Keywords>
<Keywords color="Keywords">
<Word>asm</Word>
<Word>auto</Word>
<Word>compl</Word>
<Word>mutable</Word>
<Word>const_cast</Word>
<Word>delete</Word>
<Word>dynamic_cast</Word>
<Word>explicit</Word>
<Word>export</Word>
<Word>extern</Word>
<Word>inline</Word>
<Word>int</Word>
<Word>long</Word>
<Word>operator</Word>
<Word>register</Word>
<Word>reinterpret_cast</Word>
<Word>sizeof</Word>
<Word>static_cast</Word>
<Word>template</Word>
<Word>typedef</Word>
<Word>typeid</Word>
<Word>typename</Word>
</Keywords>
<Span color="Preprocessor">
<Begin>\#</Begin>
</Span>
<Span color="Comment">
<Begin>//</Begin>
</Span>
<Span color="Comment" multiline="true">
<Begin>/\*</Begin>
<End>\*/</End>
</Span>
<Span color="String">
<Begin>"</Begin>
<End>"</End>
<RuleSet>
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Span color="Character">
<Begin>'</Begin>
<End>'</End>
<RuleSet>
<Span begin="\\" end="." />
</RuleSet>
</Span>
<Rule color="MethodName">[\d\w_]+(?=(\s*\())</Rule>
<Rule color="Digits">\b0[xX][0-9a-fA-F]+|(\b\d+(\.[0-9]+)?|\.[0-9]+)([eE][+-]?[0-9]+)?</Rule>
</RuleSet>
</SyntaxDefinition>
<SyntaxDefinition name="C++" extensions=".cpp;.h;.hpp;.c" xmlns="http://icsharpcode.net/sharpdevelop/syntaxdefinition/2008">
<Color name="Comment" foreground="#84c36b" />
<Color name="Keyword" foreground="#82AAFF" fontWeight="bold" />
<Color name="Type" foreground="#4cc9b0" />
<Color name="String" foreground="#ECC48D" />
<Color name="Preprocessor" foreground="#82AAFF" fontWeight="bold" />
<Color name="Number" foreground="#F78C6C" />
<Color name="Function" foreground="#C3E88D" />
<Color name="AccessModifier" foreground="#f20f5c" fontWeight="bold" />
<Color name="UEMacro" foreground="#82AAFF" fontWeight="bold" />
<Color name="LabelColor" foreground="#808080" />
<Color name="JumpKeywords" foreground="#dda0dd" />
<Color name="CompoundKeywords" foreground="#FF569CD6" fontWeight="bold" />
<Color name="Pointer" foreground="#ff8888" fontWeight="bold"/>
<Color name="StaticClass" foreground="#c2a8ff" />
<Color name="Brace" foreground="#89DDFF" />
<Color name="This" foreground="#FF569CD6" fontWeight="bold" />
<Color name="BooleanConstants" foreground="#569cd6" fontWeight="bold" />
<RuleSet ignoreCase="false">
<Span color="String" begin="&quot;" end="&quot;" />
<!-- UE Macros -->
<Keywords color="UEMacro">
<Word>UCLASS</Word>
<Word>USTRUCT</Word>
<Word>UPROPERTY</Word>
<Word>UFUNCTION</Word>
<Word>GENERATED_BODY</Word>
<Word>GENERATED_USTRUCT_BODY</Word>
<Word>GENERATED_UCLASS_BODY</Word>
</Keywords>
<Keywords color="JumpKeywords">
<Word>goto</Word>
<Word>return</Word>
<Word>throw</Word>
</Keywords>
<!-- C++ Keywords -->
<Keywords color="Keyword">
<Word>void</Word>
<Word>int</Word>
<Word>Int8</Word>
<Word>Int16</Word>
<Word>Int32</Word>
<Word>Int64</Word>
<Word>uint</Word>
<Word>UInt16</Word>
<Word>UInt32</Word>
<Word>UInt64</Word>
<Word>float</Word>
<Word>double</Word>
<Word>bool</Word>
<Word>return</Word>
<Word>if</Word>
<Word>else</Word>
<Word>for</Word>
<Word>while</Word>
<Word>do</Word>
<Word>switch</Word>
<Word>case</Word>
<Word>break</Word>
<Word>continue</Word>
<Word>namespace</Word>
<Word>using</Word>
<Word>typedef</Word>
<Word>sizeof</Word>
<Word>new</Word>
<Word>delete</Word>
<Word>class</Word>
<Word>struct</Word>
<Word>enum</Word>
<Word>template</Word>
<Word>typename</Word>
<Word>const</Word>
<Word>static</Word>
<Word>mutable</Word>
<Word>volatile</Word>
<Word>override</Word>
<Word>virtual</Word>
<Word>explicit</Word>
<Word>friend</Word>
<Word>inline</Word>
<Word>constexpr</Word>
<Word>default</Word>
</Keywords>
<Keywords color="Pointer">
<Word>nullptr</Word>
</Keywords>
<Keywords color="BooleanConstants">
<Word>true</Word>
<Word>True</Word>
<Word>false</Word>
<Word>False</Word>
<Word>NULL</Word>
</Keywords>
<Keywords color="AccessModifier">
<Word>public</Word>
<Word>protected</Word>
<Word>private</Word>
</Keywords>
<Keywords color="This">
<Word>this</Word>
</Keywords>
<!-- Reference symbols -->
<Rule color="Pointer">(?&lt;=[A-Za-z0-9_&gt;&amp;\]])&amp;(?=\s*[A-Za-z_&lt;])</Rule>
<Rule color="LabelColor">\bLabel_\d+:</Rule>
<!-- Numbers (hex too) -->
<Rule color="Number">\b(0x[0-9a-fA-F]+|[0-9]+(\.[0-9]+)?)\b</Rule>
<Rule color="StaticClass">\bU[A-Z][A-Za-z0-9_]*\b(?=::)</Rule>
<Rule color="Function">[A-Za-z_][A-Za-z0-9_]*\s*(?=\()</Rule>
<Rule color="Brace">[\[\]\{\}]</Rule>
<Rule color="Comment">(\/\/.*|\/\*[\s\S]*?\*\/)</Rule>
<!-- Template Functions -->
<Rule color="Function">\b[A-Za-z_][A-Za-z0-9_]*\b(?=&lt;)</Rule>
<!-- Types -->
<Rule color="Type">\b[A-Z][A-Za-z0-9_]*(?:&lt;[^&gt;]+&gt;)?[*&amp;]?(?=\s+[*&amp;]?[A-Za-z_][A-Za-z0-9_]*\s*(=|;|\)|,))</Rule>
<!-- Types inside <> -->
<Rule color="Type">(?&lt;=&lt;)\s*[A-Z][A-Za-z0-9_]*(?:&lt;[^&gt;]+&gt;)?[*&amp;]?\s*(?=[&gt;,])</Rule>
<!-- Match class name after the 'class' keyword -->
<Rule color="Type">\b(?&lt;=class\s)[A-Za-z_][A-Za-z0-9_]*</Rule>
<!-- Match name after 'public' keyword -->
<Rule color="Type">\b(?&lt;=public\s)[A-Za-z_][A-Za-z0-9_]*</Rule>
<!-- Types in function parameters -->
<Rule color="Type">\b(?:T|F|U|E)[A-Z][A-Za-z0-9_]*(?:&lt;[^&gt;]+&gt;)?[*&amp;]?(?=\s+[*&amp;]?[A-Za-z_][A-Za-z0-9_]*\s*(?:=|,|\)))</Rule>
<Rule color="Type">\b(?&lt;=[,(]\s*const\s)(?:T|F|U)[A-Z][A-Za-z0-9_]*[*&amp;]?(?=\s)</Rule>
<!-- First parameter type in function -->
<Rule color="Type">\b(?&lt;=\()\s*[TUF][A-Z][A-Za-z0-9_]*(?=\s*&lt;)</Rule>
<Rule color="Type">\b(?&lt;=\()\s*[TUF][A-Z][A-Za-z0-9_]*[*&amp;]?(?=\s)</Rule>
<Rule color="Type">\b(?&lt;=\(\s*const\s)[TUF][A-Z][A-Za-z0-9_]*[*&amp;]?(?=\s)</Rule>
</RuleSet>
</SyntaxDefinition>

View File

@ -203,6 +203,13 @@ namespace FModel.Settings
set => SetProperty(ref _keepDirectoryStructure, value);
}
private bool _showDecompileOption = false;
public bool ShowDecompileOption
{
get => _showDecompileOption;
set => SetProperty(ref _showDecompileOption, value);
}
private ECompressedAudio _compressedAudioMode = ECompressedAudio.PlayDecompressed;
public ECompressedAudio CompressedAudioMode
{

View File

@ -31,7 +31,6 @@ using CUE4Parse.UE4.Localization;
using CUE4Parse.UE4.Objects.Core.Serialization;
using CUE4Parse.UE4.Objects.Engine;
using CUE4Parse.UE4.Oodle.Objects;
using CUE4Parse.UE4.Pak;
using CUE4Parse.UE4.Readers;
using CUE4Parse.UE4.Shaders;
using CUE4Parse.UE4.Versions;
@ -63,6 +62,8 @@ using SkiaSharp;
using UE4Config.Parsing;
using Application = System.Windows.Application;
using FGuid = CUE4Parse.UE4.Objects.Core.Misc.FGuid;
using CUE4Parse.UE4.Objects.UObject.Editor;
namespace FModel.ViewModels;
@ -361,7 +362,7 @@ public class CUE4ParseViewModel : ViewModel
{
var mappingsFolder = Path.Combine(UserSettings.Default.OutputDirectory, ".data");
if (endpoint.Path == "$.[?(@.meta.compressionMethod=='Oodle')].['url','fileName']") endpoint.Path = "$.[0].['url','fileName']";
var mappings = _apiEndpointView.DynamicApi.GetMappings(default, endpoint.Url, endpoint.Path);
var mappings = _apiEndpointView.DynamicApi.GetMappings(CancellationToken.None, endpoint.Url, endpoint.Path);
if (mappings is { Length: > 0 })
{
foreach (var mapping in mappings)
@ -436,7 +437,7 @@ public class CUE4ParseViewModel : ViewModel
var ioStoreOnDemandPath = Path.Combine(UserSettings.Default.GameDirectory, "..\\..\\..\\Cloud", inst[0].Value.SubstringAfterLast("/").SubstringBefore("\""));
if (!File.Exists(ioStoreOnDemandPath)) return;
await _apiEndpointView.EpicApi.VerifyAuth(default);
await _apiEndpointView.EpicApi.VerifyAuth(CancellationToken.None);
await Provider.RegisterVfs(new IoChunkToc(ioStoreOnDemandPath), new IoStoreOnDemandOptions
{
ChunkBaseUri = new Uri("https://download.epicgames.com/ias/fortnite/", UriKind.Absolute),
@ -453,6 +454,7 @@ public class CUE4ParseViewModel : ViewModel
public int LocalizedResourcesCount { get; set; }
public bool LocalResourcesDone { get; set; }
public bool HotfixedResourcesDone { get; set; }
public async Task LoadLocalizedResources()
{
var snapshot = LocalizedResourcesCount;
@ -466,6 +468,7 @@ public class CUE4ParseViewModel : ViewModel
Utils.Typefaces = new Typefaces(this);
}
}
private Task LoadGameLocalizedResources()
{
if (LocalResourcesDone) return Task.CompletedTask;
@ -474,12 +477,13 @@ public class CUE4ParseViewModel : ViewModel
LocalResourcesDone = Provider.TryChangeCulture(Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
});
}
private Task LoadHotfixedLocalizedResources()
{
if (!Provider.ProjectName.Equals("fortnitegame", StringComparison.OrdinalIgnoreCase) || HotfixedResourcesDone) return Task.CompletedTask;
return Task.Run(() =>
{
var hotfixes = ApplicationService.ApiEndpointView.CentralApi.GetHotfixes(default, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
var hotfixes = ApplicationService.ApiEndpointView.CentralApi.GetHotfixes(CancellationToken.None, Provider.GetLanguageCode(UserSettings.Default.AssetLanguage));
if (hotfixes == null) return;
Provider.Internationalization.Override(hotfixes);
@ -606,17 +610,30 @@ public class CUE4ParseViewModel : ViewModel
break;
}
case "upluginmanifest":
case "code-workspace":
case "projectstore":
case "uefnproject":
case "uproject":
case "manifest":
case "uplugin":
case "archive":
case "dnearchive": // Banishers: Ghosts of New Eden
case "gitignore":
case "LICENSE":
case "template":
case "stUMeta": // LIS: Double Exposure
case "vmodule":
case "glslfx":
case "cptake":
case "uparam": // Steel Hunters
case "spi1d":
case "verse":
case "html":
case "json":
case "uref":
case "cube":
case "usda":
case "ocio":
case "ini":
case "txt":
case "log":
@ -634,9 +651,15 @@ public class CUE4ParseViewModel : ViewModel
case "pem":
case "tps":
case "tgc": // State of Decay 2
case "cpp":
case "apx":
case "udn":
case "doc":
case "lua":
case "vdf":
case "js":
case "po":
case "md":
case "h":
{
var data = Provider.SaveAsset(entry);
@ -695,8 +718,13 @@ public class CUE4ParseViewModel : ViewModel
break;
}
case "xvag":
case "flac":
case "at9":
case "wem":
case "wav":
case "WAV":
case "ogg":
// todo: CSCore.MediaFoundation.MediaFoundationException The byte stream type of the given URL is unsupported. case "aif":
{
var data = Provider.SaveAsset(entry);
SaveAndPlaySound(entry.PathWithoutExtension, entry.Extension, data);
@ -762,6 +790,14 @@ public class CUE4ParseViewModel : ViewModel
break;
}
case "stinfo":
{
var archive = entry.CreateReader();
var ar = new FShaderTypeHashes(archive);
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ar, Formatting.Indented), saveProperties, updateUi);
break;
}
case "res": // just skip
case "luac": // compiled lua
case "bytes": // wuthering waves
@ -796,7 +832,7 @@ public class CUE4ParseViewModel : ViewModel
}
}
private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, EBulkType bulk = EBulkType.None) // return true once you wanna stop searching for exports
private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, EBulkType bulk = EBulkType.None) // return true once you want to stop searching for exports
{
var isNone = bulk == EBulkType.None;
var updateUi = !HasFlag(bulk, EBulkType.Auto);
@ -968,6 +1004,51 @@ public class CUE4ParseViewModel : ViewModel
TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(package, Formatting.Indented), false, false);
}
public void Decompile(GameFile entry)
{
if (TabControl.CanAddTabs) TabControl.AddTab(entry);
else TabControl.SelectedTab.SoftReset(entry);
TabControl.SelectedTab.TitleExtra = "Decompiled";
TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("cpp");
UClassCookedMetaData cookedMetaData = null;
try
{
var editorPkg = Provider.LoadPackage(entry.Path.Replace(".uasset", ".o.uasset"));
cookedMetaData = editorPkg.GetExport<UClassCookedMetaData>("CookedClassMetaData");
}
catch
{
// ignored
}
var cppList = new List<string>();
var pkg = Provider.LoadPackage(entry);
for (var i = 0; i < pkg.ExportMapLength; i++)
{
var pointer = new FPackageIndex(pkg, i + 1).ResolvedObject;
if (pointer?.Object is null && pointer.Class?.Object?.Value is null)
continue;
var dummy = ((AbstractUePackage) pkg).ConstructObject(pointer.Class?.Object?.Value as UStruct, pkg);
if (dummy is not UClass || pointer.Object.Value is not UClass blueprint)
continue;
cppList.Add(blueprint.DecompileBlueprintToPseudo(cookedMetaData));
}
var cpp = cppList.Count > 1 ? string.Join("\n\n", cppList) : cppList.FirstOrDefault() ?? string.Empty;
if (entry.Path.Contains("_Verse.uasset"))
{
cpp = Regex.Replace(cpp, "__verse_0x[a-fA-F0-9]{8}_", ""); // UnmangleCasedName
}
cpp = Regex.Replace(cpp, @"CallFunc_([A-Za-z0-9_]+)_ReturnValue", "$1");
TabControl.SelectedTab.SetDocumentText(cpp, false, false);
}
private void SaveAndPlaySound(string fullPath, string ext, byte[] data)
{
if (fullPath.StartsWith('/')) fullPath = fullPath[1..];

View File

@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Linq;
using System.Threading;
using CUE4Parse.FileProvider.Objects;
@ -44,6 +44,14 @@ public class RightClickMenuCommand : ViewModelCommand<ApplicationViewModel>
contextViewModel.CUE4Parse.ShowMetadata(entry);
}
break;
case "Assets_Decompile":
foreach (var entry in entries)
{
Thread.Yield();
cancellationToken.ThrowIfCancellationRequested();
contextViewModel.CUE4Parse.Decompile(entry);
}
break;
case "Assets_Export_Data":
foreach (var entry in entries)
{

View File

@ -3,14 +3,23 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Data;
using CUE4Parse.FileProvider.Objects;
using CUE4Parse.UE4.VirtualFileSystem;
using FModel.Framework;
namespace FModel.ViewModels;
public class SearchViewModel : ViewModel
{
public enum ESortSizeMode
{
None,
Ascending,
Descending
}
private string _filterText;
public string FilterText
{
@ -32,6 +41,13 @@ public class SearchViewModel : ViewModel
set => SetProperty(ref _hasMatchCaseEnabled, value);
}
private ESortSizeMode _currentSortSizeMode = ESortSizeMode.None;
public ESortSizeMode CurrentSortSizeMode
{
get => _currentSortSizeMode;
set => SetProperty(ref _currentSortSizeMode, value);
}
public int ResultsCount => SearchResults?.Count ?? 0;
public RangeObservableCollection<GameFile> SearchResults { get; }
public ICollectionView SearchResultsView { get; }
@ -39,15 +55,57 @@ public class SearchViewModel : ViewModel
public SearchViewModel()
{
SearchResults = new RangeObservableCollection<GameFile>();
SearchResultsView = new ListCollectionView(SearchResults);
SearchResultsView = new ListCollectionView(SearchResults)
{
Filter = e => ItemFilter(e, FilterText?.Trim().Split(' ') ?? []),
};
}
public void RefreshFilter()
{
if (SearchResultsView.Filter == null)
SearchResultsView.Filter = e => ItemFilter(e, FilterText.Trim().Split(' '));
else
SearchResultsView.Refresh();
SearchResultsView.Refresh();
}
public async Task CycleSortSizeMode()
{
CurrentSortSizeMode = CurrentSortSizeMode switch
{
ESortSizeMode.None => ESortSizeMode.Descending,
ESortSizeMode.Descending => ESortSizeMode.Ascending,
_ => ESortSizeMode.None
};
var sorted = await Task.Run(() =>
{
var archiveDict = SearchResults
.OfType<VfsEntry>()
.Select(f => f.Vfs.Name)
.Distinct()
.Select((name, idx) => (name, idx))
.ToDictionary(x => x.name, x => x.idx);
var keyed = SearchResults.Select(f =>
{
int archiveKey = f is VfsEntry ve && archiveDict.TryGetValue(ve.Vfs.Name, out var key) ? key : -1;
return (File: f, f.Size, ArchiveKey: archiveKey);
});
return CurrentSortSizeMode switch
{
ESortSizeMode.Ascending => keyed
.OrderBy(x => x.Size).ThenBy(x => x.ArchiveKey)
.Select(x => x.File).ToList(),
ESortSizeMode.Descending => keyed
.OrderByDescending(x => x.Size).ThenBy(x => x.ArchiveKey)
.Select(x => x.File).ToList(),
_ => keyed
.OrderBy(x => x.ArchiveKey).ThenBy(x => x.File.Path, StringComparer.OrdinalIgnoreCase)
.Select(x => x.File).ToList()
};
});
SearchResults.Clear();
SearchResults.AddRange(sorted.ToList());
}
private bool ItemFilter(object item, IEnumerable<string> filters)

View File

@ -0,0 +1,34 @@
using System.Text.RegularExpressions;
using ICSharpCode.AvalonEdit.Rendering;
namespace FModel.Views.Resources.Controls;
public class JumpElementGenerator : VisualLineElementGenerator
{
private readonly Regex _JumpRegex = new(
@"\b(?:goto\s+Label_(?'target'\d+);)",
RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.CultureInvariant);
private Match FindMatch(int startOffset)
{
var endOffset = CurrentContext.VisualLine.LastDocumentLine.EndOffset;
var relevantText = CurrentContext.Document.GetText(startOffset, endOffset - startOffset);
return _JumpRegex.Match(relevantText);
}
public override int GetFirstInterestedOffset(int startOffset)
{
var m = FindMatch(startOffset);
return m.Success ? startOffset + m.Index : -1;
}
public override VisualLineElement ConstructElement(int offset)
{
var m = FindMatch(offset);
if (!m.Success || m.Index != 0 ||
!m.Groups.TryGetValue("target", out var g))
return null;
return new JumpVisualLineText(g.Value, CurrentContext.VisualLine, g.Length + g.Index + 1);
}
}

View File

@ -0,0 +1,75 @@
using System;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.TextFormatting;
using FModel.Extensions;
using FModel.Services;
using FModel.ViewModels;
using ICSharpCode.AvalonEdit.Rendering;
namespace FModel.Views.Resources.Controls;
public class JumpVisualLineText : VisualLineText
{
public delegate void JumpOnClick(string Jump);
public event JumpOnClick OnJumpClicked;
private readonly string _jump;
public JumpVisualLineText(string jump, VisualLine parentVisualLine, int length) : base(parentVisualLine, length)
{
_jump = jump;
}
public override TextRun CreateTextRun(int startVisualColumn, ITextRunConstructionContext context)
{
if (context == null)
throw new ArgumentNullException(nameof(context));
var relativeOffset = startVisualColumn - VisualColumn;
var text = context.GetText(context.VisualLine.FirstDocumentLine.Offset + RelativeTextOffset + relativeOffset, DocumentLength - relativeOffset);
if (text.Count != 2) // ": "
TextRunProperties.SetForegroundBrush(Brushes.Plum);
return new TextCharacters(text.Text, text.Offset, text.Count, TextRunProperties);
}
private bool JumpIsClickable() => !string.IsNullOrEmpty(_jump) && Keyboard.Modifiers == ModifierKeys.None;
protected override void OnQueryCursor(QueryCursorEventArgs e)
{
if (!JumpIsClickable())
return;
e.Handled = true;
e.Cursor = Cursors.Hand;
}
protected override void OnMouseDown(MouseButtonEventArgs e)
{
if (e.ChangedButton != MouseButton.Left || !JumpIsClickable())
return;
if (e.Handled || OnJumpClicked == null)
return;
OnJumpClicked(_jump);
e.Handled = true;
}
protected override VisualLineText CreateInstance(int length)
{
var a = new JumpVisualLineText(_jump, ParentVisualLine, length);
a.OnJumpClicked += jump =>
{
var lineNumber = a.ParentVisualLine.Document.Text.GetNameLineNumberText($" Label_{jump}:"); // impossible for different indentation
if (lineNumber > -1)
{
var line = a.ParentVisualLine.Document.GetLineByNumber(lineNumber);
AvalonEditor.YesWeEditor.Select(line.Offset, line.Length);
AvalonEditor.YesWeEditor.ScrollToLine(lineNumber);
}
};
return a;
}
}

View File

@ -43,6 +43,7 @@ public partial class AvalonEditor
MyAvalonEditor.TextArea.TextView.LinkTextBackgroundBrush = null;
MyAvalonEditor.TextArea.TextView.LinkTextForegroundBrush = Brushes.Cornsilk;
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new GamePathElementGenerator());
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new JumpElementGenerator());
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new HexColorElementGenerator());
ApplicationService.ApplicationView.CUE4Parse.TabControl.OnTabRemove += OnTabClose;

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Text.RegularExpressions;
using System.Windows.Input;
using System.Windows.Media;
@ -32,6 +32,7 @@ public partial class PropertiesPopout
MyAvalonEditor.TextArea.TextView.LinkTextBackgroundBrush = null;
MyAvalonEditor.TextArea.TextView.LinkTextForegroundBrush = Brushes.Cornsilk;
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new GamePathElementGenerator());
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new JumpElementGenerator());
MyAvalonEditor.TextArea.TextView.ElementGenerators.Add(new HexColorElementGenerator());
_manager = new JsonFoldingStrategies(MyAvalonEditor);
_manager.UpdateFoldings(MyAvalonEditor.Document);

View File

@ -70,6 +70,7 @@
<Geometry x:Key="MeshIcon">M1.8 6q-.525 0-.887-.35Q.55 5.3.55 4.8V4q0-1.425 1.012-2.438Q2.575.55 4 .55h.8q.5 0 .85.362.35.363.35.888 0 .5-.35.85T4.8 3H4q-.425 0-.712.287Q3 3.575 3 4v.8q0 .5-.35.85T1.8 6ZM4 23.45q-1.425 0-2.438-1.012Q.55 21.425.55 20v-.8q0-.5.363-.85.362-.35.887-.35.5 0 .85.35t.35.85v.8q0 .425.288.712Q3.575 21 4 21h.8q.5 0 .85.35t.35.85q0 .525-.35.887-.35.363-.85.363Zm15.2 0q-.5 0-.85-.363-.35-.362-.35-.887 0-.5.35-.85t.85-.35h.8q.425 0 .712-.288Q21 20.425 21 20v-.8q0-.5.35-.85t.85-.35q.525 0 .888.35.362.35.362.85v.8q0 1.425-1.012 2.438Q21.425 23.45 20 23.45ZM22.2 6q-.5 0-.85-.35T21 4.8V4q0-.425-.288-.713Q20.425 3 20 3h-.8q-.5 0-.85-.35T18 1.8q0-.525.35-.888.35-.362.85-.362h.8q1.425 0 2.438 1.012Q23.45 2.575 23.45 4v.8q0 .5-.362.85-.363.35-.888.35ZM12 17.35l1-.575v-4.1l3.55-2.075V9.425l-1-.575L12 10.925 8.45 8.85l-1 .575V10.6L11 12.675v4.1Zm-1.325 2.325-4.55-2.65q-.625-.35-.975-.963-.35-.612-.35-1.337V9.45q0-.725.35-1.337.35-.613.975-.963l4.55-2.65Q11.3 4.15 12 4.15t1.325.35l4.55 2.65q.625.35.975.963.35.612.35 1.337v5.275q0 .725-.35 1.337-.35.613-.975.963l-4.55 2.65q-.625.35-1.325.35t-1.325-.35Z</Geometry>
<Geometry x:Key="ArchiveIcon">M3.5 1.75v11.5c0 .09.048.173.126.217a.75.75 0 0 1-.752 1.298A1.748 1.748 0 0 1 2 13.25V1.75C2 .784 2.784 0 3.75 0h5.586c.464 0 .909.185 1.237.513l2.914 2.914c.329.328.513.773.513 1.237v8.586A1.75 1.75 0 0 1 12.25 15h-.5a.75.75 0 0 1 0-1.5h.5a.25.25 0 0 0 .25-.25V4.664a.25.25 0 0 0-.073-.177L9.513 1.573a.25.25 0 0 0-.177-.073H7.25a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5h-3a.25.25 0 0 0-.25.25Zm3.75 8.75h.5c.966 0 1.75.784 1.75 1.75v3a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1-.75-.75v-3c0-.966.784-1.75 1.75-1.75ZM6 5.25a.75.75 0 0 1 .75-.75h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 6 5.25Zm.75 2.25h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM8 6.75A.75.75 0 0 1 8.75 6h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 8 6.75ZM8.75 3h.5a.75.75 0 0 1 0 1.5h-.5a.75.75 0 0 1 0-1.5ZM8 9.75A.75.75 0 0 1 8.75 9h.5a.75.75 0 0 1 0 1.5h-.5A.75.75 0 0 1 8 9.75Zm-1 2.5v2.25h1v-2.25a.25.25 0 0 0-.25-.25h-.5a.25.25 0 0 0-.25.25Z</Geometry>
<Geometry x:Key="GitHubIcon">M12 0c-6.626 0-12 5.373-12 12 0 5.302 3.438 9.8 8.207 11.387.599.111.793-.261.793-.577v-2.234c-3.338.726-4.033-1.416-4.033-1.416-.546-1.387-1.333-1.756-1.333-1.756-1.089-.745.083-.729.083-.729 1.205.084 1.839 1.237 1.839 1.237 1.07 1.834 2.807 1.304 3.492.997.107-.775.418-1.305.762-1.604-2.665-.305-5.467-1.334-5.467-5.931 0-1.311.469-2.381 1.236-3.221-.124-.303-.535-1.524.117-3.176 0 0 1.008-.322 3.301 1.23.957-.266 1.983-.399 3.003-.404 1.02.005 2.047.138 3.006.404 2.291-1.552 3.297-1.23 3.297-1.23.653 1.653.242 2.874.118 3.176.77.84 1.235 1.911 1.235 3.221 0 4.609-2.807 5.624-5.479 5.921.43.372.823 1.102.823 2.222v3.293c0 .319.192.694.801.576 4.765-1.589 8.199-6.086 8.199-11.386 0-6.627-5.373-12-12-12z</Geometry>
<Geometry x:Key="SortIcon">M8 16H4l6 6V2H8zm6-11v17h2V8h4l-6-6z</Geometry>
<Style x:Key="TabItemFillSpace" TargetType="TabItem" BasedOn="{StaticResource {x:Type TabItem}}">
<Setter Property="Width">

View File

@ -72,6 +72,13 @@
</Canvas>
</Viewbox>
</ToggleButton>
<Button ToolTip="Sort File Sizes" Padding="5" Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}" Click="OnSortClick">
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
<Canvas Width="24" Height="24">
<Path Fill="{DynamicResource {x:Static adonisUi:Brushes.ForegroundBrush}}" Data="{StaticResource SortIcon}" />
</Canvas>
</Viewbox>
</Button>
<Button ToolTip="Clear Search Filter" Padding="5" Style="{DynamicResource {x:Static adonisUi:Styles.ToolbarButton}}" Click="OnDeleteSearchClick">
<Viewbox Width="16" Height="16" HorizontalAlignment="Center">
<Canvas Width="24" Height="24">
@ -80,11 +87,21 @@
</Viewbox>
</Button>
</StackPanel>
<TextBlock Grid.Column="2" Text="{Binding CUE4Parse.SearchVm.ResultsCount, FallbackValue=0, StringFormat={}{0:### ### ###} Loaded Packages}"
VerticalAlignment="Center" HorizontalAlignment="Right" FontStyle="Italic"/>
<TextBlock Grid.Column="2" VerticalAlignment="Center" HorizontalAlignment="Right" Margin="10 0 0 0" FontStyle="Italic">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0:### ### ###} Loaded Packages ({1})">
<Binding Path="CUE4Parse.SearchVm.ResultsCount" FallbackValue="0" />
<Binding Path="CUE4Parse.SearchVm.CurrentSortSizeMode" FallbackValue="None" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
</Grid>
<ListView Grid.Row="1" x:Name="SearchListView" VirtualizingPanel.IsVirtualizing="True" ItemsSource="{Binding CUE4Parse.SearchVm.SearchResultsView, IsAsync=True}">
<ListView Grid.Row="1" x:Name="SearchListView"
VirtualizingPanel.IsVirtualizing="True"
VirtualizingPanel.VirtualizationMode="Recycling"
ScrollViewer.CanContentScroll="True"
ItemsSource="{Binding CUE4Parse.SearchVm.SearchResultsView, IsAsync=True}">
<ListView.Resources>
<Style TargetType="{x:Type ListViewItem}" BasedOn="{StaticResource {x:Type ListViewItem}}">
<Setter Property="HorizontalContentAlignment" Value="Stretch" />

View File

@ -29,6 +29,11 @@ public partial class SearchView
_applicationView.CUE4Parse.SearchVm.RefreshFilter();
}
private async void OnSortClick(object sender, RoutedEventArgs e)
{
await _applicationView.CUE4Parse.SearchVm.CycleSortSizeMode();
}
private async void OnAssetDoubleClick(object sender, RoutedEventArgs e)
{
if (SearchListView.SelectedItem is not GameFile entry)
@ -43,6 +48,9 @@ public partial class SearchView
do { await Task.Delay(100); } while (MainWindow.YesWeCats.AssetsListName.Items.Count < folder.AssetsList.Assets.Count);
while (!folder.IsSelected || MainWindow.YesWeCats.AssetsFolderName.SelectedItem != folder)
await Task.Delay(50); // stops assets tab from opening too early
MainWindow.YesWeCats.LeftTabControl.SelectedIndex = 2; // assets tab
do
{

View File

@ -45,6 +45,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
@ -229,8 +230,12 @@
<CheckBox Grid.Row="17" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
IsChecked="{Binding ReadShaderMaps, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"/>
<TextBlock Grid.Row="18" Grid.Column="0" Text="Max Wwise Bank (.BNK) Prefetch" VerticalAlignment="Center" Margin="0 0 0 5" />
<Slider Grid.Row="18" Grid.Column="2" Grid.ColumnSpan="5" TickPlacement="None" Minimum="0" Maximum="512" Ticks="0,2,4,8,16,32,64,128,256,512"
<TextBlock Grid.Row="18" Grid.Column="0" Text="Decompile Blueprint to Pseudo C++" VerticalAlignment="Center" Margin="0 0 0 5" ToolTip="Adds a right click option to decompile UClass packages into a pseudo C++ friendly format" />
<CheckBox Grid.Row="18" Grid.Column="2" Content="{Binding IsChecked, RelativeSource={RelativeSource Self}, Converter={x:Static converters:BoolToToggleConverter.Instance}}"
IsChecked="{Binding ShowDecompileOption, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}" Margin="0 5 0 10"/>
<TextBlock Grid.Row="19" Grid.Column="0" Text="Max Wwise Bank (.BNK) Prefetch" VerticalAlignment="Center" Margin="0 0 0 5" />
<Slider Grid.Row="19" Grid.Column="2" Grid.ColumnSpan="5" TickPlacement="None" Minimum="0" Maximum="512" Ticks="0,2,4,8,16,32,64,128,256,512"
AutoToolTipPlacement="BottomRight" IsMoveToPointEnabled="True" IsSnapToTickEnabled="True" Margin="0 5 0 5"
Value="{Binding WwiseMaxBnkPrefetch, Source={x:Static local:Settings.UserSettings.Default}, Mode=TwoWay}"/>
</Grid>