GuiLanguage .java

net.minecraft.client.gui.GuiLanguage (class): members: forceUnicodeFontBtn, confirmSettingsBtn, game_settings_3, languageManager, list, List, parentScreen.

net.minecraft.client.guiclass166 linesclientextends GuiScreen6.7 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)
int getContentHeight()
void drawBackground()
void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)

Fields & Constants (6)

parentScreen
list
game_settings_3
languageManager
forceUnicodeFontBtn
confirmSettingsBtn

String literals (3)

"gui.done"
"options.language"
"options.languageWarning"

Full Source

GuiLanguage.java166 lines · MCP 1.8.9 · verbatimOriginal ↗
1
package net.minecraft.client.gui;
2
3
import com.google.common.collect.Lists;
4
import com.google.common.collect.Maps;
5
import java.io.IOException;
6
import java.util.Map;
7
import net.minecraft.client.Minecraft;
8
import net.minecraft.client.resources.I18n;
9
import net.minecraft.client.resources.Language;
10
import net.minecraft.client.resources.LanguageManager;
11
import net.minecraft.client.settings.GameSettings;
12
13
public class GuiLanguage extends GuiScreen
14
{
15
    /** The parent Gui screen */
16
    protected GuiScreen parentScreen;
17
18
    /** The List GuiSlot object reference. */
19
    private GuiLanguage.List list;
20
21
    /** Reference to the GameSettings object. */
22
    private final GameSettings game_settings_3;
23
24
    /** Reference to the LanguageManager object. */
25
    private final LanguageManager languageManager;
26
27
    /**
28
     * A button which allows the user to determine if the Unicode font should be forced.
29
     */
30
    private GuiOptionButton forceUnicodeFontBtn;
31
32
    /** The button to confirm the current settings. */
33
    private GuiOptionButton confirmSettingsBtn;
34
35
    public GuiLanguage(GuiScreen screen, GameSettings gameSettingsObj, LanguageManager manager)
36
    {
37
        this.parentScreen = screen;
38
        this.game_settings_3 = gameSettingsObj;
39
        this.languageManager = manager;
40
    }
41
42
    /**
43
     * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
44
     * window resizes, the buttonList is cleared beforehand.
45
     */
46
    public void initGui()
47
    {
48
        this.buttonList.add(this.forceUnicodeFontBtn = new GuiOptionButton(100, this.width / 2 - 155, this.height - 38, GameSettings.Options.FORCE_UNICODE_FONT, this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT)));
49
        this.buttonList.add(this.confirmSettingsBtn = new GuiOptionButton(6, this.width / 2 - 155 + 160, this.height - 38, I18n.format("gui.done", new Object[0])));
50
        this.list = new GuiLanguage.List(this.mc);
51
        this.list.registerScrollButtons(7, 8);
52
    }
53
54
    /**
55
     * Handles mouse input.
56
     */
57
    public void handleMouseInput() throws IOException
58
    {
59
        super.handleMouseInput();
60
        this.list.handleMouseInput();
61
    }
62
63
    /**
64
     * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
65
     */
66
    protected void actionPerformed(GuiButton button) throws IOException
67
    {
68
        if (button.enabled)
69
        {
70
            switch (button.id)
71
            {
72
                case 5:
73
                    break;
74
75
                case 6:
76
                    this.mc.displayGuiScreen(this.parentScreen);
77
                    break;
78
79
                case 100:
80
                    if (button instanceof GuiOptionButton)
81
                    {
82
                        this.game_settings_3.setOptionValue(((GuiOptionButton)button).returnEnumOptions(), 1);
83
                        button.displayString = this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT);
84
                        ScaledResolution scaledresolution = new ScaledResolution(this.mc);
85
                        int i = scaledresolution.getScaledWidth();
86
                        int j = scaledresolution.getScaledHeight();
87
                        this.setWorldAndResolution(this.mc, i, j);
88
                    }
89
90
                    break;
91
92
                default:
93
                    this.list.actionPerformed(button);
94
            }
95
        }
