    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 net.minecraft.client.gui.GuiButton;
    016import net.minecraft.client.gui.GuiScreen;
    017import net.minecraft.client.gui.GuiSmallButton;
    018import net.minecraft.util.StringTranslate;
    019import cpw.mods.fml.common.network.ModMissingPacket;
    020import cpw.mods.fml.common.versioning.ArtifactVersion;
    021
    022public class GuiModsMissingForServer extends GuiScreen
    023{
    024    private ModMissingPacket modsMissing;
    025
    026    public GuiModsMissingForServer(ModMissingPacket modsMissing)
    027    {
    028        this.modsMissing = modsMissing;
    029    }
    030
    031    @Override
    032
    033    /**
    034     * Adds the buttons (and other controls) to the screen in question.
    035     */
    036    public void initGui()
    037    {
    038        StringTranslate translations = StringTranslate.getInstance();
    039        this.buttonList.add(new GuiSmallButton(1, this.width / 2 - 75, this.height - 38, translations.translateKey("gui.done")));
    040    }
    041
    042    @Override
    043
    044    /**
    045     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    046     */
    047    protected void actionPerformed(GuiButton par1GuiButton)
    048    {
    049        if (par1GuiButton.enabled && par1GuiButton.id == 1)
    050        {
    051            FMLClientHandler.instance().getClient().displayGuiScreen(null);
    052        }
    053    }
    054    @Override
    055
    056    /**
    057     * Draws the screen and all the components in it.
    058     */
    059    public void drawScreen(int par1, int par2, float par3)
    060    {
    061        this.drawDefaultBackground();
    062        int offset = Math.max(85 - modsMissing.getModList().size() * 10, 10);
    063        this.drawCenteredString(this.fontRenderer, "Forge Mod Loader could not connect to this server", this.width / 2, offset, 0xFFFFFF);
    064        offset += 10;
    065        this.drawCenteredString(this.fontRenderer, "The mods and versions listed below could not be found", this.width / 2, offset, 0xFFFFFF);
    066        offset += 10;
    067        this.drawCenteredString(this.fontRenderer, "They are required to play on this server", this.width / 2, offset, 0xFFFFFF);
    068        offset += 5;
    069        for (ArtifactVersion v : modsMissing.getModList())
    070        {
    071            offset += 10;
    072            this.drawCenteredString(this.fontRenderer, String.format("%s : %s", v.getLabel(), v.getRangeString()), this.width / 2, offset, 0xEEEEEE);
    073        }
    074        super.drawScreen(par1, par2, par3);
    075    }
    076}