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