    001/*
    002 * Forge Mod Loader
    003 * Copyright (c) 2012-2013 cpw.
    004 * All rights reserved. This program and the accompanying materials
    005 * are made available under the terms of the GNU Lesser Public License v2.1
    006 * which accompanies this distribution, and is available at
    007 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
    008 *
    009 * Contributors:
    010 *     cpw - implementation
    011 */
    012
    013package cpw.mods.fml.client;
    014
    015import java.util.ArrayList;
    016
    017import net.minecraft.client.renderer.Tessellator;
    018
    019import cpw.mods.fml.common.Loader;
    020import cpw.mods.fml.common.LoaderState.ModState;
    021import cpw.mods.fml.common.ModContainer;
    022
    023/**
    024 * @author cpw
    025 *
    026 */
    027public class GuiSlotModList extends GuiScrollingList
    028{
    029    private GuiModList parent;
    030    private ArrayList<ModContainer> mods;
    031
    032    public GuiSlotModList(GuiModList parent, ArrayList<ModContainer> mods, int listWidth)
    033    {
    034        super(parent.getMinecraftInstance(), listWidth, parent.height, 32, parent.height - 65 + 4, 10, 35);
    035        this.parent=parent;
    036        this.mods=mods;
    037    }
    038
    039    @Override
    040    protected int getSize()
    041    {
    042        return mods.size();
    043    }
    044
    045    @Override
    046    protected void elementClicked(int var1, boolean var2)
    047    {
    048        this.parent.selectModIndex(var1);
    049    }
    050
    051    @Override
    052    protected boolean isSelected(int var1)
    053    {
    054        return this.parent.modIndexSelected(var1);
    055    }
    056
    057    @Override
    058    protected void drawBackground()
    059    {
    060        this.parent.drawDefaultBackground();
    061    }
    062
    063    @Override
    064    protected int getContentHeight()
    065    {
    066        return (this.getSize()) * 35 + 1;
    067    }
    068
    069    @Override
    070    protected void drawSlot(int listIndex, int var2, int var3, int var4, Tessellator var5)
    071    {
    072        ModContainer mc=mods.get(listIndex);
    073        if (Loader.instance().getModState(mc)==ModState.DISABLED)
    074        {
    075            this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFF2222);
    076            this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xFF2222);
    077            this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth("DISABLED", listWidth - 10), this.left + 3 , var3 + 22, 0xFF2222);
    078        }
    079        else
    080        {
    081            this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getName(), listWidth - 10), this.left + 3 , var3 + 2, 0xFFFFFF);
    082            this.parent.getFontRenderer().drawString(this.parent.getFontRenderer().trimStringToWidth(mc.getDisplayVersion(), listWidth - 10), this.left + 3 , var3 + 12, 0xCCCCCC);
    083            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);
    084        }
    085    }
    086
    087}