public TexturePackList(Minecraft par1Minecraft, string par2File)
        {
            availableTexturePacks = new List <TexturePackBase>();
            DefaultTexturePack    = new TexturePackDefault(par1Minecraft);
            Field_6538_d          = new Dictionary <string, TexturePackBase>();
            Mc             = par1Minecraft;
            TexturePackDir = IOPath.Combine(par2File, "Texturepacks");

            if (Directory.Exists(TexturePackDir))
            {
                if (File.Exists(TexturePackDir))
                {
                    File.Delete(TexturePackDir);
                    Directory.CreateDirectory(TexturePackDir);
                }
            }
            else
            {
                Directory.CreateDirectory(TexturePackDir);
            }

            CurrentTexturePack = par1Minecraft.GameSettings.Skin;
            UpdateAvaliableTexturePacks();
            SelectedTexturePack.Func_6482_a();
        }
        public virtual int[] GetTextureContents(string par1Str)
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;

            if (TextureContentsMap.ContainsKey(par1Str))
            {
                return(TextureContentsMap[par1Str]);
            }

            try
            {
                int[] ai1 = null;

                if (par1Str.StartsWith("##"))
                {
                    ai1 = GetImageContentsAndAllocate(UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(2)))));
                }
                else if (par1Str.StartsWith("%clamp%"))
                {
                    ClampTexture = true;
                    ai1          = GetImageContentsAndAllocate(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(7))));
                    ClampTexture = false;
                }
                else if (par1Str.StartsWith("%blur%"))
                {
                    BlurTexture  = true;
                    ClampTexture = true;
                    ai1          = GetImageContentsAndAllocate(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(6))));
                    ClampTexture = false;
                    BlurTexture  = false;
                }
                else
                {
                    Stream inputstream = texturepackbase.GetResourceAsStream(par1Str);

                    if (inputstream == null)
                    {
                        ai1 = GetImageContentsAndAllocate(MissingTextureImage);
                    }
                    else
                    {
                        ai1 = GetImageContentsAndAllocate(ReadTextureImage(inputstream));
                    }
                }

                TextureContentsMap.Add(par1Str, ai1);
                return(ai1);
            }
            catch (IOException ioexception)
            {
                Utilities.LogException(ioexception);
            }

            int[] ai2 = GetImageContentsAndAllocate(MissingTextureImage);
            TextureContentsMap.Add(par1Str, ai2);
            return(ai2);
        }
 /// <summary>
 /// Sets the new TexturePack to be used, returning true if it has actually changed, false if nothing changed.
 /// </summary>
 public virtual bool SetTexturePack(TexturePackBase par1TexturePackBase)
 {
     if (par1TexturePackBase == SelectedTexturePack)
     {
         return(false);
     }
     else
     {
         SelectedTexturePack.CloseTexturePackFile();
         CurrentTexturePack   = par1TexturePackBase.TexturePackFileName;
         SelectedTexturePack  = par1TexturePackBase;
         Mc.GameSettings.Skin = CurrentTexturePack;
         Mc.GameSettings.SaveOptions();
         SelectedTexturePack.Func_6482_a();
         return(true);
     }
 }
        protected override void DrawSlot(int par1, int par2, int par3, int par4, Tessellator par5Tessellator)
        {
            TexturePackBase texturepackbase = GuiTexturePacks.GetMinecraft(ParentTexturePackGui).TexturePackList.AvailableTexturePacks()[par1];

            texturepackbase.BindThumbnailTexture(GuiTexturePacks.GetMinecraft(ParentTexturePackGui));/*
                                                                                                      * GL.Color4(1.0F, 1.0F, 1.0F, 1.0F);
                                                                                                      * par5Tessellator.StartDrawingQuads();
                                                                                                      * par5Tessellator.SetColorOpaque_I(0xffffff);
                                                                                                      * par5Tessellator.AddVertexWithUV(par2,      par3 + par4, 0.0F, 0.0F, 1.0D);
                                                                                                      * par5Tessellator.AddVertexWithUV(par2 + 32, par3 + par4, 0.0F, 1.0D, 1.0D);
                                                                                                      * par5Tessellator.AddVertexWithUV(par2 + 32, par3,        0.0F, 1.0D, 0.0F);
                                                                                                      * par5Tessellator.AddVertexWithUV(par2,      par3,        0.0F, 0.0F, 0.0F);
                                                                                                      * par5Tessellator.Draw();*/
            RenderEngine.Instance.RenderSprite(new Rectangle(par2, par3, 32, par4), null);

            ParentTexturePackGui.DrawString(GuiTexturePacks.GetMinecraft(ParentTexturePackGui).FontRenderer, texturepackbase.TexturePackFileName, par2 + 32 + 2, par3 + 1, 0xffffff);
            ParentTexturePackGui.DrawString(GuiTexturePacks.GetMinecraft(ParentTexturePackGui).FontRenderer, texturepackbase.FirstDescriptionLine, par2 + 32 + 2, par3 + 12, 0x808080);
            ParentTexturePackGui.DrawString(GuiTexturePacks.GetMinecraft(ParentTexturePackGui).FontRenderer, texturepackbase.SecondDescriptionLine, par2 + 32 + 2, par3 + 12 + 10, 0x808080);
        }
        /// <summary>
        /// check the texture packs the client has installed
        /// </summary>
        public virtual void UpdateAvaliableTexturePacks()
        {
            List <TexturePackBase> arraylist = new List <TexturePackBase>();

            SelectedTexturePack = null;
            arraylist.Add(DefaultTexturePack);

            if (Directory.Exists(TexturePackDir))
            {
                string[] afile  = Directory.GetFiles(TexturePackDir);
                string[] afile1 = afile;
                int      i      = afile1.Length;

                for (int j = 0; j < i; j++)
                {
                    FileInfo file = new FileInfo(afile1[j]);

                    if (file.Name.ToLower().EndsWith(".zip"))
                    {
                        string s = (new StringBuilder()).Append(file.Name).Append(":").Append(file.Length).Append(":").Append(file.LastWriteTime).ToString();

                        try
                        {
                            if (!Field_6538_d.ContainsKey(s))
                            {
                                TexturePackCustom texturepackcustom = new TexturePackCustom(file.FullName);
                                texturepackcustom.TexturePackID = s;
                                Field_6538_d[s] = texturepackcustom;
                                texturepackcustom.Func_6485_a(Mc);
                            }

                            TexturePackBase texturepackbase1 = Field_6538_d[s];

                            if (texturepackbase1.TexturePackFileName.Equals(CurrentTexturePack))
                            {
                                SelectedTexturePack = texturepackbase1;
                            }

                            arraylist.Add(texturepackbase1);
                        }
                        catch (IOException ioexception)
                        {
                            Console.WriteLine(ioexception.ToString());
                            Console.Write(ioexception.StackTrace);
                        }

                        continue;
                    }

                    if (!Directory.Exists(file.FullName) || !File.Exists(IOPath.Combine(file.FullName, "pack.txt")))
                    {
                        continue;
                    }

                    string s1 = (new StringBuilder()).Append(file.Name).Append(":folder:").Append(file.LastWriteTime).ToString();

                    try
                    {
                        if (!Field_6538_d.ContainsKey(s1))
                        {
                            TexturePackFolder texturepackfolder = new TexturePackFolder(file.FullName);
                            texturepackfolder.TexturePackID = s1;
                            Field_6538_d[s1] = texturepackfolder;
                            texturepackfolder.Func_6485_a(Mc);
                        }

                        TexturePackBase texturepackbase2 = Field_6538_d[s1];

                        if (texturepackbase2.TexturePackFileName.Equals(CurrentTexturePack))
                        {
                            SelectedTexturePack = texturepackbase2;
                        }

                        arraylist.Add(texturepackbase2);
                    }
                    catch (IOException ioexception1)
                    {
                        Console.WriteLine(ioexception1.ToString());
                        Console.WriteLine();
                    }
                }
            }

            if (SelectedTexturePack == null)
            {
                SelectedTexturePack = DefaultTexturePack;
            }

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'removeAll' method:
            foreach (TexturePackBase t in arraylist)
            {
                availableTexturePacks.Remove(t);
            }

            TexturePackBase texturepackbase;

            for (IEnumerator <TexturePackBase> iterator = availableTexturePacks.GetEnumerator(); iterator.MoveNext(); Field_6538_d.Remove(texturepackbase.TexturePackID))
            {
                texturepackbase = iterator.Current;
                texturepackbase.UnbindThumbnailTexture(Mc);
            }

            availableTexturePacks = arraylist;
        }
        /// <summary>
        /// Call setupTexture on all currently-loaded textures again to account for changes in rendering options
        /// </summary>
        public void RefreshTextures()
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;
            int             i;
            Bitmap          bufferedimage;

            for (IEnumerator <int> iterator = TextureNameToImageMap.GetKeySet().GetEnumerator(); iterator.MoveNext(); SetupTexture(bufferedimage, i))
            {
                i             = iterator.Current;
                bufferedimage = (Bitmap)TextureNameToImageMap.Lookup(i);
            }
            for (IEnumerator <ThreadedImageDownloader> iterator1 = UrlToImageDataMap.Values.GetEnumerator(); iterator1.MoveNext();)
            {
                ThreadedImageDownloader threaddownloadimagedata = iterator1.Current;
                threaddownloadimagedata.TextureSetupComplete = false;
            }
            for (IEnumerator <string> iterator2 = TextureMap.Keys.GetEnumerator(); iterator2.MoveNext();)
            {
                string s = (string)iterator2.Current;
                try
                {
                    Bitmap bufferedimage1;
                    if (s.StartsWith("##"))
                    {
                        bufferedimage1 = UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(2))));
                    }
                    else if (s.StartsWith("%clamp%"))
                    {
                        ClampTexture   = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(7)));
                    }
                    else if (s.StartsWith("%blur%"))
                    {
                        BlurTexture    = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(6)));
                    }
                    else if (s.StartsWith("%blurclamp%"))
                    {
                        BlurTexture    = true;
                        ClampTexture   = true;
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s.Substring(11)));
                    }
                    else
                    {
                        bufferedimage1 = ReadTextureImage(texturepackbase.GetResourceAsStream(s));
                    }
                    int j = TextureMap[s];
                    SetupTexture(bufferedimage1, j);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                catch (IOException ioexception)
                {
                    Utilities.LogException(ioexception);
                }
            }
            for (IEnumerator <string> iterator3 = TextureContentsMap.Keys.GetEnumerator(); iterator3.MoveNext();)
            {
                string s1 = (string)iterator3.Current;
                try
                {
                    Bitmap bufferedimage2;
                    if (s1.StartsWith("##"))
                    {
                        bufferedimage2 = UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(2))));
                    }
                    else if (s1.StartsWith("%clamp%"))
                    {
                        ClampTexture   = true;
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(7)));
                    }
                    else if (s1.StartsWith("%blur%"))
                    {
                        BlurTexture    = true;
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1.Substring(6)));
                    }
                    else
                    {
                        bufferedimage2 = ReadTextureImage(texturepackbase.GetResourceAsStream(s1));
                    }
                    GetImageContents(bufferedimage2, (int[])TextureContentsMap[s1]);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                catch (IOException ioexception1)
                {
                    Utilities.LogException(ioexception1);
                }
            }
        }
        public virtual int GetTexture(string par1Str)
        {
            TexturePackBase texturepackbase = TexturePack.SelectedTexturePack;

            if (TextureMap.ContainsKey(par1Str))
            {
                return(TextureMap[par1Str]);
            }

            try
            {
                SingleIntBuffer.Clear();
                GLAllocation.GenerateTextureNames(SingleIntBuffer);
                int i = SingleIntBuffer.Get(0);

                if (par1Str.StartsWith("##"))
                {
                    SetupTexture(UnwrapImageByColumns(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(2)))), i);
                }
                else if (par1Str.StartsWith("%clamp%"))
                {
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(7))), i);
                    ClampTexture = false;
                }
                else if (par1Str.StartsWith("%blur%"))
                {
                    BlurTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(6))), i);
                    BlurTexture = false;
                }
                else if (par1Str.StartsWith("%blurclamp%"))
                {
                    BlurTexture  = true;
                    ClampTexture = true;
                    SetupTexture(ReadTextureImage(texturepackbase.GetResourceAsStream(par1Str.Substring(11))), i);
                    BlurTexture  = false;
                    ClampTexture = false;
                }
                else
                {
                    Stream inputstream = texturepackbase.GetResourceAsStream(par1Str);

                    if (inputstream == null)
                    {
                        SetupTexture(MissingTextureImage, i);
                    }
                    else
                    {
                        SetupTexture(ReadTextureImage(inputstream), i);
                    }
                }

                TextureMap.Add(par1Str, i);
                return(i);
            }
            catch (Exception exception)
            {
                Utilities.LogException(exception);
            }

            GLAllocation.GenerateTextureNames(SingleIntBuffer);
            int j = SingleIntBuffer.Get(0);

            SetupTexture(MissingTextureImage, j);
            TextureMap.Add(par1Str, j);
            return(j);
        }