96
    }
97
98
    /**
99
     * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
100
     */
101
    public void drawScreen(int mouseX, int mouseY, float partialTicks)
102
    {
103
        this.list.drawScreen(mouseX, mouseY, partialTicks);
104
        this.drawCenteredString(this.fontRendererObj, I18n.format("options.language", new Object[0]), this.width / 2, 16, 16777215);
105
        this.drawCenteredString(this.fontRendererObj, "(" + I18n.format("options.languageWarning", new Object[0]) + ")", this.width / 2, this.height - 56, 8421504);
106
        super.drawScreen(mouseX, mouseY, partialTicks);
107
    }
108
109
    class List extends GuiSlot
110
    {
111
        private final java.util.List<String> langCodeList = Lists.<String>newArrayList();
112
        private final Map<String, Language> languageMap = Maps.<String, Language>newHashMap();
113
114
        public List(Minecraft mcIn)
115
        {
116
            super(mcIn, GuiLanguage.this.width, GuiLanguage.this.height, 32, GuiLanguage.this.height - 65 + 4, 18);
117
118
            for (Language language : GuiLanguage.this.languageManager.getLanguages())
119
            {
120
                this.languageMap.put(language.getLanguageCode(), language);
121
                this.langCodeList.add(language.getLanguageCode());
122
            }
123
        }
124
125
        protected int getSize()
126
        {
127
            return this.langCodeList.size();
128
        }
129
130
        protected void elementClicked(int slotIndex, boolean isDoubleClick, int mouseX, int mouseY)
131
        {
132
            Language language = (Language)this.languageMap.get(this.langCodeList.get(slotIndex));
133
            GuiLanguage.this.languageManager.setCurrentLanguage(language);
134
            GuiLanguage.this.game_settings_3.language = language.getLanguageCode();
135
            this.mc.refreshResources();
136
            GuiLanguage.this.fontRendererObj.setUnicodeFlag(GuiLanguage.this.languageManager.isCurrentLocaleUnicode() || GuiLanguage.this.game_settings_3.forceUnicodeFont);
137
            GuiLanguage.this.fontRendererObj.setBidiFlag(GuiLanguage.this.languageManager.isCurrentLanguageBidirectional());
138
            GuiLanguage.this.confirmSettingsBtn.displayString = I18n.format("gui.done", new Object[0]);
139
            GuiLanguage.this.forceUnicodeFontBtn.displayString = GuiLanguage.this.game_settings_3.getKeyBinding(GameSettings.Options.FORCE_UNICODE_FONT);
140
            GuiLanguage.this.game_settings_3.saveOptions();
141
        }
142
143
        protected boolean isSelected(int slotIndex)
144
        {
145
            return ((String)this.langCodeList.get(slotIndex)).equals(GuiLanguage.this.languageManager.getCurrentLanguage().getLanguageCode());
146
        }
147
148
        protected int getContentHeight()
149
        {
150
            return this.getSize() * 18;
151
        }
152
153
        protected void drawBackground()
154
        {
155
            GuiLanguage.this.drawDefaultBackground();
156
        }
157
158
        protected void drawSlot(int entryID, int p_180791_2_, int p_180791_3_, int p_180791_4_, int mouseXIn, int mouseYIn)
159
        {
160
            GuiLanguage.this.fontRendererObj.setBidiFlag(true);
161
            GuiLanguage.this.drawCenteredString(GuiLanguage.this.fontRendererObj, ((Language)this.languageMap.get(this.langCodeList.get(entryID))).toString(), this.width / 2, p_180791_3_ + 1, 16777215);
162
            GuiLanguage.this.fontRendererObj.setBidiFlag(GuiLanguage.this.languageManager.getCurrentLanguage().isBidirectional());
163
        }
164
    }
165
}
166

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