GuiIngestServers .java

net.minecraft.client.gui.stream.GuiIngestServers (class): members: field_152309_a, field_152310_f, field_152311_g, ServerList, onGuiClosed, initGui.

net.minecraft.client.gui.streamclass179 linesclientextends GuiScreen6.6 KB

API Surface (11)

void initGui()
void handleMouseInput()
void onGuiClosed()
void actionPerformed(GuiButton button)
void drawScreen(int mouseX, int mouseY, float partialTicks)
int getSize()
void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
boolean isSelected(int slotIndex)
void drawBackground()
void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
int getScrollBarX()

Fields & Constants (3)

field_152309_a
field_152310_f
field_152311_g

String literals (8)

"options.stream.ingest.title"
"gui.done"
"options.stream.ingest.reset"
"\\{stream_key\\}"
" kbps"
"Down!"
"(Preferred)"
"(Default)"

Full Source

GuiIngestServers.java179 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui.stream;
2
3
import java.io.IOException;
4
import net.minecraft.client.Minecraft;
5
import net.minecraft.client.gui.GuiButton;
6
import net.minecraft.client.gui.GuiScreen;
7
import net.minecraft.client.gui.GuiSlot;
8
import net.minecraft.client.resources.I18n;
9
import net.minecraft.client.stream.IngestServerTester;
10
import net.minecraft.util.EnumChatFormatting;
11
import tv.twitch.broadcast.IngestServer;
12
13
public class GuiIngestServers extends GuiScreen
14
{
15
    private final GuiScreen field_152309_a;
16
    private String field_152310_f;
17
    private GuiIngestServers.ServerList field_152311_g;
18
19
    public GuiIngestServers(GuiScreen p_i46312_1_)
20
    {
21
        this.field_152309_a = p_i46312_1_;
22
    }
23
24
    /**
25
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
26
     * window resizes, the buttonList is cleared beforehand.
27
     */
28
    public void initGui()
29
    {
30
        this.field_152310_f = I18n.format("options.stream.ingest.title", new Object[0]);
31
        this.field_152311_g = new GuiIngestServers.ServerList(this.mc);
32
33
        if (!this.mc.getTwitchStream().func_152908_z())
34
        {
35
            this.mc.getTwitchStream().func_152909_x();
36
        }
37
38
        this.buttonList.add(new GuiButton(1, this.width / 2 - 155, this.height - 24 - 6, 150, 20, I18n.format("gui.done", new Object[0])));
39
        this.buttonList.add(new GuiButton(2, this.width / 2 + 5, this.height - 24 - 6, 150, 20, I18n.format("options.stream.ingest.reset", new Object[0])));
40
    }
41
42
    /**
43
     * Handles mouse input.
44
     */
45
    public void handleMouseInput() throws IOException
46
    {
47
        super.handleMouseInput();
48
        this.field_152311_g.handleMouseInput();
49
    }
50
51
    /**
52
     * Called when the screen is unloaded. Used to disable keyboard repeat events
53
     */
54
    public void onGuiClosed()
55
    {
56
        if (this.mc.getTwitchStream().func_152908_z())
57
        {
58
            this.mc.getTwitchStream().func_152932_y().func_153039_l();
59
        }
60
    }
61
62
    /**
63
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
64
     */
65
    protected void actionPerformed(GuiButton button) throws IOException
66
    {
67
        if (button.enabled)
68
        {
69
            if (button.id == 1)
70
            {
71
                this.mc.displayGuiScreen(this.field_152309_a);
72
            }
73
            else
74
            {
75
                this.mc.gameSettings.streamPreferredServer = "";
76
                this.mc.gameSettings.saveOptions();
77
            }
78
        }
79
    }
80
81
    /**
82
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
83
     */
84
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
85
    {
86
        this.drawDefaultBackground();
87
        this.field_152311_g.drawScreen(mouseX, mouseY, partialTicks);
88
        this.drawCenteredString(this.fontRendererObj, this.field_152310_f, this.width / 2, 20, 16777215);
89
        super.drawScreen(mouseX, mouseY, partialTicks);
90
    }
91
92
    class ServerList extends GuiSlot
93
    {
94
        public ServerList(Minecraft mcIn)
95
        {
96
            super(mcIn, GuiIngestServers.this.width, GuiIngestServers.this.height, 32, GuiIngestServers.this.height - 35, (int)((double)mcIn.fontRendererObj.FONT_HEIGHT * 3.5D));
97
            this.setShowSelectionBox(false);
98
        }
99
100
        protected int getSize()
101
        {
102
            return this.mc.getTwitchStream().func_152925_v().length;
103
        }
104
105
        protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
106
        {
107
            this.mc.gameSettings.streamPreferredServer = this.mc.getTwitchStream().func_152925_v()[slotIndex].serverUrl;
108
            this.mc.gameSettings.saveOptions();
109
        }
110
111
        protected boolean isSelected(int slotIndex)
112
        {
113
            return this.mc.getTwitchStream().func_152925_v()[slotIndex].serverUrl.equals(this.mc.gameSettings.streamPreferredServer);
114
        }
115
116
        protected void drawBackground()
117
        {
118
        }
119
120
        protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
121
        {
122
            IngestServer ingestserver = this.mc.getTwitchStream().func_152925_v()[entryID];
123
            String s = ingestserver.serverUrl.replaceAll("\\{stream_key\\}", "");
124
            String s1 = (int)ingestserver.bitrateKbps + " kbps";
125
            String s2 = null;
126
            IngestServerTester ingestservertester = this.mc.getTwitchStream().func_152932_y();
127
128
            if (ingestservertester != null)
129
            {
130
                if (ingestserver == ingestservertester.func_153040_c())
131
                {
132
                    s = EnumChatFormatting.GREEN + s;
133
                    s1 = (int)(ingestservertester.func_153030_h() * 100.0F) + "%";
134
                }
135
                else if (entryID < ingestservertester.func_153028_p())
136
                {
137
                    if (ingestserver.bitrateKbps == 0.0F)
138
                    {
139
                        s1 = EnumChatFormatting.RED + "Down!";
140
                    }
141
                }
142
                else
143
                {
144
                    s1 = EnumChatFormatting.OBFUSCATED + "1234" + EnumChatFormatting.RESET + " kbps";
145
                }
146
            }
147
            else if (ingestserver.bitrateKbps == 0.0F)
148
            {
149
                s1 = EnumChatFormatting.RED + "Down!";
150
            }
151
152
            p_180791_2_ = p_180791_2_ - 15;
153
154
            if (this.isSelected(entryID))
155
            {
156
                s2 = EnumChatFormatting.BLUE + "(Preferred)";
157
            }
158
            else if (ingestserver.defaultServer)
159
            {
160
                s2 = EnumChatFormatting.GREEN + "(Default)";
161
            }
162
163
            GuiIngestServers.this.drawString(GuiIngestServers.this.fontRendererObj, ingestserver.serverName, p_180791_2_ + 2, p_180791_3_ + 5, 16777215);
164
            GuiIngestServers.this.drawString(GuiIngestServers.this.fontRendererObj, s, p_180791_2_ + 2, p_180791_3_ + GuiIngestServers.this.fontRendererObj.FONT_HEIGHT + 5 + 3, 3158064);
165
            GuiIngestServers.this.drawString(GuiIngestServers.this.fontRendererObj, s1, this.getScrollBarX() - 5 - GuiIngestServers.this.fontRendererObj.getStringWidth(s1), p_180791_3_ + 5, 8421504);
166
167
            if (s2 != null)
168
            {
169
                GuiIngestServers.this.drawString(GuiIngestServers.this.fontRendererObj, s2, this.getScrollBarX() - 5 - GuiIngestServers.this.fontRendererObj.getStringWidth(s2), p_180791_3_ + 5 + 3 + GuiIngestServers.this.fontRendererObj.FONT_HEIGHT, 8421504);
170
            }
171
        }
172
173
        protected int getScrollBarX()
174
        {
175
            return super.getScrollBarX() + 15;
176
        }
177
    }
178
}
179

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