コード例 #1
0
        void ReadAllUnits()
        {
            FoundUnits.Clear();
            IconBackgrounds.Clear();

            ZipFile zf     = GetGamedataFile.GetZipFileInstance(GetGamedataFile.UnitsScd);
            ZipFile FAF_zf = GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.UnitsScd);

            if (zf == null)
            {
                Preferences.Open();
                GenericInfoPopup.ShowInfo("Gamedata path not exist!");
                return;
            }

            IconBackgrounds.Add("land", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/land_up.dds", false, true, true));
            IconBackgrounds.Add("amph", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/amph_up.dds", false, true, true));
            IconBackgrounds.Add("sea", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/sea_up.dds", false, true, true));
            IconBackgrounds.Add("air", GetGamedataFile.LoadTexture2DFromGamedata(GetGamedataFile.TexturesScd, "/textures/ui/common/icons/units/air_up.dds", false, true, true));

            foreach (ZipEntry zipEntry in zf)
            {
                if (zipEntry.IsDirectory)
                {
                    continue;
                }

                string LocalName = zipEntry.Name;
                if (LocalName.ToLower().EndsWith("mesh.bp"))
                {
                    continue;
                }

                if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3)
                {
                    FoundUnits.Add(LocalName);
                }
            }
            int Count = FoundUnits.Count;

            if (FAF_zf != null)
            {
                string[] NewFiles = GetGamedataFile.GetNewFafFiles(GetGamedataFile.UnitsScd);

                for (int i = 0; i < NewFiles.Length; i++)
                {
                    string LocalName = NewFiles[i];
                    if (LocalName.ToLower().EndsWith("mesh.bp"))
                    {
                        continue;
                    }

                    if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3)
                    {
                        FoundUnits.Add(LocalName);
                    }
                }
            }

            Debug.Log("Found " + FoundUnits.Count + " units ( FAF: " + (FoundUnits.Count - Count) + ")");

            FoundUnits.Sort();
            Initialised = true;
        }
コード例 #2
0
        void ReadAllUnits()
        {
            FoundUnits.Clear();
            IconBackgrounds.Clear();

            //ZipFile zf = GetGamedataFile.GetZipFileInstance(GetGamedataFile.UnitsScd);
            //ZipFile FAF_zf = GetGamedataFile.GetFAFZipFileInstance(GetGamedataFile.UnitsScd);

            if (!EnvPaths.GamedataExist)
            {
                Preferences.Open();
                GenericInfoPopup.ShowInfo("Gamedata path not exist!");
                return;
            }

            IconBackgrounds.Add("land", GetGamedataFile.LoadTexture2D("/textures/ui/common/icons/units/land_up.dds", false, true, true));
            IconBackgrounds.Add("amph", GetGamedataFile.LoadTexture2D("/textures/ui/common/icons/units/amph_up.dds", false, true, true));
            IconBackgrounds.Add("sea", GetGamedataFile.LoadTexture2D("/textures/ui/common/icons/units/sea_up.dds", false, true, true));
            IconBackgrounds.Add("air", GetGamedataFile.LoadTexture2D("/textures/ui/common/icons/units/air_up.dds", false, true, true));

            string[] files = GetGamedataFile.GetFilesInPath("units/");

            for (int f = 0; f < files.Length; f++)
            {
                string LocalName = files[f];
                if (LocalName.ToLower().EndsWith("mesh.bp"))
                {
                    continue;
                }

                if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3)
                {
                    FoundUnits.Add(LocalName);
                }
            }


            /*foreach (ZipEntry zipEntry in zf)
             * {
             *      if (zipEntry.IsDirectory)
             *      {
             *              continue;
             *      }
             *
             *      string LocalName = zipEntry.Name;
             *      if (LocalName.ToLower().EndsWith("mesh.bp"))
             *              continue;
             *
             *      if (LocalName.ToLower().EndsWith(".bp") && LocalName.Split('/').Length <= 3)
             *      {
             *              FoundUnits.Add(LocalName);
             *      }
             * }
             * int Count = FoundUnits.Count;
             *
             * if (FAF_zf != null)
             * {
             *      string[] NewFiles = GetGamedataFile.GetNewFafFiles(GetGamedataFile.UnitsScd);
             *
             *      for (int i = 0; i < NewFiles.Length; i++)
             *      {
             *              string LocalName = NewFiles[i];
             *              if (LocalName.ToLower().EndsWith("mesh.bp"))
             *                      continue;
             *
             *              if (LocalName.ToLower().EndsWith(".bp"))
             *              {
             *                      if (LocalName.Split('/').Length <= 3) // Only from main folder
             *                      {
             *                              FoundUnits.Add(LocalName);
             *                      }
             *              }
             *      }
             * }
             *
             * Debug.Log("Found " + FoundUnits.Count + " units ( FAF: " + (FoundUnits.Count - Count) + ")");
             */

            Debug.Log("Found " + FoundUnits.Count + " units");

            FoundUnits.Sort();
            Initialised = true;
        }