Skip to content

Commit

Permalink
Added functionality for mods to pass args to IO
Browse files Browse the repository at this point in the history
  • Loading branch information
Nifyr committed Nov 18, 2023
1 parent 4adedc4 commit 5cc2f6c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 3 deletions.
6 changes: 6 additions & 0 deletions DataParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 8 additions & 0 deletions FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ModArgs>(File.ReadAllText(fileArchive[modArgsPath].fileLocation));
}

public void DuplicateIconBundle(string srcPath, string dstPath)
{
FileData fd = new();
Expand Down
7 changes: 4 additions & 3 deletions GlobalData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public class GameDataSet

public Dictionary<string, string> trainerNames;
public StringBuilder audioSourceLog;
public ModArgs modArgs;

private readonly bool[] fieldStates = new bool[Enum.GetNames(typeof(DataField)).Length];

Expand Down Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions Structs/ModArgs.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}

0 comments on commit 5cc2f6c

Please sign in to comment.