GuiDisconnected .java

net.minecraft.client.gui.GuiDisconnected (class, 75 lines): members: multilineMessage, field_175353_i, message, reason, parentScreen, keyTyped, initGui.

net.minecraft.client.guiclass75 linesclientextends GuiScreen2.7 KB

API Surface (4)

void keyTyped(char typedChar, int keyCode)
void initGui()
void actionPerformed(GuiButton button)
void drawScreen(int mouseX, int mouseY, float partialTicks)

Fields & Constants (5)

reason
message
multilineMessage
parentScreen
field_175353_i

String literals (1)

"gui.toMenu"

Code Graph: Dependencies (6)

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

Full Source

GuiDisconnected.java75 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import java.util.List;
5
import net.minecraft.client.resources.I18n;
6
import net.minecraft.util.IChatComponent;
7
8
public class GuiDisconnected extends GuiScreen
9
{
10
    private String reason;
11
    private IChatComponent message;
12
    private List<String> multilineMessage;
13
    private final GuiScreen parentScreen;
14
    private int field_175353_i;
15
16
    public GuiDisconnected(GuiScreen screen, String reasonLocalizationKey, IChatComponent chatComp)
17
    {
18
        this.parentScreen = screen;
19
        this.reason = I18n.format(reasonLocalizationKey, new Object[0]);
20
        this.message = chatComp;
21
    }
22
23
    /**
24
     * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
25
     * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
26
     */
27
    protected void keyTyped(char typedChar, int keyCode) throws IOException
28
    {
29
    }
30
31
    /**
32
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
33
     * window resizes, the buttonList is cleared beforehand.
34
     */
35
    public void initGui()
36
    {
37
        this.buttonList.clear();
38
        this.multilineMessage = this.fontRendererObj.listFormattedStringToWidth(this.message.getFormattedText(), this.width - 50);
39
        this.field_175353_i = this.multilineMessage.size() * this.fontRendererObj.FONT_HEIGHT;
40
        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 2 + this.field_175353_i / 2 + this.fontRendererObj.FONT_HEIGHT, I18n.format("gui.toMenu", new Object[0])));
41
    }
42
43
    /**
44
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
45
     */
46
    protected void actionPerformed(GuiButton button) throws IOException
47
    {
48
        if (button.id == 0)
49
        {
50
            this.mc.displayGuiScreen(this.parentScreen);
51
        }
52
    }
53
54
    /**
55
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
56
     */
57
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
58
    {
59
        this.drawDefaultBackground();
60
        this.drawCenteredString(this.fontRendererObj, this.reason, this.width / 2, this.height / 2 - this.field_175353_i / 2 - this.fontRendererObj.FONT_HEIGHT * 2, 11184810);
61
        int i = this.height / 2 - this.field_175353_i / 2;
62
63
        if (this.multilineMessage != null)
64
        {
65
            for (String s : this.multilineMessage)
66
            {
67
                this.drawCenteredString(this.fontRendererObj, s, this.width / 2, i, 16777215);
68
                i += this.fontRendererObj.FONT_HEIGHT;
69
            }
70
        }
71
72
        super.drawScreen(mouseX, mouseY, partialTicks);
73
    }
74
}
75

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