From 60c2d7015379446f79eade7ce8395229e8ab73e1 Mon Sep 17 00:00:00 2001 From: iAmAsval Date: Fri, 4 Sep 2020 15:12:28 +0200 Subject: [PATCH] added more FTexts --- FModel/Creator/Creator.cs | 30 +++++++-------- .../PakReader/Parsers/Objects/ETextGender.cs | 10 +++++ .../Parsers/Objects/ETextHistoryType.cs | 32 ++++++++-------- .../Parsers/Objects/ETransformType.cs | 11 ++++++ .../Parsers/Objects/FFormatArgumentData.cs | 35 ++++++++++++++++++ FModel/PakReader/Parsers/Objects/FText.cs | 20 ++++++++-- .../Objects/FTextHistoryArgumentDataFormat.cs | 36 ++++++++++++++++++ .../Parsers/Objects/FTextHistoryAsDate.cs | 37 +++++++++++++++++++ .../Parsers/Objects/FTextHistoryAsTime.cs | 34 +++++++++++++++++ .../Parsers/Objects/FTextHistoryTransform.cs | 30 +++++++++++++++ 10 files changed, 239 insertions(+), 36 deletions(-) create mode 100644 FModel/PakReader/Parsers/Objects/ETextGender.cs create mode 100644 FModel/PakReader/Parsers/Objects/ETransformType.cs create mode 100644 FModel/PakReader/Parsers/Objects/FFormatArgumentData.cs create mode 100644 FModel/PakReader/Parsers/Objects/FTextHistoryArgumentDataFormat.cs create mode 100644 FModel/PakReader/Parsers/Objects/FTextHistoryAsDate.cs create mode 100644 FModel/PakReader/Parsers/Objects/FTextHistoryAsTime.cs create mode 100644 FModel/PakReader/Parsers/Objects/FTextHistoryTransform.cs diff --git a/FModel/Creator/Creator.cs b/FModel/Creator/Creator.cs index 82b90eda..f653bf6e 100644 --- a/FModel/Creator/Creator.cs +++ b/FModel/Creator/Creator.cs @@ -7,9 +7,7 @@ using FModel.Creator.Texts; using FModel.ViewModels.ImageBox; using PakReader.Parsers.Class; using PakReader.Parsers.Objects; -using PakReader.Parsers.PropertyTagData; using SkiaSharp; -using System.Diagnostics; using System.IO; namespace FModel.Creator @@ -244,20 +242,20 @@ namespace FModel.Creator } return true; } - case "StreamedVideoDataAsset": - { - if (Globals.Game.ActualGame == EGame.Valorant && exports[index].GetExport("Uuid") is StructProperty s && s.Value is FGuid uuid) - { - Process.Start(new ProcessStartInfo - { - FileName = string.Format( - "http://valorant.dyn.riotcdn.net/x/videos/release-01.05/{0}_default_universal.mp4", - $"{uuid.A:x8}-{uuid.B >> 16:x4}-{uuid.B & 0xFFFF:x4}-{uuid.C >> 16:x4}-{uuid.C & 0xFFFF:x4}{uuid.D:x8}"), - UseShellExecute = true - }); - } - return false; - } + //case "StreamedVideoDataAsset": // must find a way to automatically gets the right version in the url + // { + // if (Globals.Game.ActualGame == EGame.Valorant && exports[index].GetExport("Uuid") is StructProperty s && s.Value is FGuid uuid) + // { + // Process.Start(new ProcessStartInfo + // { + // FileName = string.Format( + // "http://valorant.dyn.riotcdn.net/x/videos/release-01.05/{0}_default_universal.mp4", + // $"{uuid.A:x8}-{uuid.B >> 16:x4}-{uuid.B & 0xFFFF:x4}-{uuid.C >> 16:x4}-{uuid.C & 0xFFFF:x4}{uuid.D:x8}"), + // UseShellExecute = true + // }); + // } + // return false; + // } } return false; } diff --git a/FModel/PakReader/Parsers/Objects/ETextGender.cs b/FModel/PakReader/Parsers/Objects/ETextGender.cs new file mode 100644 index 00000000..a2ca2cad --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/ETextGender.cs @@ -0,0 +1,10 @@ +namespace PakReader.Parsers.Objects +{ + public enum ETextGender : byte + { + Masculine, + Feminine, + Neuter, + // Add new enum types at the end only! They are serialized by index. + } +} diff --git a/FModel/PakReader/Parsers/Objects/ETextHistoryType.cs b/FModel/PakReader/Parsers/Objects/ETextHistoryType.cs index dc8c2f18..1281275a 100644 --- a/FModel/PakReader/Parsers/Objects/ETextHistoryType.cs +++ b/FModel/PakReader/Parsers/Objects/ETextHistoryType.cs @@ -2,21 +2,21 @@ { public enum ETextHistoryType : sbyte { - None = -1, - Base = 0, - NamedFormat, - OrderedFormat, - ArgumentFormat, - AsNumber, - AsPercent, - AsCurrency, - AsDate, - AsTime, - AsDateTime, - Transform, - StringTableEntry, - TextGenerator, + None = -1, + Base = 0, + NamedFormat, + OrderedFormat, + ArgumentFormat, + AsNumber, + AsPercent, + AsCurrency, + AsDate, + AsTime, + AsDateTime, + Transform, + StringTableEntry, + TextGenerator, - // Add new enum types at the end only! They are serialized by index. - } + // Add new enum types at the end only! They are serialized by index. + } } diff --git a/FModel/PakReader/Parsers/Objects/ETransformType.cs b/FModel/PakReader/Parsers/Objects/ETransformType.cs new file mode 100644 index 00000000..3f6cb3d6 --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/ETransformType.cs @@ -0,0 +1,11 @@ + +namespace PakReader.Parsers.Objects +{ + public enum ETransformType : byte + { + ToLower = 0, + ToUpper, + + // Add new enum types at the end only! They are serialized by index. + } +} diff --git a/FModel/PakReader/Parsers/Objects/FFormatArgumentData.cs b/FModel/PakReader/Parsers/Objects/FFormatArgumentData.cs new file mode 100644 index 00000000..047a6559 --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/FFormatArgumentData.cs @@ -0,0 +1,35 @@ +using System.Collections.Generic; + +namespace PakReader.Parsers.Objects +{ + public readonly struct FFormatArgumentData : IUStruct + { + public readonly string ArgumentName; + public readonly EFormatArgumentType ArgumentValueType; + public readonly object ArgumentValue; + + public FFormatArgumentData(PackageReader reader) + { + ArgumentName = reader.ReadFString(); + ArgumentValueType = (EFormatArgumentType)reader.ReadByte(); + ArgumentValue = ArgumentValueType switch + { + EFormatArgumentType.Int => reader.ReadInt32(), + EFormatArgumentType.Float => reader.ReadFloat(), + EFormatArgumentType.Text => new FText(reader), + EFormatArgumentType.Gender => (ETextGender)reader.ReadByte(), + _ => null, + }; + } + + public Dictionary GetValue() + { + return new Dictionary + { + ["ArgumentName"] = ArgumentName, + ["ArgumentValueType"] = ArgumentValueType, + ["ArgumentValue"] = ArgumentValue + }; + } + } +} diff --git a/FModel/PakReader/Parsers/Objects/FText.cs b/FModel/PakReader/Parsers/Objects/FText.cs index 54dfe47e..6c5c4958 100644 --- a/FModel/PakReader/Parsers/Objects/FText.cs +++ b/FModel/PakReader/Parsers/Objects/FText.cs @@ -23,6 +23,8 @@ namespace PakReader.Parsers.Objects var HistoryType = (ETextHistoryType)reader.ReadSByte(); // Create the history class based on the serialized type + // https://github.com/EpicGames/UnrealEngine/blob/283e412aa843210f2d6e9ed0236861cf749b3429/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.h + // https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.cpp switch (HistoryType) { case ETextHistoryType.Base: @@ -31,8 +33,6 @@ namespace PakReader.Parsers.Objects case ETextHistoryType.AsDateTime: Text = new FTextHistory.DateTime(reader); break; - // https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextHistory.cpp - // https://github.com/EpicGames/UnrealEngine/blob/bf95c2cbc703123e08ab54e3ceccdd47e48d224a/Engine/Source/Runtime/Core/Private/Internationalization/TextData.h case ETextHistoryType.NamedFormat: case ETextHistoryType.OrderedFormat: Text = new FTextHistory.OrderedFormat(reader); @@ -45,10 +45,18 @@ namespace PakReader.Parsers.Objects case ETextHistoryType.StringTableEntry: Text = new FTextHistory.StringTableEntry(reader); break; - case ETextHistoryType.ArgumentFormat: - case ETextHistoryType.AsDate: case ETextHistoryType.AsTime: + Text = new FTextHistory.AsTime(reader); + break; + case ETextHistoryType.AsDate: + Text = new FTextHistory.AsDate(reader); + break; + case ETextHistoryType.ArgumentFormat: + Text = new FTextHistory.ArgumentDataFormat(reader); + break; case ETextHistoryType.Transform: + Text = new FTextHistory.Transform(reader); + break; case ETextHistoryType.TextGenerator: throw new NotImplementedException(string.Format(FModel.Properties.Resources.ParsingNotSupported, HistoryType)); default: @@ -65,6 +73,10 @@ namespace PakReader.Parsers.Objects FTextHistory.OrderedFormat orderedFormat => orderedFormat.GetValue(), FTextHistory.FormatNumber formatNumber => formatNumber.GetValue(), FTextHistory.StringTableEntry stringTableEntry => stringTableEntry.GetValue(), + FTextHistory.AsTime asTime => asTime.GetValue(), + FTextHistory.AsDate asDate => asDate.GetValue(), + FTextHistory.ArgumentDataFormat argumentDataFormat => argumentDataFormat.GetValue(), + FTextHistory.Transform transform => transform.GetValue(), FTextHistory.None none => none.CultureInvariantString, _ => Text }; diff --git a/FModel/PakReader/Parsers/Objects/FTextHistoryArgumentDataFormat.cs b/FModel/PakReader/Parsers/Objects/FTextHistoryArgumentDataFormat.cs new file mode 100644 index 00000000..cb40ca12 --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/FTextHistoryArgumentDataFormat.cs @@ -0,0 +1,36 @@ +using System.Collections.Generic; + +namespace PakReader.Parsers.Objects +{ + public partial class FTextHistory + { + public sealed class ArgumentDataFormat : FTextHistory + { + public readonly FText FormatText; + public readonly FFormatArgumentData[] Arguments; + + internal ArgumentDataFormat(PackageReader reader) + { + FormatText = new FText(reader); + Arguments = reader.ReadTArray(() => new FFormatArgumentData(reader)); + } + + public Dictionary GetValue() + { + var ret = new object[Arguments.Length]; + for (int i = 0; i < ret.Length; i++) + { + ret[i] = Arguments[i] switch + { + _ => Arguments[i].GetValue(), + }; + } + return new Dictionary + { + ["FormatText"] = FormatText.GetValue(), + ["Arguments"] = ret + }; + } + } + } +} diff --git a/FModel/PakReader/Parsers/Objects/FTextHistoryAsDate.cs b/FModel/PakReader/Parsers/Objects/FTextHistoryAsDate.cs new file mode 100644 index 00000000..daad2260 --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/FTextHistoryAsDate.cs @@ -0,0 +1,37 @@ +using System.Collections.Generic; + +namespace PakReader.Parsers.Objects +{ + public partial class FTextHistory + { + public sealed class AsDate : FTextHistory + { + public readonly FDateTime SourceDateTime; + public readonly EDateTimeStyle DateStyle; + public readonly EDateTimeStyle TimeStyle; + public readonly string TimeZone; + public readonly string CultureName; + + internal AsDate(PackageReader reader) + { + SourceDateTime = new FDateTime(reader); + DateStyle = (EDateTimeStyle)reader.ReadByte(); + TimeStyle = (EDateTimeStyle)reader.ReadByte(); + TimeZone = reader.ReadFString(); + CultureName = reader.ReadFString(); + } + + public Dictionary GetValue() + { + return new Dictionary + { + ["SourceDateTime"] = SourceDateTime.Ticks, + ["DateStyle"] = DateStyle, + ["TimeStyle"] = TimeStyle, + ["TimeZone"] = TimeZone, + ["CultureName"] = CultureName, + }; + } + } + } +} diff --git a/FModel/PakReader/Parsers/Objects/FTextHistoryAsTime.cs b/FModel/PakReader/Parsers/Objects/FTextHistoryAsTime.cs new file mode 100644 index 00000000..4ea3a4ee --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/FTextHistoryAsTime.cs @@ -0,0 +1,34 @@ +using System.Collections.Generic; + +namespace PakReader.Parsers.Objects +{ + public partial class FTextHistory + { + public sealed class AsTime : FTextHistory + { + public readonly FDateTime SourceDateTime; + public readonly EDateTimeStyle TimeStyle; + public readonly string TimeZone; + public readonly string CultureName; + + internal AsTime(PackageReader reader) + { + SourceDateTime = new FDateTime(reader); + TimeStyle = (EDateTimeStyle)reader.ReadByte(); + TimeZone = reader.ReadFString(); + CultureName = reader.ReadFString(); + } + + public Dictionary GetValue() + { + return new Dictionary + { + ["SourceDateTime"] = SourceDateTime.Ticks, + ["TimeStyle"] = TimeStyle, + ["TimeZone"] = TimeZone, + ["CultureName"] = CultureName, + }; + } + } + } +} diff --git a/FModel/PakReader/Parsers/Objects/FTextHistoryTransform.cs b/FModel/PakReader/Parsers/Objects/FTextHistoryTransform.cs new file mode 100644 index 00000000..91505af4 --- /dev/null +++ b/FModel/PakReader/Parsers/Objects/FTextHistoryTransform.cs @@ -0,0 +1,30 @@ +using System.Collections.Generic; + +namespace PakReader.Parsers.Objects +{ + public partial class FTextHistory + { + public sealed class Transform : FTextHistory + { + /** The source text instance that was transformed */ + public readonly FText SourceText; + /** How the source text was transformed */ + public readonly ETransformType TransformType; + + internal Transform(PackageReader reader) + { + SourceText = new FText(reader); + TransformType = (ETransformType)reader.ReadByte(); + } + + public Dictionary GetValue() + { + return new Dictionary + { + ["SourceText"] = SourceText.GetValue(), + ["TransformType"] = TransformType + }; + } + } + } +}