Skip to content

Instantly share code, notes, and snippets.

@pixeldesu
Created March 14, 2019 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pixeldesu/3d6d5dc9a62376d651d2b3bc25cd9134 to your computer and use it in GitHub Desktop.
Save pixeldesu/3d6d5dc9a62376d651d2b3bc25cd9134 to your computer and use it in GitHub Desktop.
IFFFileManager prototype
using System.Collections.Generic;
using System.IO;
using PangLib.IFF;
using PangLib.IFF.DataModels;
namespace PangLib.IFF
{
class IFFFileManager
{
private string BasePath;
public Dictionary<string, IFFFile> Files = new Dictionary<string, IFFFile>();
public IFFFileManager (string basePath)
{
BasePath = basePath;
Build();
}
private void Build()
{
// get all file paths from BasePath
string[] files = System.IO.Directory.GetFiles(BasePath, "*.iff");
files.forEach(file => {
// get all filenames from the files
string Model = Path.GetFileNameWithoutExtension(file);
// add specific IFFFile to IFFFileManager dictionary Files
switch (Model)
{
case "Character":
Files.Add(Model, IFFFile<Character>.Load(file);
break;
case "Caddie":
Files.Add(Model, IFFFile<Caddie>.Load(file);
break;
// ...
}
// resulting structure:
// IFFFileManager.Files {
// "Character" => IFFFile<Character>
// "Caddie" => IFFFile<Caddie>
// ...
// }
});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment