|
| 1 | +package net.shadowfacts.discordchat.client; |
| 2 | + |
| 3 | +import net.minecraft.client.Minecraft; |
| 4 | +import net.minecraft.client.gui.GuiMainMenu; |
| 5 | +import net.minecraft.client.gui.GuiScreen; |
| 6 | +import net.minecraft.client.renderer.GlStateManager; |
| 7 | +import net.shadowfacts.discordchat.DCConfig; |
| 8 | +import net.shadowfacts.discordchat.DCPrivateProps; |
| 9 | +import net.shadowfacts.shadowlib.util.DesktopUtils; |
| 10 | +import net.shadowfacts.shadowmc.gui.component.GUIComponentText; |
| 11 | +import net.shadowfacts.shadowmc.gui.component.button.GUIButtonText; |
| 12 | +import net.shadowfacts.shadowmc.gui.mcwrapper.GuiScreenWrapper; |
| 13 | +import net.shadowfacts.shadowmc.gui.mcwrapper.MCBaseGUI; |
| 14 | +import net.shadowfacts.shadowmc.util.MouseButton; |
| 15 | +import net.shadowfacts.shadowmc.util.StringHelper; |
| 16 | + |
| 17 | +import java.net.URISyntaxException; |
| 18 | + |
| 19 | +/** |
| 20 | + * @author shadowfacts |
| 21 | + */ |
| 22 | +public class GUISetup extends MCBaseGUI { |
| 23 | + |
| 24 | + public GUISetup(GuiScreenWrapper wrapper) { |
| 25 | + super(wrapper); |
| 26 | + |
| 27 | + String line1 = StringHelper.localize("dc.gui.setup.line1"); |
| 28 | + String line2 = StringHelper.localize("dc.gui.setup.line2"); |
| 29 | + |
| 30 | + addChild(new GUIComponentText(-(mc.fontRendererObj.getStringWidth(line1) / 2), 10, line1)); |
| 31 | + addChild(new GUIComponentText(-(mc.fontRendererObj.getStringWidth(line2) / 2), mc.fontRendererObj.FONT_HEIGHT + 14, line2)); |
| 32 | + |
| 33 | + addChild(new GUIButtonText(-100, 40, 200, 20, this::handleInstructions, StringHelper.localize("dc.gui.setup.instructions"))); |
| 34 | + addChild(new GUIButtonText(-100, 70, 200, 20, this::handleFinished, StringHelper.localize("dc.gui.setup.finished"))); |
| 35 | + addChild(new GUIButtonText(-100, 100, 200, 20, this::handleSkip, StringHelper.localize("dc.gui.setup.skip"))); |
| 36 | + } |
| 37 | + |
| 38 | + @Override |
| 39 | + public void setInitialized(boolean initialized) { |
| 40 | + super.setInitialized(initialized); |
| 41 | + updatePosition(width / 2, y); |
| 42 | + } |
| 43 | + |
| 44 | + private boolean handleInstructions(GUIButtonText button, MouseButton mouseButton) { |
| 45 | + try { |
| 46 | + DesktopUtils.openWebpage("https://git.io/vrGte"); |
| 47 | + } catch (URISyntaxException ignored) {} |
| 48 | + return true; |
| 49 | + } |
| 50 | + |
| 51 | + private boolean handleFinished(GUIButtonText button, MouseButton mouseButton) { |
| 52 | + DCPrivateProps.setup = true; |
| 53 | + DCPrivateProps.save(); |
| 54 | + DCConfig.load(); |
| 55 | + Minecraft.getMinecraft().displayGuiScreen(new GuiMainMenu()); |
| 56 | + return true; |
| 57 | + } |
| 58 | + |
| 59 | + private boolean handleSkip(GUIButtonText button, MouseButton mouseButton) { |
| 60 | + DCPrivateProps.setup = true; |
| 61 | + DCPrivateProps.save(); |
| 62 | + Minecraft.getMinecraft().displayGuiScreen(new GuiMainMenu()); |
| 63 | + return true; |
| 64 | + } |
| 65 | + |
| 66 | + @Override |
| 67 | + public void draw(int mouseX, int mouseY, float partialTicks) { |
| 68 | + // because something else disables GL_TEXTURE_2D without using the GlStateManager |
| 69 | + GlStateManager.disableTexture2D(); |
| 70 | + GlStateManager.enableTexture2D(); |
| 71 | + |
| 72 | + super.draw(mouseX, mouseY, partialTicks); |
| 73 | + } |
| 74 | + |
| 75 | + public static GuiScreen create() { |
| 76 | + GuiScreenWrapper wrapper = new GuiScreenWrapper(); |
| 77 | + GUISetup gui = new GUISetup(wrapper); |
| 78 | + gui.setZLevel(0); |
| 79 | + wrapper.gui = gui; |
| 80 | + return wrapper; |
| 81 | + } |
| 82 | + |
| 83 | +} |
0 commit comments