    001package net.minecraft.client.gui;
    002
    003import cpw.mods.fml.relauncher.Side;
    004import cpw.mods.fml.relauncher.SideOnly;
    005import java.net.URI;
    006import net.minecraft.client.settings.GameSettings;
    007import net.minecraft.util.StatCollector;
    008import org.lwjgl.input.Keyboard;
    009import org.lwjgl.opengl.GL11;
    010
    011@SideOnly(Side.CLIENT)
    012public class GuiScreenDemo extends GuiScreen
    013{
    014    /**
    015     * Adds the buttons (and other controls) to the screen in question.
    016     */
    017    public void initGui()
    018    {
    019        this.controlList.clear();
    020        byte var1 = -16;
    021        this.controlList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + var1, 114, 20, StatCollector.translateToLocal("demo.help.buy")));
    022        this.controlList.add(new GuiButton(2, this.width / 2 + 2, this.height / 2 + 62 + var1, 114, 20, StatCollector.translateToLocal("demo.help.later")));
    023    }
    024
    025    /**
    026     * Fired when a control is clicked. This is the equivalent of ActionListener.actionPerformed(ActionEvent e).
    027     */
    028    protected void actionPerformed(GuiButton par1GuiButton)
    029    {
    030        switch (par1GuiButton.id)
    031        {
    032            case 1:
    033                par1GuiButton.enabled = false;
    034
    035                try
    036                {
    037                    Class var2 = Class.forName("java.awt.Desktop");
    038                    Object var3 = var2.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
    039                    var2.getMethod("browse", new Class[] {URI.class}).invoke(var3, new Object[] {new URI("http://www.minecraft.net/store?source=demo")});
    040                }
    041                catch (Throwable var4)
    042                {
    043                    var4.printStackTrace();
    044                }
    045
    046                break;
    047            case 2:
    048                this.mc.displayGuiScreen((GuiScreen)null);
    049                this.mc.setIngameFocus();
    050        }
    051    }
    052
    053    /**
    054     * Called from the main game loop to update the screen.
    055     */
    056    public void updateScreen()
    057    {
    058        super.updateScreen();
    059    }
    060
    061    /**
    062     * Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png
    063     */
    064    public void drawDefaultBackground()
    065    {
    066        super.drawDefaultBackground();
    067        int var1 = this.mc.renderEngine.getTexture("/gui/demo_bg.png");
    068        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    069        this.mc.renderEngine.bindTexture(var1);
    070        int var2 = (this.width - 248) / 2;
    071        int var3 = (this.height - 166) / 2;
    072        this.drawTexturedModalRect(var2, var3, 0, 0, 248, 166);
    073    }
    074
    075    /**
    076     * Draws the screen and all the components in it.
    077     */
    078    public void drawScreen(int par1, int par2, float par3)
    079    {
    080        this.drawDefaultBackground();
    081        int var4 = (this.width - 248) / 2 + 10;
    082        int var5 = (this.height - 166) / 2 + 8;
    083        this.fontRenderer.drawString(StatCollector.translateToLocal("demo.help.title"), var4, var5, 2039583);
    084        var5 += 12;
    085        GameSettings var7 = this.mc.gameSettings;
    086        String var6 = StatCollector.translateToLocal("demo.help.movementShort");
    087        var6 = String.format(var6, new Object[] {Keyboard.getKeyName(var7.keyBindForward.keyCode), Keyboard.getKeyName(var7.keyBindLeft.keyCode), Keyboard.getKeyName(var7.keyBindBack.keyCode), Keyboard.getKeyName(var7.keyBindRight.keyCode)});
    088        this.fontRenderer.drawString(var6, var4, var5, 5197647);
    089        var6 = StatCollector.translateToLocal("demo.help.movementMouse");
    090        this.fontRenderer.drawString(var6, var4, var5 + 12, 5197647);
    091        var6 = StatCollector.translateToLocal("demo.help.jump");
    092        var6 = String.format(var6, new Object[] {Keyboard.getKeyName(var7.keyBindJump.keyCode)});
    093        this.fontRenderer.drawString(var6, var4, var5 + 24, 5197647);
    094        var6 = StatCollector.translateToLocal("demo.help.inventory");
    095        var6 = String.format(var6, new Object[] {Keyboard.getKeyName(var7.keyBindInventory.keyCode)});
    096        this.fontRenderer.drawString(var6, var4, var5 + 36, 5197647);
    097        this.fontRenderer.drawSplitString(StatCollector.translateToLocal("demo.help.fullWrapped"), var4, var5 + 68, 218, 2039583);
    098        super.drawScreen(par1, par2, par3);
    099    }
    100}