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