Skip to content

Commit

Permalink
Expanded pokémon inserter with ability to duplicate icons
Browse files Browse the repository at this point in the history
  • Loading branch information
Nifyr committed Sep 12, 2022
1 parent b0f7260 commit d1e3e27
Show file tree
Hide file tree
Showing 2 changed files with 516 additions and 25 deletions.
56 changes: 53 additions & 3 deletions FileManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using System.Configuration;
using System.Threading.Tasks;
using System.Text;
using System.Security.Cryptography;

namespace ImpostersOrdeal
{
Expand Down Expand Up @@ -74,7 +75,7 @@ private enum FileSource
App
}

public AssetsManager getAssetsManager()
public AssetsManager GetAssetsManager()
{
return am;
}
Expand Down Expand Up @@ -362,6 +363,47 @@ public BundleFileInstance TryGetPokemonBundleFileInstance(string path)
return fileArchive[gamePath].bundle;
}

/// <summary>
/// Returns the BundleFileInstance of the texturemass bundle.
/// </summary>
public BundleFileInstance GetTexturemassBundle()
{
string absolutePath = assetAssistantPath + "\\UIs\\textures_mass\\texturemass";
string gamePath = "romfs\\Data\\StreamingAssets\\AssetAssistant\\UIs\\textures_mass\\texturemass";

if (!fileArchive.ContainsKey(gamePath))
{
if (!File.Exists(absolutePath))
{
MessageBox.Show("File not found:\n" + gamePath,
"Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return null;
}

FileData fd = new();
fd.fileLocation = absolutePath;
fd.gamePath = gamePath;
fd.fileSource = FileSource.Dump;
fileArchive[gamePath] = fd;
}

if (!fileArchive[gamePath].IsBundle())
{
FileData fd = fileArchive[gamePath];
fd.bundle = am.LoadBundleFile(fd.fileLocation, false);
DecompressBundle(fd.bundle);
}

return fileArchive[gamePath].bundle;
}

public void WriteTexturemassBundle(List<AssetsReplacer> ars)
{
string gamePath = "romfs\\Data\\StreamingAssets\\AssetAssistant\\UIs\\textures_mass\\texturemass";
fileArchive[gamePath].fileSource = FileSource.App;
MakeTempBundle(fileArchive[gamePath], ars, "texturemass");
}

/// <summary>
/// Gets a list of MonoBehaviour value fields by PathEnum.
/// </summary>
Expand Down Expand Up @@ -517,6 +559,15 @@ public StringBuilder GetAudioSourceLog()
return new(File.ReadAllText(fileArchive[logPath].fileLocation));
}

public void DuplicateIconBundle(string srcPath, string dstPath)
{
FileData fd = new();
fd.fileLocation = assetAssistantPath + "\\UIs\\" + srcPath;
fd.gamePath = "romfs\\Data\\StreamingAssets\\AssetAssistant\\UIs\\" + dstPath;
fd.fileSource = FileSource.App;
fileArchive[fd.gamePath] = fd;
}

/// <summary>
/// Places a file relative to the mod root in accordance with its FileData.
/// </summary>
Expand Down Expand Up @@ -651,8 +702,7 @@ private void MakeTempBundle(FileData fd, List<AssetsReplacer> ars, string fileNa
afw = new(File.OpenWrite(fileLocation));
fd.bundle.file.Write(afw, new List<BundleReplacer> { brfm });
afw.Close();
fd.bundle.file.Close();
fd.bundle.stream.Dispose();
am = new();
fd.bundle = am.LoadBundleFile(fileLocation, false);
DecompressBundle(fd.bundle);
if (fd.tempLocation)
Expand Down
Loading

0 comments on commit d1e3e27

Please sign in to comment.