private static CustomCharacterData GetCharacterData(string filePath) { filePath = filePath.Replace("/", ".").Replace("\\", "."); ToolsCharApi.StartTimer("Loading data for " + Path.GetFileName(filePath)); ToolsCharApi.Print(""); ToolsCharApi.Print("--Loading " + Path.GetFileName(filePath) + "--", "0000FF"); //string customCharacterDir = Path.Combine(CharacterDirectory, filePath).Replace("/", ".").Replace("\\", "."); string dataFilePath = Path.Combine(filePath, "characterdata.txt").Replace("/", ".").Replace("\\", "."); var assembly = Assembly.GetCallingAssembly(); var lines = new string[0]; using (Stream stream = assembly.GetManifestResourceStream(dataFilePath)) using (StreamReader reader = new StreamReader(stream)) { var linesList = new List <string>(); string line = null; while ((line = reader.ReadLine()) != null) { linesList.Add(line); } //ToolsCharApi.PrintError(linesList.Count().ToString()); lines = linesList.ToArray(); } if (lines.Count() <= 0) { ToolsCharApi.PrintError($"No \"{DataFile}\" file found for " + Path.GetFileName(filePath)); return(null); } //var lines = ToolsCharApi.GetLinesFromFile(dataFilePath); var data = ParseCharacterData(lines); string spritesDir = Path.Combine(filePath, "sprites").Replace("/", ".").Replace("\\", "."); string newSpritesDir = Path.Combine(filePath, "newspritesetup").Replace("/", ".").Replace("\\", "."); string newAltSpritesDir = Path.Combine(filePath, "newaltspritesetup").Replace("/", ".").Replace("\\", "."); string altSpritesDir = Path.Combine(filePath, "alt_sprites").Replace("/", ".").Replace("\\", "."); string loadoutDir = Path.Combine(filePath, "loadoutsprites").Replace("/", ".").Replace("\\", "."); string foyerDir = Path.Combine(filePath, "foyercard").Replace("/", ".").Replace("\\", "."); string punchoutDir = Path.Combine(filePath, "punchout").Replace("/", ".").Replace("\\", "."); string punchoutSpritesDir = Path.Combine(filePath, "punchout.sprites").Replace("/", ".").Replace("\\", "."); string[] resources = ToolsCharApi.GetResourceNames(); for (int i = 0; i < resources.Length; i++) { if (resources[i].Contains(filePath)) { if (resources[i].StartsWith(spritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.sprites == null) { //ToolsCharApi.PrintError("Found: Sprites folder"); data.sprites = ToolsCharApi.GetTexturesFromResource(spritesDir); } if (resources[i].StartsWith(altSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.altSprites == null) { //ToolsCharApi.PrintError("Found: Alt Sprites folder"); data.altSprites = ToolsCharApi.GetTexturesFromResource(altSpritesDir); } if (resources[i].StartsWith(newSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(data.pathForSprites)) { //ToolsCharApi.PrintError("Found: New Sprites folder"); data.pathForSprites = newSpritesDir; } if (resources[i].StartsWith(newAltSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && string.IsNullOrEmpty(data.pathForAltSprites)) { //ToolsCharApi.PrintError("Found: New Sprites folder"); data.pathForAltSprites = newAltSpritesDir; } if (resources[i].StartsWith(foyerDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.foyerCardSprites == null) { //ToolsCharApi.PrintError("Found: Foyer card folder"); data.foyerCardSprites = ToolsCharApi.GetTexturesFromResource(foyerDir); } if (resources[i].StartsWith(loadoutDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.loadoutSprites == null) { //ToolsCharApi.PrintError("Found: Loadout card folder"); data.loadoutSprites = ToolsCharApi.GetTexturesFromResource(loadoutDir); //ToolsCharApi.PrintError(data.loadoutSprites.Count.ToString()); } if (resources[i].StartsWith(punchoutSpritesDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.punchoutSprites == null) { ToolsCharApi.Print("Found: Punchout Sprites folder"); Debug.Log("Found: Punchout Sprites folder"); data.punchoutSprites = new Dictionary <string, Texture2D>(); foreach (var tex in ToolsCharApi.GetTexturesFromResource(punchoutSpritesDir)) { data.punchoutSprites.Add(tex.name, tex); } } if (resources[i].StartsWith(punchoutDir.Replace('/', '.'), StringComparison.OrdinalIgnoreCase) && data.punchoutFaceCards == null) { data.punchoutFaceCards = new List <Texture2D>(); //ETGModConsole.Log(punchoutDir); var punchoutSprites = ToolsCharApi.GetTexturesFromResource(punchoutDir); foreach (var tex in punchoutSprites) { string name = tex.name.ToLower(); if (name.Contains("facecard1") || name.Contains("facecard2") || name.Contains("facecard3")) { data.punchoutFaceCards.Add(tex); ToolsCharApi.Print("Found: Punchout facecard " + tex.name); } } } } } //ToolsCharApi.PrintError("new sprites"); //ToolsCharApi.PrintError("alt sprites"); //ToolsCharApi.PrintError("foyer card sprites"); //ToolsCharApi.PrintError("loadout sprites"); List <Texture2D> miscTextures = ToolsCharApi.GetTexturesFromResource(filePath); foreach (var tex in miscTextures) { string name = tex.name.ToLower(); if (name.Equals("icon")) { //ToolsCharApi.PrintError("Found: Icon "); data.minimapIcon = tex; } if (name.Equals("coop_page_death")) { //ToolsCharApi.PrintError("Found: Icon "); data.coopDeathScreenIcon = tex; } if (name.Contains("bosscard_")) { //ToolsCharApi.PrintError("Found: Bosscard"); //BotsModule.Log(name.ToLower().Replace("bosscard_", "").Replace("0", "")); data.bossCard.Add(tex); } if (name.Equals("playersheet")) { //ToolsCharApi.PrintError("Found: Playersheet"); data.playerSheet = tex; } if (name.Equals("facecard")) { //ToolsCharApi.PrintError("Found: Facecard"); data.faceCard = tex; } if (name.Equals("win_pic_junkan")) { //ToolsCharApi.PrintError("Found: Junkan Win Pic"); data.junkanWinPic = tex; } if (name.Equals("win_pic")) { //ToolsCharApi.PrintError("Found: Past Win Pic"); data.pastWinPic = tex; } if (name.Equals("alt_skin_obj_sprite_001")) { //ToolsCharApi.PrintError("Found: alt_skin_obj_sprite_001"); data.altObjSprite1 = tex; } if (name.Equals("alt_skin_obj_sprite_002")) { //ToolsCharApi.PrintError("Found: alt_skin_obj_sprite_002"); data.altObjSprite2 = tex; } } //ToolsCharApi.PrintError("other sprites"); //ToolsCharApi.StopTimerAndReport("Loading data for " + Path.GetFileName(directories[i])); return(data); }