    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.src.Tessellator;
    020    import cpw.mods.fml.common.Loader;
    021    import cpw.mods.fml.common.LoaderState.ModState;
    022    import cpw.mods.fml.common.ModContainer;
    023
    024    /**
    025     * @author cpw
    026     *
    027     */
    028    public class GuiSlotModList extends GuiScrollingList
    029    {
    030        private GuiModList parent;
    031        private ArrayList<ModContainer> mods;
    032
    033        public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
    034        {
    035            super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 65 + 4, 10, 35);
    036            this.parent=parent;
    037            this.mods=mods;
    038        }
    039
    040        @Override
    041        protected int getSize()
    042        {
    043            return mods.size();
    044        }
    045
    046        @Override
    047        protected void elementClicked(int var1, boolean var2)
    048        {
    049            this.parent.selectModIndex(var1);
    050        }
    051
    052        @Override
    053        protected boolean isSelected(int var1)
    054        {
    055            return this.parent.modIndexSelected(var1);
    056        }
    057
    058        @Override
    059        protected void drawBackground()
    060        {
    061            this.parent.drawDefaultBackground();
    062        }
    063
    064        @Override
    065        protected int getContentHeight()
    066        {
    067            return (this.getSize()) * 35 + 1;
    068        }
    069
    070        @Override
    071        protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
    072        {
    073            ModContainer mc=mods.get(listIndex);
    074            if (Loader.instance().getModState(mc)==ModState.DISABLED)
    075            {
    076                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222);
    077                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222);
    078                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222);
    079            }
    080            else
    081            {
    082                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
    083                this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
    084                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);
    085            }
    086        }
    087
    088    }