| 1 | package net.minecraft.client.gui.stream;
|
| 2 |
|
| 3 | import java.io.IOException;
|
| 4 | import net.minecraft.client.gui.GuiButton;
|
| 5 | import net.minecraft.client.gui.GuiOptionButton;
|
| 6 | import net.minecraft.client.gui.GuiOptionSlider;
|
| 7 | import net.minecraft.client.gui.GuiScreen;
|
| 8 | import net.minecraft.client.resources.I18n;
|
| 9 | import net.minecraft.client.settings.GameSettings;
|
| 10 | import net.minecraft.util.EnumChatFormatting;
|
| 11 |
|
| 12 | public class GuiStreamOptions extends GuiScreen
|
| 13 | {
|
| 14 | private static final GameSettings.Options[] field_152312_a = new GameSettings.Options[] {GameSettings.Options.STREAM_BYTES_PER_PIXEL, GameSettings.Options.STREAM_FPS, GameSettings.Options.STREAM_KBPS, GameSettings.Options.STREAM_SEND_METADATA, GameSettings.Options.STREAM_VOLUME_MIC, GameSettings.Options.STREAM_VOLUME_SYSTEM, GameSettings.Options.STREAM_MIC_TOGGLE_BEHAVIOR, GameSettings.Options.STREAM_COMPRESSION};
|
| 15 | private static final GameSettings.Options[] field_152316_f = new GameSettings.Options[] {GameSettings.Options.STREAM_CHAT_ENABLED, GameSettings.Options.STREAM_CHAT_USER_FILTER};
|
| 16 | private final GuiScreen parentScreen;
|
| 17 | private final GameSettings field_152318_h;
|
| 18 | private String field_152319_i;
|
| 19 | private String field_152313_r;
|
| 20 | private int field_152314_s;
|
| 21 | private boolean field_152315_t = false;
|
| 22 |
|
| 23 | public GuiStreamOptions(GuiScreen parentScreenIn, GameSettings p_i1073_2_)
|
| 24 | {
|
| 25 | this.parentScreen = parentScreenIn;
|
| 26 | this.field_152318_h = p_i1073_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 | int i = 0;
|
| 36 | this.field_152319_i = I18n.format("options.stream.title", new Object[0]);
|
| 37 | this.field_152313_r = I18n.format("options.stream.chat.title", new Object[0]);
|
| 38 |
|
| 39 | for (GameSettings.Options gamesettings$options : field_152312_a)
|
| 40 | {
|
| 41 | if (gamesettings$options.getEnumFloat())
|
| 42 | {
|
| 43 | this.buttonList.add(new GuiOptionSlider(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options));
|
| 44 | }
|
| 45 | else
|
| 46 | {
|
| 47 | this.buttonList.add(new GuiOptionButton(gamesettings$options.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options, this.field_152318_h.getKeyBinding(gamesettings$options)));
|
| 48 | }
|
| 49 |
|
| 50 | ++i;
|
| 51 | }
|
| 52 |
|
| 53 | if (i % 2 == 1)
|
| 54 | {
|
| 55 | ++i;
|
| 56 | }
|
| 57 |
|
| 58 | this.field_152314_s = this.height / 6 + 24 * (i >> 1) + 6;
|
| 59 | i = i + 2;
|
| 60 |
|
| 61 | for (GameSettings.Options gamesettings$options1 : field_152316_f)
|
| 62 | {
|
| 63 | if (gamesettings$options1.getEnumFloat())
|
| 64 | {
|
| 65 | this.buttonList.add(new GuiOptionSlider(gamesettings$options1.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options1));
|
| 66 | }
|
| 67 | else
|
| 68 | {
|
| 69 | this.buttonList.add(new GuiOptionButton(gamesettings$options1.returnEnumOrdinal(), this.width / 2 - 155 + i % 2 * 160, this.height / 6 + 24 * (i >> 1), gamesettings$options1, this.field_152318_h.getKeyBinding(gamesettings$options1)));
|
| 70 | }
|
| 71 |
|
| 72 | ++i;
|
| 73 | }
|
| 74 |
|
| 75 | this.buttonList.add(new GuiButton(200, this.width / 2 - 155, this.height / 6 + 168, 150, 20, I18n.format("gui.done", new Object[0])));
|
| 76 | GuiButton guibutton = new GuiButton(201, this.width / 2 + 5, this.height / 6 + 168, 150, 20, I18n.format("options.stream.ingestSelection", new Object[0]));
|
| 77 | guibutton.enabled = this.mc.getTwitchStream().isReadyToBroadcast() && this.mc.getTwitchStream().func_152925_v().length > 0 || this.mc.getTwitchStream().func_152908_z();
|
| 78 | this.buttonList.add(guibutton);
|
| 79 | }
|
| 80 |
|
| 81 | /**
|
| 82 | * Called by the controls from the buttonList when activated. (Mouse pressed for buttons)
|
| 83 | */
|
| 84 | protected void actionPerformed(GuiButton button) throws IOException
|
| 85 | {
|
| 86 | if (button.enabled)
|
| 87 | {
|
| 88 | if (button.id < 100 && button instanceof GuiOptionButton)
|
| 89 | {
|
| 90 | GameSettings.Options gamesettings$options = ((GuiOptionButton)button).returnEnumOptions();
|
| 91 | this.field_152318_h.setOptionValue(gamesettings$options, 1);
|
| 92 | button.displayString = this.field_152318_h.getKeyBinding(GameSettings.Options.getEnumOptions(button.id));
|
| 93 |
|
| 94 | if (this.mc.getTwitchStream().isBroadcasting() && gamesettings$options != GameSettings.Options.STREAM_CHAT_ENABLED && gamesettings$options != GameSettings.Options.STREAM_CHAT_USER_FILTER)
|
| 95 | {
|
| 96 | this.field_152315_t = true;
|
| 97 | }
|
| 98 | }
|
| 99 | else if (button instanceof GuiOptionSlider)
|
| 100 | {
|
| 101 | if (button.id == GameSettings.Options.STREAM_VOLUME_MIC.returnEnumOrdinal())
|
| 102 | {
|
| 103 | this.mc.getTwitchStream().updateStreamVolume();
|
| 104 | }
|
| 105 | else if (button.id == GameSettings.Options.STREAM_VOLUME_SYSTEM.returnEnumOrdinal())
|
| 106 | {
|
| 107 | this.mc.getTwitchStream().updateStreamVolume();
|
| 108 | }
|
| 109 | else if (this.mc.getTwitchStream().isBroadcasting())
|
| 110 | {
|
| 111 | this.field_152315_t = true;
|
| 112 | }
|
| 113 | }
|
| 114 |
|
| 115 | if (button.id == 200)
|
| 116 | {
|
| 117 | this.mc.gameSettings.saveOptions();
|
| 118 | this.mc.displayGuiScreen(this.parentScreen);
|
| 119 | }
|
| 120 | else if (button.id == 201)
|
| 121 | {
|
| 122 | this.mc.gameSettings.saveOptions();
|
| 123 | this.mc.displayGuiScreen(new GuiIngestServers(this));
|
| 124 | }
|
| 125 | }
|
| 126 | }
|
| 127 |
|
| 128 | /**
|
| 129 | * Draws the screen and all the components in it. Args : mouseX, mouseY, renderPartialTicks
|
| 130 | */
|
| 131 | public void drawScreen(int mouseX, int mouseY, float partialTicks)
|
| 132 | {
|
| 133 | this.drawDefaultBackground();
|
| 134 | this.drawCenteredString(this.fontRendererObj, this.field_152319_i, this.width / 2, 20, 16777215);
|
| 135 | this.drawCenteredString(this.fontRendererObj, this.field_152313_r, this.width / 2, this.field_152314_s, 16777215);
|
| 136 |
|
| 137 | if (this.field_152315_t)
|
| 138 | {
|
| 139 | this.drawCenteredString(this.fontRendererObj, EnumChatFormatting.RED + I18n.format("options.stream.changes", new Object[0]), this.width / 2, 20 + this.fontRendererObj.FONT_HEIGHT, 16777215);
|
| 140 | }
|
| 141 |
|
| 142 | super.drawScreen(mouseX, mouseY, partialTicks);
|
| 143 | }
|
| 144 | }
|
| 145 |
|