| 1 | package net.minecraft.client.gui;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.client.audio.PositionedSoundRecord;
|
| 5 | import net.minecraft.client.audio.SoundCategory;
|
| 6 | import net.minecraft.client.audio.SoundEventAccessorComposite;
|
| 7 | import net.minecraft.client.audio.SoundHandler;
|
| 8 | import net.minecraft.client.gui.stream.GuiStreamOptions;
|
| 9 | import net.minecraft.client.gui.stream.GuiStreamUnavailable;
|
| 10 | import net.minecraft.client.resources.I18n;
|
| 11 | import net.minecraft.client.settings.GameSettings;
|
| 12 | import net.minecraft.client.stream.IStream;
|
| 13 | import net.minecraft.util.ChatComponentText;
|
| 14 | import net.minecraft.util.ChatComponentTranslation;
|
| 15 | import net.minecraft.util.IChatComponent;
|
| 16 | import net.minecraft.world.EnumDifficulty;
|
| 17 |
|
| 18 | public class GuiOptions extends GuiScreen implements GuiYesNoCallback
|
| 19 | {
|
| 20 | private static final GameSettings.Options[] field_146440_f = new GameSettings.Options[] {GameSettings.Options.FOV};
|
| 21 | private final GuiScreen field_146441_g;
|
| 22 |
|
| 23 | /** Reference to the GameSettings object. */
|
| 24 | private final GameSettings game_settings_1;
|
| 25 | private GuiButton field_175357_i;
|
| 26 | private GuiLockIconButton field_175356_r;
|
| 27 | protected String field_146442_a = "Options";
|
| 28 |
|
| 29 | public GuiOptions(GuiScreen p_i1046_1_, GameSettings p_i1046_2_)
|
| 30 | {
|
| 31 | this.field_146441_g = p_i1046_1_;
|
| 32 | this.game_settings_1 = p_i1046_2_;
|
| 33 | }
|
| 34 |
|
| 35 | /**
|
| 36 | * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
|
| 37 | * window resizes, the buttonList is cleared beforehand.
|
| 38 | */
|
| 39 | public void initGui()
|
| 40 | {
|
| 41 | int i = 0;
|
| 42 | this.field_146442_a = I18n.format("options.title", new Object[0]);
|
| 43 |
|
| 44 | for (GameSettings.Options gamesettings$options : field_146440_f)
|
| 45 | {
|
| 46 | if (gamesettings$options.getEnumFloat())
|
| 47 | {
|
| 48 | this.buttonList.add(new GuiOptionSlider(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), gamesettings$options));
|
| 49 | }
|
| 50 | else
|
| 51 | {
|
| 52 | GuiOptionButton guioptionbutton = new GuiOptionButton(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), gamesettings$options, this.game_settings_1.getKeyBinding(gamesettings$options));
|
| 53 | this.buttonList.add(guioptionbutton);
|
| 54 | }
|
| 55 |
|
| 56 | ++i;
|
| 57 | }
|
| 58 |
|
| 59 | if (this.mc.theWorld != null)
|
| 60 | {
|
| 61 | EnumDifficulty enumdifficulty = this.mc.theWorld.getDifficulty();
|
| 62 | this.field_175357_i = new GuiButton(108, this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), 150, 20, this.func_175355_a(enumdifficulty));
|
| 63 | this.buttonList.add(this.field_175357_i);
|
| 64 |
|
| 65 | if (this.mc.isSingleplayer() && !this.mc.theWorld.getWorldInfo().isHardcoreModeEnabled())
|
| 66 | {
|
| 67 | this.field_175357_i.setWidth(this.field_175357_i.getButtonWidth() - 20);
|
| 68 | this.field_175356_r = new GuiLockIconButton(109, this.field_175357_i.xPosition + this.field_175357_i.getButtonWidth(), this.field_175357_i.yPosition);
|
| 69 | this.buttonList.add(this.field_175356_r);
|
| 70 | this.field_175356_r.func_175229_b(this.mc.theWorld.getWorldInfo().isDifficultyLocked());
|
| 71 | this.field_175356_r.enabled = !this.field_175356_r.func_175230_c();
|
| 72 | this.field_175357_i.enabled = !this.field_175356_r.func_175230_c();
|
| 73 | }
|
| 74 | else
|
| 75 | {
|
| 76 | this.field_175357_i.enabled = false;
|
| 77 | }
|
| 78 | }
|
| 79 | else
|
| 80 | {
|
| 81 | GuiOptionButton guioptionbutton1 = new GuiOptionButton(GameSettings.Options.REALMS_NOTIFICATIONS.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 - 12 + 24 * (i >> 1), GameSettings.Options.REALMS_NOTIFICATIONS, this.game_settings_1.getKeyBinding(GameSettings.Options.REALMS_NOTIFICATIONS));
|
| 82 | this.buttonList.add(guioptionbutton1);
|
| 83 | }
|
| 84 |
|
| 85 | this.buttonList.add(new GuiButton(110, this.width / 2 - 155, this.height / 6 + 48 - 6, 150, 20, I18n.format("options.skinCustomisation", new Object[0])));
|
| 86 | this.buttonList.add(new GuiButton(8675309, this.width / 2 + 5, this.height / 6 + 48 - 6, 150, 20, "Super Secret Settings...")
|
| 87 | {
|
| 88 | public void playPressSound(SoundHandler soundHandlerIn)
|
| 89 | {
|
| 90 | SoundEventAccessorComposite soundeventaccessorcomposite = soundHandlerIn.getRandomSoundFromCategories(new SoundCategory[] {SoundCategory.ANIMALS, SoundCategory.BLOCKS, SoundCategory.MOBS, SoundCategory.PLAYERS, SoundCategory.WEATHER});
|
| 91 |
|
| 92 | if (soundeventaccessorcomposite != null)
|
| 93 | {
|
| 94 | soundHandlerIn.playSound(PositionedSoundRecord.create(soundeventaccessorcomposite.getSoundEventLocation(), 0.5F));
|
| 95 | }
|
| 96 | }
|
| 97 | });
|
| 98 | this.buttonList.add(new GuiButton(106, this.width / 2 - 155, this.height / 6 + 72 - 6, 150, 20, I18n.format("options.sounds", new Object[0])));
|
| 99 | this.buttonList.add(new GuiButton(107, this.width / 2 + 5, this.height / 6 + 72 - 6, 150, 20, I18n.format("options.stream", new Object[0])));
|
| 100 | this.buttonList.add(new GuiButton(101, this.width / 2 - 155, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.video", new Object[0])));
|
| 101 | this.buttonList.add(new GuiButton(100, this.width / 2 + 5, this.height / 6 + 96 - 6, 150, 20, I18n.format("options.controls", new Object[0])));
|
| 102 | this.buttonList.add(new GuiButton(102, this.width / 2 - 155, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.language", new Object[0])));
|
| 103 | this.buttonList.add(new GuiButton(103, this.width / 2 + 5, this.height / 6 + 120 - 6, 150, 20, I18n.format("options.chat.title", new Object[0])));
|
| 104 | this.buttonList.add(new GuiButton(105, this.width / 2 - 155, this.height / 6 + 144 - 6, 150, 20, I18n.format("options.resourcepack", new Object[0])));
|
| 105 | this.buttonList.add(new GuiButton(104, this.width / 2 + 5, this.height / 6 + 144 - 6, 150, 20, I18n.format("options.snooper.view", new Object[0])));
|
| 106 | this.buttonList.add(new GuiButton(200, this.width / 2 - 100, this.height / 6 + 168, I18n.format("gui.done", new Object[0])));
|
| 107 | }
|
| 108 |
|
| 109 | public String func_175355_a(EnumDifficulty p_175355_1_)
|
| 110 | {
|
| 111 | IChatComponent ichatcomponent = new ChatComponentText("");
|
| 112 | ichatcomponent.appendSibling(new ChatComponentTranslation("options.difficulty", new Object[0]));
|
| 113 | ichatcomponent.appendText(": ");
|
| 114 | ichatcomponent.appendSibling(new ChatComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0]));
|
| 115 | return ichatcomponent.getFormattedText();
|
| 116 | }
|
| 117 |
|
| 118 | public void confirmClicked(boolean result, int id)
|
| 119 | {
|
| 120 | this.mc.displayGuiScreen(this);
|
| 121 |
|
| 122 | if (id == 109 && result && this.mc.theWorld != null)
|
| 123 | {
|
| 124 | this.mc.theWorld.getWorldInfo().setDifficultyLocked(true);
|
| 125 | this.field_175356_r.func_175229_b(true);
|
| 126 | this.field_175356_r.enabled = false;
|
| 127 | this.field_175357_i.enabled = false;
|
| 128 | }
|
| 129 | }
|
| 130 |
|
| 131 | /**
|
| 132 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 133 | */
|
| 134 | protected void actionPerformed(GuiButton button) throws IOException
|
| 135 | {
|
| 136 | if (button.enabled)
|
| 137 | {
|
| 138 | if (button.id < 100 && button instanceof GuiOptionButton)
|
| 139 | {
|
| 140 | GameSettings.Options gamesettings$options = ((GuiOptionButton)button).returnEnumOptions();
|
| 141 | this.game_settings_1.setOptionValue(gamesettings$options, 1);
|
| 142 | button.displayString = this.game_settings_1.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
|
| 143 | }
|
| 144 |
|
| 145 | if (button.id == 108)
|
| 146 | {
|
| 147 | this.mc.theWorld.getWorldInfo().setDifficulty(EnumDifficulty.getDifficultyEnum(this.mc.theWorld.getDifficulty().getDifficultyId() + 1));
|
| 148 | this.field_175357_i.displayString = this.func_175355_a(this.mc.theWorld.getDifficulty());
|
| 149 | }
|
| 150 |
|
| 151 | if (button.id == 109)
|
| 152 | {
|
| 153 | this.mc.displayGuiScreen(new GuiYesNo(this, (new ChatComponentTranslation("difficulty.lock.title", new Object[0])).getFormattedText(), (new ChatComponentTranslation("difficulty.lock.question", new Object[] {new ChatComponentTranslation(this.mc.theWorld.getWorldInfo().getDifficulty().getDifficultyResourceKey(), new Object[0])})).getFormattedText(), 109));
|
| 154 | }
|
| 155 |
|
| 156 | if (button.id == 110)
|
| 157 | {
|
| 158 | this.mc.gameSettings.saveOptions();
|
| 159 | this.mc.displayGuiScreen(new GuiCustomizeSkin(this));
|
| 160 | }
|
| 161 |
|
| 162 | if (button.id == 8675309)
|
| 163 | {
|
| 164 | this.mc.entityRenderer.activateNextShader();
|
| 165 | }
|
| 166 |
|
| 167 | if (button.id == 101)
|
| 168 | {
|
| 169 | this.mc.gameSettings.saveOptions();
|
| 170 | this.mc.displayGuiScreen(new GuiVideoSettings(this, this.game_settings_1));
|
| 171 | }
|
| 172 |
|
| 173 | if (button.id == 100)
|
| 174 | {
|
| 175 | this.mc.gameSettings.saveOptions();
|
| 176 | this.mc.displayGuiScreen(new GuiControls(this, this.game_settings_1));
|
| 177 | }
|
| 178 |
|
| 179 | if (button.id == 102)
|
| 180 | {
|
| 181 | this.mc.gameSettings.saveOptions();
|
| 182 | this.mc.displayGuiScreen(new GuiLanguage(this, this.game_settings_1, this.mc.getLanguageManager()));
|
| 183 | }
|
| 184 |
|
| 185 | if (button.id == 103)
|
| 186 | {
|
| 187 | this.mc.gameSettings.saveOptions();
|
| 188 | this.mc.displayGuiScreen(new ScreenChatOptions(this, this.game_settings_1));
|
| 189 | }
|
| 190 |
|
| 191 | if (button.id == 104)
|
| 192 | {
|
| 193 | this.mc.gameSettings.saveOptions();
|
| 194 | this.mc.displayGuiScreen(new GuiSnooper(this, this.game_settings_1));
|
| 195 | }
|
| 196 |
|
| 197 | if (button.id == 200)
|
| 198 | {
|
| 199 | this.mc.gameSettings.saveOptions();
|
| 200 | this.mc.displayGuiScreen(this.field_146441_g);
|
| 201 | }
|
| 202 |
|
| 203 | if (button.id == 105)
|
| 204 | {
|
| 205 | this.mc.gameSettings.saveOptions();
|
| 206 | this.mc.displayGuiScreen(new GuiScreenResourcePacks(this));
|
| 207 | }
|
| 208 |
|
| 209 | if (button.id == 106)
|
| 210 | {
|
| 211 | this.mc.gameSettings.saveOptions();
|
| 212 | this.mc.displayGuiScreen(new GuiScreenOptionsSounds(this, this.game_settings_1));
|
| 213 | }
|
| 214 |
|
| 215 | if (button.id == 107)
|
| 216 | {
|
| 217 | this.mc.gameSettings.saveOptions();
|
| 218 | IStream istream = this.mc.getTwitchStream();
|
| 219 |
|
| 220 | if (istream.func_152936_l() && istream.func_152928_D())
|
| 221 | {
|
| 222 | this.mc.displayGuiScreen(new GuiStreamOptions(this, this.game_settings_1));
|
| 223 | }
|
| 224 | else
|
| 225 | {
|
| 226 | GuiStreamUnavailable.func_152321_a(this);
|
| 227 | }
|
| 228 | }
|
| 229 | }
|
| 230 | }
|
| 231 |
|
| 232 | /**
|
| 233 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 234 | */
|
| 235 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 236 | {
|
| 237 | this.drawDefaultBackground();
|
| 238 | this.drawCenteredString(this.fontRendererObj, this.field_146442_a, this.width / 2, 15, 16777215);
|
| 239 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 240 | }
|
| 241 | }
|
| 242 |
|