GuiSnooper .java

net.minecraft.client.gui.GuiSnooper (class, 156 lines): members: game_settings_2, field_146604_g, field_146605_t, field_146606_s, field_146607_r, List.

net.minecraft.client.guiclass156 linesclientextends GuiScreen5.6 KB

API Surface (10)

void initGui()
void handleMouseInput()
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 (8)

field_146608_a
game_settings_2
field_146604_g
field_146609_h
field_146610_i
field_146607_r
field_146606_s
field_146605_t

String literals (3)

"options.snooper.title"
"options.snooper.desc"
"gui.done"

Code Graph: Dependencies (7)

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

Full Source

GuiSnooper.java156 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import com.google.common.collect.Lists;
4
import java.io.IOException;
5
import java.util.TreeMap;
6
import java.util.Map.Entry;
7
import net.minecraft.client.resources.I18n;
8
import net.minecraft.client.settings.GameSettings;
9
10
public class GuiSnooper extends GuiScreen
11
{
12
    private final GuiScreen field_146608_a;
13
14
    /** Reference to the GameSettings object. */
15
    private final GameSettings game_settings_2;
16
    private final java.util.List<String> field_146604_g = Lists.<String>newArrayList();
17
    private final java.util.List<String> field_146609_h = Lists.<String>newArrayList();
18
    private String field_146610_i;
19
    private String[] field_146607_r;
20
    private GuiSnooper.List field_146606_s;
21
    private GuiButton field_146605_t;
22
23
    public GuiSnooper(GuiScreen p_i1061_1_, GameSettings p_i1061_2_)
24
    {
25
        this.field_146608_a = p_i1061_1_;
26
        this.game_settings_2 = p_i1061_2_;
27
    }
28
29
    /**
30
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
31
     * window resizes, the buttonList is cleared beforehand.
32
     */
33
    public void initGui()
34
    {
35
        this.field_146610_i = I18n.format("options.snooper.title", new Object[0]);
36
        String s = I18n.format("options.snooper.desc", new Object[0]);
37
        java.util.List<String> list = Lists.<String>newArrayList();
38
39
        for (String s1 : this.fontRendererObj.listFormattedStringToWidth(s, this.width - 30))
40
        {
41
            list.add(s1);
42
        }
43
44
        this.field_146607_r = (String[])list.toArray(new String[list.size()]);
45
        this.field_146604_g.clear();
46
        this.field_146609_h.clear();
47
        this.buttonList.add(this.field_146605_t = new GuiButton(1, this.width / 2 - 152, this.height - 30, 150, 20, this.game_settings_2.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED)));
48
        this.buttonList.add(new GuiButton(2, this.width / 2 + 2, this.height - 30, 150, 20, I18n.format("gui.done", new Object[0])));
49
        boolean flag = this.mc.getIntegratedServer() != null && this.mc.getIntegratedServer().getPlayerUsageSnooper() != null;
50
51
        for (Entry<String, String> entry : (new TreeMap<String, String>(this.mc.getPlayerUsageSnooper().getCurrentStats())).entrySet())
52
        {
53
            this.field_146604_g.add((flag ? "C " : "") + (String)entry.getKey());
54
            this.field_146609_h.add(this.fontRendererObj.trimStringToWidth((String)entry.getValue(), this.width - 220));
55
        }
56
57
        if (flag)
58
        {
59
            for (Entry<String, String> entry1 : (new TreeMap<String, String>(this.mc.getIntegratedServer().getPlayerUsageSnooper().getCurrentStats())).entrySet())
60
            {
61
                this.field_146604_g.add("S " + (String)entry1.getKey());
62
                this.field_146609_h.add(this.fontRendererObj.trimStringToWidth((String)entry1.getValue(), this.width - 220));
63
            }
64
        }
65
66
        this.field_146606_s = new GuiSnooper.List();
67
    }
68
69
    /**
70
     * Handles mouse input.
71
     */
72
    public void handleMouseInput() throws IOException
73
    {
74
        super.handleMouseInput();
75
        this.field_146606_s.handleMouseInput();
76
    }
77
78
    /**
79
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
80
     */
81
    protected void actionPerformed(GuiButton button) throws IOException
82
    {
83
        if (button.enabled)
84
        {
85
            if (button.id == 2)
86
            {
87
                this.game_settings_2.saveOptions();
88
                this.game_settings_2.saveOptions();
89
                this.mc.displayGuiScreen(this.field_146608_a);
90
            }
91
92
            if (button.id == 1)
93
            {
94
                this.game_settings_2.setOptionValue(GameSettings.Options.SNOOPER_ENABLED, 1);
95
                this.field_146605_t.displayString = this.game_settings_2.getKeyBinding(GameSettings.Options.SNOOPER_ENABLED);
96
            }
97
        }
98
    }
99
100
    /**
101
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
102
     */
103
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
104
    {
105
        this.drawDefaultBackground();
106
        this.field_146606_s.drawScreen(mouseX, mouseY, partialTicks);
107
        this.drawCenteredString(this.fontRendererObj, this.field_146610_i, this.width / 2, 8, 16777215);
108
        int i = 22;
109
110
        for (String s : this.field_146607_r)
111
        {
112
            this.drawCenteredString(this.fontRendererObj, s, this.width / 2, i, 8421504);
113
            i += this.fontRendererObj.FONT_HEIGHT;
114
        }
115
116
        super.drawScreen(mouseX, mouseY, partialTicks);
117
    }
118
119
    class List extends GuiSlot
120
    {
121
        public List()
122
        {
123
            super(GuiSnooper.this.mc, GuiSnooper.this.width, GuiSnooper.this.height, 80, GuiSnooper.this.height - 40, GuiSnooper.this.fontRendererObj.FONT_HEIGHT + 1);
124
        }
125
126
        protected int getSize()
127
        {
128
            return GuiSnooper.this.field_146604_g.size();
129
        }
130
131
        protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
132
        {
133
        }
134
135
        protected boolean isSelected(int slotIndex)
136
        {
137
            return false;
138
        }
139
140
        protected void drawBackground()
141
        {
142
        }
143
144
        protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
145
        {
146
            GuiSnooper.this.fontRendererObj.drawString((String)GuiSnooper.this.field_146604_g.get(entryID), 10, p_180791_3_, 16777215);
147
            GuiSnooper.this.fontRendererObj.drawString((String)GuiSnooper.this.field_146609_h.get(entryID), 230, p_180791_3_, 16777215);
148
        }
149
150
        protected int getScrollBarX()
151
        {
152
            return this.width - 10;
153
        }
154
    }
155
}
156

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