| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.client.resources.I18n;
|
| 5 | import net.minecraft.client.settings.GameSettings;
|
| 6 |
|
| 7 | public class ScreenChatOptions extends GuiScreen
|
| 8 | {
|
| 9 | private static final GameSettings.Options[] field_146399_a = new GameSettings.Options[] {GameSettings.Options.CHAT_VISIBILITY, GameSettings.Options.CHAT_COLOR, GameSettings.Options.CHAT_LINKS, GameSettings.Options.CHAT_OPACITY, GameSettings.Options.CHAT_LINKS_PROMPT, GameSettings.Options.CHAT_SCALE, GameSettings.Options.CHAT_HEIGHT_FOCUSED, GameSettings.Options.CHAT_HEIGHT_UNFOCUSED, GameSettings.Options.CHAT_WIDTH, GameSettings.Options.REDUCED_DEBUG_INFO};
|
| 10 | private final GuiScreen parentScreen;
|
| 11 | private final GameSettings game_settings;
|
| 12 | private String field_146401_i;
|
| 13 |
|
| 14 | public ScreenChatOptions(GuiScreen parentScreenIn, GameSettings gameSettingsIn)
|
| 15 | {
|
| 16 | this.parentScreen = parentScreenIn;
|
| 17 | this.game_settings = gameSettingsIn;
|
| 18 | }
|
| 19 |
|
| 20 | /**
|
| 21 | * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
| 22 | * window resizes, the buttonList is cleared beforehand.
|
| 23 | */
|
| 24 | public void initGui()
|
| 25 | {
|
| 26 | int i = 0;
|
| 27 | this.field_146401_i = I18n.format("options.chat.title", new Object[0]);
|
| 28 |
|
| 29 | for (GameSettings.Options gamesettings$options : field_146399_a)
|
| 30 | {
|
| 31 | if (gamesettings$options.getEnumFloat())
|
| 32 | {
|
| 33 | this.buttonList.add(new GuiOptionSlider(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options));
|
| 34 | }
|
| 35 | else
|
| 36 | {
|
| 37 | this.buttonList.add(new GuiOptionButton(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options, this.game_settings.getKeyBinding(gamesettings$options)));
|
| 38 | }
|
| 39 |
|
| 40 | ++i;
|
| 41 | }
|
| 42 |
|
| 43 | this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 120, I18n.format("gui.done", new Object[0])));
|
| 44 | }
|
| 45 |
|
| 46 | /**
|
| 47 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 48 | */
|
| 49 | protected void actionPerformed(GuiButton button) throws IOException
|
| 50 | {
|
| 51 | if (button.enabled)
|
| 52 | {
|
| 53 | if (button.id < 100 && button instanceof GuiOptionButton)
|
| 54 | {
|
| 55 | this.game_settings.setOptionValue(((GuiOptionButton)button).returnEnumOptions(), 1);
|
| 56 | button.displayString = this.game_settings.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
|
| 57 | }
|
| 58 |
|
| 59 | if (button.id == 200)
|
| 60 | {
|
| 61 | this.mc.gameSettings.saveOptions();
|
| 62 | this.mc.displayGuiScreen(this.parentScreen);
|
| 63 | }
|
| 64 | }
|
| 65 | }
|
| 66 |
|
| 67 | /**
|
| 68 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 69 | */
|
| 70 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 71 | {
|
| 72 | this.drawDefaultBackground();
|
| 73 | this.drawCenteredString(this.fontRendererObj, this.field_146401_i, this.width / 2, 20, 16777215);
|
| 74 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 75 | }
|
| 76 | }
|
| 77 |
|