GuiScreenServerList .java

net.minecraft.client.gui.GuiScreenServerList (class): members: field_146301_f, field_146302_g, field_146303_a, onGuiClosed, mouseClicked, updateScreen.

net.minecraft.client.guiclass111 linesclientextends GuiScreen4.2 KB

API Surface (7)

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

Fields & Constants (3)

field_146303_a
field_146301_f
field_146302_g

String literals (4)

"selectServer.select"
"gui.cancel"
"selectServer.direct"
"addServer.enterIp"

Code Graph: Dependencies (5)

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

Full Source

GuiScreenServerList.java111 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import java.io.IOException;
4
import net.minecraft.client.multiplayer.ServerData;
5
import net.minecraft.client.resources.I18n;
6
import org.lwjgl.input.Keyboard;
7
8
public class GuiScreenServerList extends GuiScreen
9
{
10
    private final GuiScreen field_146303_a;
11
    private final ServerData field_146301_f;
12
    private GuiTextField field_146302_g;
13
14
    public GuiScreenServerList(GuiScreen p_i1031_1_, ServerData p_i1031_2_)
15
    {
16
        this.field_146303_a = p_i1031_1_;
17
        this.field_146301_f = p_i1031_2_;
18
    }
19
20
    /**
21
     * Called from the main game loop to update the screen.
22
     */
23
    public void updateScreen()
24
    {
25
        this.field_146302_g.updateCursorCounter();
26
    }
27
28
    /**
29
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
30
     * window resizes, the buttonList is cleared beforehand.
31
     */
32
    public void initGui()
33
    {
34
        Keyboard.enableRepeatEvents(true);
35
        this.buttonList.clear();
36
        this.buttonList.add(new GuiButton(0, this.width / 2 - 100, this.height / 4 + 96 + 12, I18n.format("selectServer.select", new Object[0])));
37
        this.buttonList.add(new GuiButton(1, this.width / 2 - 100, this.height / 4 + 120 + 12, I18n.format("gui.cancel", new Object[0])));
38
        this.field_146302_g = new GuiTextField(2, this.fontRendererObj, this.width / 2 - 100, 116, 200, 20);
39
        this.field_146302_g.setMaxStringLength(128);
40
        this.field_146302_g.setFocused(true);
41
        this.field_146302_g.setText(this.mc.gameSettings.lastServer);
42
        ((GuiButton)this.buttonList.get(0)).enabled = this.field_146302_g.getText().length() > 0 && this.field_146302_g.getText().split(":").length > 0;
43
    }
44
45
    /**
46
     * Called when the screen is unloaded. Used to disable keyboard repeat events
47
     */
48
    public void onGuiClosed()
49
    {
50
        Keyboard.enableRepeatEvents(false);
51
        this.mc.gameSettings.lastServer = this.field_146302_g.getText();
52
        this.mc.gameSettings.saveOptions();
53
    }
54
55
    /**
56
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
57
     */
58
    protected void actionPerformed(GuiButton button) throws IOException
59
    {
60
        if (button.enabled)
61
        {
62
            if (button.id == 1)
63
            {
64
                this.field_146303_a.confirmClicked(false, 0);
65
            }
66
            else if (button.id == 0)
67
            {
68
                this.field_146301_f.serverIP = this.field_146302_g.getText();
69
                this.field_146303_a.confirmClicked(true, 0);
70
            }
71
        }
72
    }
73
74
    /**
75
     * Fired when a key is typed (except F11 which toggles full screen). This is the equivalent of
76
     * KeyListener.keyTyped(KeyEvent e). Args : character (character on the key), keyCode (lwjgl Keyboard key code)
77
     */
78
    protected void keyTyped(char typedChar, int keyCode) throws IOException
79
    {
80
        if (this.field_146302_g.textboxKeyTyped(typedChar, keyCode))
81
        {
82
            ((GuiButton)this.buttonList.get(0)).enabled = this.field_146302_g.getText().length() > 0 && this.field_146302_g.getText().split(":").length > 0;
83
        }
84
        else if (keyCode == 28 || keyCode == 156)
85
        {
86
            this.actionPerformed((GuiButton)this.buttonList.get(0));
87
        }
88
    }
89
90
    /**
91
     * Called when the mouse is clicked. Args : mouseX, mouseY, clickedButton
92
     */
93
    protected void mouseClicked(int mouseX, int mouseY, int mouseButton) throws IOException
94
    {
95
        super.mouseClicked(mouseX, mouseY, mouseButton);
96
        this.field_146302_g.mouseClicked(mouseX, mouseY, mouseButton);
97
    }
98
99
    /**
100
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
101
     */
102
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
103
    {
104
        this.drawDefaultBackground();
105
        this.drawCenteredString(this.fontRendererObj, I18n.format("selectServer.direct", new Object[0]), this.width / 2, 20, 16777215);
106
        this.drawString(this.fontRendererObj, I18n.format("addServer.enterIp", new Object[0]), this.width / 2 - 100, 100, 10526880);
107
        this.field_146302_g.drawTextBox();
108
        super.drawScreen(mouseX, mouseY, partialTicks);
109
    }
110
}
111

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