001    /*
002     * The FML Forge Mod Loader suite.
003     * Copyright (C) 2012 cpw
004     *
005     * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or any later version.
007     *
008     * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
009     * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
010     *
011     * You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51
012     * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
013     */
014    
015    package cpw.mods.fml.client;
016    
017    import java.util.ArrayList;
018    
019    import net.minecraft.client.renderer.Tessellator;
020    
021    import cpw.mods.fml.common.Loader;
022    import cpw.mods.fml.common.LoaderState.ModState;
023    import cpw.mods.fml.common.ModContainer;
024    
025    /**
026     * @author cpw
027     *
028     */
029    public class GuiSlotModList extends GuiScrollingList
030    {
031        private GuiModList parent;
032        private ArrayList<ModContainer> mods;
033    
034        public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
035        {
036            super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 65 + 4, 10, 35);
037            this.parent=parent;
038            this.mods=mods;
039        }
040    
041        @Override
042        protected int getSize()
043        {
044            return mods.size();
045        }
046    
047        @Override
048        protected void elementClicked(int var1, boolean var2)
049        {
050            this.parent.selectModIndex(var1);
051        }
052    
053        @Override
054        protected boolean isSelected(int var1)
055        {
056            return this.parent.modIndexSelected(var1);
057        }
058    
059        @Override
060        protected void drawBackground()
061        {
062            this.parent.drawDefaultBackground();
063        }
064    
065        @Override
066        protected int getContentHeight()
067        {
068            return (this.getSize()) * 35 + 1;
069        }
070    
071        @Override
072        protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
073        {
074            ModContainer mc=mods.get(listIndex);
075            if (Loader.instance().getModState(mc)==ModState.DISABLED)
076            {
077                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222);
078                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222);
079                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222);
080            }
081            else
082            {
083                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
084                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
085                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getMetadata() !=null ? mc.getMetadata().getChildModCountString() : "Metadata not found", listWidth - 10), this.left + 3 , var3 + 22, 0xCCCCCC);
086            }
087        }
088    
089    }