From 5cc2f6c2e7cfe64208d2077f2a084ab1696c54e3 Mon Sep 17 00:00:00 2001 From: Nifyr Date: Sat, 18 Nov 2023 23:03:08 +0100 Subject: [PATCH] Added functionality for mods to pass args to IO --- DataParser.cs | 6 ++++++ FileManager.cs | 8 ++++++++ GlobalData.cs | 7 ++++--- Structs/ModArgs.cs | 15 +++++++++++++++ 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 Structs/ModArgs.cs diff --git a/DataParser.cs b/DataParser.cs index 8437c04..b2bbc6c 100644 --- a/DataParser.cs +++ b/DataParser.cs @@ -62,12 +62,18 @@ public static void PrepareAnalysis() ParseGlobalMetadata(); ParseDprBin(); ParseAudioData(); + TryParseModArgs(); Task.WaitAll(tasks.ToArray()); //Hot damn! 4GB?? This has got to go. monoBehaviourCollection = null; GC.Collect(); } + private static void TryParseModArgs() + { + gameData.modArgs = fileManager.TryGetModArgs(); + } + private static void TryParseExternalHoneyTrees() { gameData.externalHoneyTrees = null; diff --git a/FileManager.cs b/FileManager.cs index 6d66132..9e02a8b 100644 --- a/FileManager.cs +++ b/FileManager.cs @@ -46,6 +46,7 @@ public class FileManager private static readonly string globalMetadataPath = "romfs\\Data\\Managed\\Metadata\\global-metadata.dat"; private static readonly string dprBinPath = "romfs\\Data\\StreamingAssets\\AssetAssistant\\Dpr.bin"; private static readonly string externalJsonGamePath = "romfs\\Data\\ExtraData"; + private static readonly string modArgsPath = "ImpostersOrdealArgs.json"; private string assetAssistantPath; private string audioPath; @@ -596,6 +597,13 @@ public void CommitExternalJson(string externalJsonPath) fileArchive[externalJsonGamePath + "\\" + externalJsonPath].fileSource = FileSource.App; } + public ModArgs TryGetModArgs() + { + if (!fileArchive.ContainsKey(modArgsPath)) + return null; + return JsonConvert.DeserializeObject(File.ReadAllText(fileArchive[modArgsPath].fileLocation)); + } + public void DuplicateIconBundle(string srcPath, string dstPath) { FileData fd = new(); diff --git a/GlobalData.cs b/GlobalData.cs index 2769aa1..a16b843 100644 --- a/GlobalData.cs +++ b/GlobalData.cs @@ -62,6 +62,7 @@ public class GameDataSet public Dictionary trainerNames; public StringBuilder audioSourceLog; + public ModArgs modArgs; private readonly bool[] fieldStates = new bool[Enum.GetNames(typeof(DataField)).Length]; @@ -125,21 +126,21 @@ public string GetTPDisplayName(TrainerPokemon tp) public bool UgVersionsUnbounded() { - return ugEncounterFiles + return modArgs != null ? modArgs.ugVersionsUnbounded : ugEncounterFiles .SelectMany(o => o.ugEncounters) .Any(e => e.version < 1 || e.version > 3); } public bool Uint16UgTables() { - return ugEncounterFiles + return modArgs != null ? modArgs.uint16UgTables : ugEncounterFiles .SelectMany(ugef => ugef.ugEncounters) .Any(uge => (uint)uge.dexID > 0xFFFF); } public bool Uint16EncounterTables() { - return encounterTableFiles + return modArgs != null ? modArgs.uint16EncounterTables : encounterTableFiles .Any(etf => etf.encounterTables .Any(o => o.GetAllTables() .Any(l => l diff --git a/Structs/ModArgs.cs b/Structs/ModArgs.cs new file mode 100644 index 0000000..1e7fb73 --- /dev/null +++ b/Structs/ModArgs.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ImpostersOrdeal +{ + public class ModArgs + { + public bool ugVersionsUnbounded; + public bool uint16UgTables; + public bool uint16EncounterTables; + } +}