Example #1
0
        private static void LoadDirectories()
        {
            var directories = Directory.GetDirectories(CharacterDirectory);

            Tools.Print("# of character folders found: " + directories.Length);
            for (int i = 0; i < directories.Length; i++)
            {
                Tools.StartTimer("Loading data for " + Path.GetFileName(directories[i]));
                Tools.Print("");
                Tools.Print("--Loading " + Path.GetFileName(directories[i]) + "--", "0000FF");
                string customCharacterDir = Path.Combine(CharacterDirectory, directories[i]);
                string dataFilePath       = Path.Combine(customCharacterDir, DataFile);
                if (!File.Exists(dataFilePath))
                {
                    Tools.PrintError($"No \"{DataFile}\" file found for " + Path.GetFileName(directories[i]));
                    continue;
                }

                var lines = ResourceExtractor.GetLinesFromFile(dataFilePath);
                var data  = ParseCharacterData(lines);

                string spritesDir = Path.Combine(customCharacterDir, "sprites");
                if (Directory.Exists(spritesDir))
                {
                    Tools.Print("Found: Sprites folder");
                    data.sprites = ResourceExtractor.GetTexturesFromDirectory(spritesDir);
                }

                string foyerDir = Path.Combine(customCharacterDir, "foyercard");
                if (Directory.Exists(foyerDir))
                {
                    Tools.Print("Found: Foyer card folder");
                    data.foyerCardSprites = ResourceExtractor.GetTexturesFromDirectory(foyerDir);
                }

                List <Texture2D> miscTextures = ResourceExtractor.GetTexturesFromDirectory(customCharacterDir);
                foreach (var tex in miscTextures)
                {
                    string name = tex.name.ToLower();
                    if (name.Equals("icon"))
                    {
                        Tools.Print("Found: Icon ");
                        data.minimapIcon = tex;
                    }
                    if (name.Equals("bosscard"))
                    {
                        Tools.Print("Found: Bosscard");
                        data.bossCard = tex;
                    }
                    if (name.Equals("playersheet"))
                    {
                        Tools.Print("Found: Playersheet");
                        data.playerSheet = tex;
                    }
                    if (name.Equals("facecard"))
                    {
                        Tools.Print("Found: Facecard");
                        data.faceCard = tex;
                    }
                }

                string punchoutDir = Path.Combine(customCharacterDir, "punchout/");

                string punchoutSpritesDir = Path.Combine(punchoutDir, "sprites");
                if (Directory.Exists(punchoutSpritesDir))
                {
                    Tools.Print("Found: Punchout Sprites folder");
                    data.punchoutSprites = ResourceExtractor.GetTexturesFromDirectory(punchoutSpritesDir);
                }

                if (Directory.Exists(punchoutDir))
                {
                    data.punchoutFaceCards = new List <Texture2D>();
                    var punchoutSprites = ResourceExtractor.GetTexturesFromDirectory(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);
                            Tools.Print("Found: Punchout facecard " + tex.name);
                        }
                    }
                }
                characterData.Add(data);
                Tools.StopTimerAndReport("Loading data for " + Path.GetFileName(directories[i]));
            }
        }