From 2ded17d9e8f6d28773f735f1ed9c3db14915f747 Mon Sep 17 00:00:00 2001 From: LongerWarrior Date: Sun, 4 Oct 2026 17:16:37 +0300 Subject: [PATCH] Ace Combat 8 localization / FN preview fix --- CUE4Parse | 2 +- FModel/Creator/Bases/FN/BaseIcon.cs | 6 +-- FModel/Creator/Utils.cs | 12 ++--- FModel/ViewModels/CUE4ParseViewModel.cs | 61 ++++++++++++++++++++++++- 4 files changed, 65 insertions(+), 16 deletions(-) diff --git a/CUE4Parse b/CUE4Parse index 52f96d60..6b8909bf 160000 --- a/CUE4Parse +++ b/CUE4Parse @@ -1 +1 @@ -Subproject commit 52f96d60eadf95f2933a5599461d94f0774d08c1 +Subproject commit 6b8909bf961f054e1d2571173f9de81a5c96b2ee diff --git a/FModel/Creator/Bases/FN/BaseIcon.cs b/FModel/Creator/Bases/FN/BaseIcon.cs index 5b79b834..e6016509 100644 --- a/FModel/Creator/Bases/FN/BaseIcon.cs +++ b/FModel/Creator/Bases/FN/BaseIcon.cs @@ -47,14 +47,12 @@ public class BaseIcon : UCreator { if (isUsingDisplayAsset && Utils.TryGetDisplayAsset(Object, out var preview)) Preview = preview; - else if (Object.TryGetValue(out FPackageIndex itemDefinition, "HeroDefinition", "WeaponDefinition")) + else if (Object.TryGetValue(out ILoadableObject itemDefinition, "HeroDefinition", "WeaponDefinition")) Preview = Utils.GetBitmap(itemDefinition); - else if (Object.TryGetValue(out FSoftObjectPath largePreview, "LargePreviewImage", "EntryListIcon", "SmallPreviewImage", "BundleImage", "ItemDisplayAsset", "LargeIcon", "ToastIcon", "SmallIcon", "CartridgeIcon", "EffectIcon")) + else if (Object.TryGetValue(out ILoadableObject largePreview, "LargePreviewImage", "EntryListIcon", "SmallPreviewImage", "BundleImage", "ItemDisplayAsset", "LargeIcon", "ToastIcon", "SmallIcon", "CartridgeIcon", "EffectIcon", "ToastIcon", "access_item")) Preview = Utils.GetBitmap(largePreview); else if (Object.TryGetValue(out string s, "LargePreviewImage") && !string.IsNullOrEmpty(s)) Preview = Utils.GetBitmap(s); - else if (Object.TryGetValue(out FPackageIndex otherPreview, "SmallPreviewImage", "ToastIcon", "access_item")) - Preview = Utils.GetBitmap(otherPreview); else if (Object.TryGetValue(out UMaterialInstanceConstant materialInstancePreview, "EventCalloutImage")) Preview = Utils.GetBitmap(materialInstancePreview); else if (Object.TryGetValue(out FStructFallback brush, "IconBrush", "BuildingSymbolNormal") && brush.TryGetValue(out UTexture2D res, "ResourceObject")) diff --git a/FModel/Creator/Utils.cs b/FModel/Creator/Utils.cs index 3d44c40e..965917d9 100644 --- a/FModel/Creator/Utils.cs +++ b/FModel/Creator/Utils.cs @@ -60,11 +60,11 @@ public static class Utils return preview != null; } - public static SKBitmap GetBitmap(FPackageIndex packageIndex) + public static SKBitmap GetBitmap(ILoadableObject loadableObject) { while (true) { - if (!TryGetPackageIndexExport(packageIndex, out UObject export)) return null; + if (!loadableObject.TryLoad(out UObject export)) return null; switch (export) { case UTexture2D texture: @@ -74,13 +74,8 @@ public static class Utils default: { if (export.TryGetValue(out FInstancedStruct[] dataList, "DataList")) return GetBitmap(dataList); - if (export.TryGetValue(out FSoftObjectPath previewImage, "LargePreviewImage", "SmallPreviewImage")) return GetBitmap(previewImage); + if (export.TryGetValue(out ILoadableObject previewImage, "LargePreviewImage", "SmallPreviewImage")) return GetBitmap(previewImage); if (export.TryGetValue(out string largePreview, "LargePreviewImage")) return GetBitmap(largePreview); - if (export.TryGetValue(out FPackageIndex smallPreview, "SmallPreviewImage")) - { - packageIndex = smallPreview; - continue; - } return null; } @@ -128,7 +123,6 @@ public static class Utils } public static SKBitmap GetB64Bitmap(string b64) => SKBitmap.Decode(new MemoryStream(Convert.FromBase64String(b64)) { Position = 0 }); - public static SKBitmap GetBitmap(FSoftObjectPath softObjectPath) => GetBitmap(softObjectPath.Load()); public static SKBitmap GetBitmap(string fullPath) => TryLoadObject(fullPath, out UTexture2D texture) ? GetBitmap(texture) : null; public static SKBitmap GetBitmap(UTexture2D texture) => texture.Decode(UserSettings.Default.CurrentDir.TexturePlatform).ToSkBitmap(); public static SKBitmap GetBitmap(byte[] data) => SKBitmap.Decode(data); diff --git a/FModel/ViewModels/CUE4ParseViewModel.cs b/FModel/ViewModels/CUE4ParseViewModel.cs index f92072aa..105ffeae 100644 --- a/FModel/ViewModels/CUE4ParseViewModel.cs +++ b/FModel/ViewModels/CUE4ParseViewModel.cs @@ -19,6 +19,8 @@ using CUE4Parse.Encryption.Aes; using CUE4Parse.FileProvider; using CUE4Parse.FileProvider.Objects; using CUE4Parse.FileProvider.Vfs; +using CUE4Parse.GameTypes.ACE8.Assets.Exports; +using CUE4Parse.GameTypes.ACE8.Encryption; using CUE4Parse.GameTypes.Aion2.Objects; using CUE4Parse.GameTypes.AoC.Objects; using CUE4Parse.GameTypes.AshEchoes.FileProvider; @@ -749,6 +751,11 @@ public class CUE4ParseViewModel : ViewModel ProcessAion2DatFile(entry, updateUi, saveProperties); break; } + case "dat" when Provider.Versions.Game is GAME_AceCombat8WingsofTheve: + { + ProcessACE8DatFile(entry, updateUi, saveProperties); + break; + } case "bytes" when Provider.Versions.Game is GAME_RocoKingdomWorld: { ProcessRocoBinFile(entry, updateUi, saveProperties); @@ -1067,6 +1074,7 @@ public class CUE4ParseViewModel : ViewModel } case "res": // just skip case "bytes": // wuthering waves + case "ffxanim": // dead island 2 break; default: { @@ -1190,6 +1198,43 @@ public class CUE4ParseViewModel : ViewModel TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(dbc, Formatting.Indented), saveProperties, updateUi); } + + // Ace Combat 8 + void ProcessACE8DatFile(GameFile entry, bool updateUi, bool saveProperties) + { + TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("json"); + + if (entry.NameWithoutExtension.EndsWith("_Cmn")) + { + TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ACE8LocDecrypt.ReadKeysDatFile(entry), Formatting.Indented), saveProperties, updateUi); + } + else + { + if (Provider.TryGetGameFile(entry.PathWithoutExtension[..^1] + "Cmn." + entry.Extension, out var keysDatFile)) + { + var keys = ACE8LocDecrypt.ReadKeysDatFile(keysDatFile); + var values = ACE8LocDecrypt.ReadDatFile(entry); + var locTable = new Dictionary(Math.Max(keys.Count, values.Length)); + var k = 0; + for (var i = 0; i < values.Length; i++) + { + if (keys.TryGetValue(i, out var key)) + { + locTable[key] = values[i]; + } + else + { + locTable[$"UnknownKey_{k++}"] = values[i]; + } + } + TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(locTable, Formatting.Indented), saveProperties, updateUi); + } + else + { + TabControl.SelectedTab.SetDocumentText(JsonConvert.SerializeObject(ACE8LocDecrypt.ReadDatFile(entry), Formatting.Indented), saveProperties, updateUi); + } + } + } } private byte[] ProcessLuaFile(byte[] data) @@ -1259,6 +1304,8 @@ public class CUE4ParseViewModel : ViewModel if (CheckExport(cancellationToken, result.Package, i, ref showSnooper)) break; } + + if (showSnooper) SnooperViewer.Run(); } private bool CheckExport(CancellationToken cancellationToken, IPackage pkg, int index, ref bool showSnooper, EBulkType bulk = EBulkType.None) // return true once you want to stop searching for exports @@ -1276,11 +1323,21 @@ public class CUE4ParseViewModel : ViewModel { case UVerseDigest when isNone && pointer.Object.Value is UVerseDigest verseDigest: { - if (!TabControl.CanAddTabs) return false; + if (verseDigest.ReadableCode is null || !TabControl.CanAddTabs) return false; TabControl.AddTab($"{verseDigest.Name}.verse"); TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("verse"); - TabControl.SelectedTab.SetDocumentText(verseDigest.ReadableCode, false, false); + TabControl.SelectedTab.SetDocumentText(Encoding.UTF8.GetString(verseDigest.ReadableCode), false, false); + return true; + } + // Ace Combat 8 + case ULuaScript when isNone && pointer.Object.Value is ULuaScript luaScript: + { + if (!TabControl.CanAddTabs) return false; + + TabControl.AddTab($"{luaScript.Name}.lua"); + TabControl.SelectedTab.Highlighter = AvalonExtensions.HighlighterSelector("lua"); + TabControl.SelectedTab.SetDocumentText(luaScript.Code, false, false); return true; } case UTexture when (isNone || saveTextures) && pointer.Object.Value is UTexture texture: