GuiScreenDemo .java

net.minecraft.client.gui.GuiScreenDemo (class): members: field_146348_f, drawDefaultBackground, updateScreen, actionPerformed, initGui, drawScreen, logger.

net.minecraft.client.guiclass98 linesclientextends GuiScreen4.3 KB

API Surface (5)

void initGui()
void actionPerformed(GuiButton button)
void updateScreen()
void drawDefaultBackground()
void drawScreen(int mouseX, int mouseY, float partialTicks)

Fields & Constants (2)

logger
field_146348_f

String literals (14)

"textures/gui/demo_background.png"
"demo.help.buy"
"demo.help.later"
"java.awt.Desktop"
"getDesktop"
"browse"
"http://www.minecraft.net/store?source=demo"
"Couldn\'t open link"
"demo.help.title"
"demo.help.movementShort"
"demo.help.movementMouse"
"demo.help.jump"
"demo.help.inventory"
"demo.help.fullWrapped"

Code Graph: Dependencies (8)

Edges (calls / imports / inherits / references) resolved by graphify from the AST. Every chip opens the class source.

Full Source

GuiScreenDemo.java98 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import java.net.URI;
5
import net.minecraft.client.renderer.GlStateManager;
6
import net.minecraft.client.resources.I18n;
7
import net.minecraft.client.settings.GameSettings;
8
import net.minecraft.util.ResourceLocation;
9
import org.apache.logging.log4j.LogManager;
10
import org.apache.logging.log4j.Logger;
11
12
public class GuiScreenDemo extends GuiScreen
13
{
14
    private static final Logger logger = LogManager.getLogger();
15
    private static final ResourceLocation field_146348_f = new ResourceLocation("textures/gui/demo_background.png");
16
17
    /**
18
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
19
     * window resizes, the buttonList is cleared beforehand.
20
     */
21
    public void initGui()
22
    {
23
        this.buttonList.clear();
24
        int i = -16;
25
        this.buttonList.add(new GuiButton(1, this.width / 2 - 116, this.height / 2 + 62 + i, 114, 20, I18n.format("demo.help.buy", new Object[0])));
26
        this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height / 2 + 62 + i, 114, 20, I18n.format("demo.help.later", new Object[0])));
27
    }
28
29
    /**
30
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
31
     */
32
    protected void actionPerformed(GuiButton button) throws IOException
33
    {
34
        switch (button.id)
35
        {
36
            case 1:
37
                button.enabled = false;
38
39
                try
40
                {
41
                    Class<?> oclass = Class.forName("java.awt.Desktop");
42
                    Object object = oclass.getMethod("getDesktop", new Class[0]).invoke((Object)null, new Object[0]);
43
                    oclass.getMethod("browse", new Class[] {URI.class}).invoke(object, new Object[] {new URI("http://www.minecraft.net/store?source=demo")});
44
                }
45
                catch (Throwable throwable)
46
                {
47
                    logger.error("Couldn\'t open link", throwable);
48
                }
49
50
                break;
51
52
            case 2:
53
                this.mc.displayGuiScreen((GuiScreen)null);
54
                this.mc.setIngameFocus();
55
        }
56
    }
57
58
    /**
59
     * Called from the main game loop to update the screen.
60
     */
61
    public void updateScreen()
62
    {
63
        super.updateScreen();
64
    }
65
66
    /**
67
     * Draws either a gradient over the background screen (when it exists) or a flat gradient over background.png
68
     */
69
    public void drawDefaultBackground()
70
    {
71
        super.drawDefaultBackground();
72
        GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
73
        this.mc.getTextureManager().bindTexture(field_146348_f);
74
        int i = (this.width - 248) / 2;
75
        int j = (this.height - 166) / 2;
76
        this.drawTexturedModalRect(i, j, 0, 0, 248, 166);
77
    }
78
79
    /**
80
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
81
     */
82
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
83
    {
84
        this.drawDefaultBackground();
85
        int i = (this.width - 248) / 2 + 10;
86
        int j = (this.height - 166) / 2 + 8;
87
        this.fontRendererObj.drawString(I18n.format("demo.help.title", new Object[0]), i, j, 2039583);
88
        j = j + 12;
89
        GameSettings gamesettings = this.mc.gameSettings;
90
        this.fontRendererObj.drawString(I18n.format("demo.help.movementShort", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindForward.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindLeft.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindBack.getKeyCode()), GameSettings.getKeyDisplayString(gamesettings.keyBindRight.getKeyCode())}), i, j, 5197647);
91
        this.fontRendererObj.drawString(I18n.format("demo.help.movementMouse", new Object[0]), i, j + 12, 5197647);
92
        this.fontRendererObj.drawString(I18n.format("demo.help.jump", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindJump.getKeyCode())}), i, j + 24, 5197647);
93
        this.fontRendererObj.drawString(I18n.format("demo.help.inventory", new Object[] {GameSettings.getKeyDisplayString(gamesettings.keyBindInventory.getKeyCode())}), i, j + 36, 5197647);
94
        this.fontRendererObj.drawSplitString(I18n.format("demo.help.fullWrapped", new Object[0]), i, j + 68, 218, 2039583);
95
        super.drawScreen(mouseX, mouseY, partialTicks);
96
    }
97
}
98

Deobfuscated MCP 1.8.9 source of GuiScreenDemo from Marcelektro/MavenMCP-1.8.9 (net/minecraft/client/gui/GuiScreenDemo.java), stored verbatim.