    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 / 4 + 132 + var1, 114, 20, StatCollector.translateToLocal("demo.help.buy")));
    020            this.controlList.add(new GuiButton(2, this.width / 2 + 2, this.height / 4 + 132 + 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            this.fontRenderer.drawString(StatCollector.translateToLocal("demo.help.title"), var4, 44, 2039583);
    081            GameSettings var6 = this.mc.gameSettings;
    082            byte var7 = 60;
    083            String var5 = StatCollector.translateToLocal("demo.help.movementShort");
    084            var5 = String.format(var5, new Object[] {Keyboard.getKeyName(var6.keyBindForward.keyCode), Keyboard.getKeyName(var6.keyBindLeft.keyCode), Keyboard.getKeyName(var6.keyBindBack.keyCode), Keyboard.getKeyName(var6.keyBindRight.keyCode)});
    085            this.fontRenderer.drawString(var5, var4, var7, 5197647);
    086            var5 = StatCollector.translateToLocal("demo.help.movementMouse");
    087            this.fontRenderer.drawString(var5, var4, var7 + 12, 5197647);
    088            var5 = StatCollector.translateToLocal("demo.help.jump");
    089            var5 = String.format(var5, new Object[] {Keyboard.getKeyName(var6.keyBindJump.keyCode)});
    090            this.fontRenderer.drawString(var5, var4, var7 + 24, 5197647);
    091            var5 = StatCollector.translateToLocal("demo.help.inventory");
    092            var5 = String.format(var5, new Object[] {Keyboard.getKeyName(var6.keyBindInventory.keyCode)});
    093            this.fontRenderer.drawString(var5, var4, var7 + 36, 5197647);
    094            this.fontRenderer.drawSplitString(StatCollector.translateToLocal("demo.help.fullWrapped"), var4, var7 + 68, 218, 2039583);
    095            super.drawScreen(par1, par2, par3);
    096        }
    097    }