GuiYesNo .java

net.minecraft.client.gui.GuiYesNo (class): members: parentButtonClickedId, confirmButtonText, cancelButtonText, ticksUntilEnable, field_175298_s, initGui.

net.minecraft.client.guiclass113 linesclientextends GuiScreen3.7 KB

API Surface (5)

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

Fields & Constants (8)

parentScreen
messageLine1
messageLine2
field_175298_s
confirmButtonText
cancelButtonText
parentButtonClickedId
ticksUntilEnable

String literals (2)

"gui.yes"
"gui.no"

Code Graph: Dependencies (5)

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

Full Source

GuiYesNo.java113 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.List;
6
import net.minecraft.client.resources.I18n;
7
8
public class GuiYesNo extends GuiScreen
9
{
10
    /**
11
     * A reference to the screen object that created this. Used for navigating between screens.
12
     */
13
    protected GuiYesNoCallback parentScreen;
14
    protected String messageLine1;
15
    private String messageLine2;
16
    private final List<String> field_175298_s = Lists.<String>newArrayList();
17
18
    /** The text shown for the first button in GuiYesNo */
19
    protected String confirmButtonText;
20
21
    /** The text shown for the second button in GuiYesNo */
22
    protected String cancelButtonText;
23
    protected int parentButtonClickedId;
24
    private int ticksUntilEnable;
25
26
    public GuiYesNo(GuiYesNoCallback p_i1082_1_, String p_i1082_2_, String p_i1082_3_, int p_i1082_4_)
27
    {
28
        this.parentScreen = p_i1082_1_;
29
        this.messageLine1 = p_i1082_2_;
30
        this.messageLine2 = p_i1082_3_;
31
        this.parentButtonClickedId = p_i1082_4_;
32
        this.confirmButtonText = I18n.format("gui.yes", new Object[0]);
33
        this.cancelButtonText = I18n.format("gui.no", new Object[0]);
34
    }
35
36
    public GuiYesNo(GuiYesNoCallback p_i1083_1_, String p_i1083_2_, String p_i1083_3_, String p_i1083_4_, String p_i1083_5_, int p_i1083_6_)
37
    {
38
        this.parentScreen = p_i1083_1_;
39
        this.messageLine1 = p_i1083_2_;
40
        this.messageLine2 = p_i1083_3_;
41
        this.confirmButtonText = p_i1083_4_;
42
        this.cancelButtonText = p_i1083_5_;
43
        this.parentButtonClickedId = p_i1083_6_;
44
    }
45
46
    /**
47
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
48
     * window resizes, the buttonList is cleared beforehand.
49
     */
50
    public void initGui()
51
    {
52
        this.buttonList.add(new GuiOptionButton(0, this.width / 2 - 155, this.height / 6 + 96, this.confirmButtonText));
53
        this.buttonList.add(new GuiOptionButton(1, this.width / 2 - 155 + 160, this.height / 6 + 96, this.cancelButtonText));
54
        this.field_175298_s.clear();
55
        this.field_175298_s.addAll(this.fontRendererObj.listFormattedStringToWidth(this.messageLine2, this.width - 50));
56
    }
57
58
    /**
59
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
60
     */
61
    protected void actionPerformed(GuiButton button) throws IOException
62
    {
63
        this.parentScreen.confirmClicked(button.id == 0, this.parentButtonClickedId);
64
    }
65
66
    /**
67
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
68
     */
69
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
70
    {
71
        this.drawDefaultBackground();
72
        this.drawCenteredString(this.fontRendererObj, this.messageLine1, this.width / 2, 70, 16777215);
73
        int i = 90;
74
75
        for (String s : this.field_175298_s)
76
        {
77
            this.drawCenteredString(this.fontRendererObj, s, this.width / 2, i, 16777215);
78
            i += this.fontRendererObj.FONT_HEIGHT;
79
        }
80
81
        super.drawScreen(mouseX, mouseY, partialTicks);
82
    }
83
84
    /**
85
     * Sets the number of ticks to wait before enabling the buttons.
86
     */
87
    public void setButtonDelay(int p_146350_1_)
88
    {
89
        this.ticksUntilEnable = p_146350_1_;
90
91
        for (GuiButton guibutton : this.buttonList)
92
        {
93
            guibutton.enabled = false;
94
        }
95
    }
96
97
    /**
98
     * Called from the main game loop to update the screen.
99
     */
100
    public void updateScreen()
101
    {
102
        super.updateScreen();
103
104
        if (--this.ticksUntilEnable == 0)
105
        {
106
            for (GuiButton guibutton : this.buttonList)
107
            {
108
                guibutton.enabled = true;
109
            }
110
        }
111
    }
112
}
113

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