|
1 | 1 | package net.vulkanmod.config.gui; |
2 | 2 |
|
3 | 3 | import com.google.common.collect.Lists; |
| 4 | +import net.minecraft.ChatFormatting; |
4 | 5 | import net.minecraft.Util; |
5 | 6 | import net.minecraft.client.gui.GuiGraphics; |
6 | 7 | import net.minecraft.client.gui.components.events.GuiEventListener; |
|
12 | 13 | import net.minecraft.resources.ResourceLocation; |
13 | 14 | import net.minecraft.util.FormattedCharSequence; |
14 | 15 | import net.vulkanmod.Initializer; |
| 16 | +import net.vulkanmod.config.UpdateChecker; |
15 | 17 | import net.vulkanmod.config.gui.render.GuiRenderer; |
16 | 18 | import net.vulkanmod.config.gui.widget.VAbstractWidget; |
17 | 19 | import net.vulkanmod.config.gui.widget.VButtonWidget; |
|
24 | 26 | import java.util.List; |
25 | 27 |
|
26 | 28 | public class VOptionScreen extends Screen { |
| 29 | + public final static int MARGIN = 20; |
27 | 30 | public final static int RED = ColorUtil.ARGB.pack(0.3f, 0.0f, 0.0f, 0.8f); |
28 | 31 | final ResourceLocation ICON = ResourceLocation.fromNamespaceAndPath("vulkanmod", "vlogo_transparent.png"); |
29 | 32 |
|
@@ -88,15 +91,13 @@ protected void init() { |
88 | 91 | int bottom = 60; |
89 | 92 | int itemHeight = 20; |
90 | 93 |
|
91 | | - int leftMargin = 100; |
92 | | -// int listWidth = (int) (this.width * 0.65f); |
93 | | - int listWidth = Math.min((int) (this.width * 0.65f), 420); |
| 94 | + int leftMargin = MARGIN + 90; |
| 95 | + int listWidth = Math.min(this.width - leftMargin - MARGIN, 420); |
94 | 96 | int listHeight = this.height - top - bottom; |
95 | 97 |
|
96 | 98 | this.buildLists(leftMargin, top, listWidth, listHeight, itemHeight); |
97 | 99 |
|
98 | 100 | int x = leftMargin + listWidth + 10; |
99 | | -// int width = Math.min(this.width - this.tooltipX - 10, 200); |
100 | 101 | int width = this.width - x - 10; |
101 | 102 | int y = 50; |
102 | 103 |
|
@@ -147,8 +148,7 @@ private void buildPage() { |
147 | 148 | this.pageButtons.clear(); |
148 | 149 | this.clearWidgets(); |
149 | 150 |
|
150 | | -// this.addPageButtons(20, 6, 60, 20, false); |
151 | | - this.addPageButtons(10, 40, 80, 22, true); |
| 151 | + this.addPageButtons(MARGIN, 40, 80, 22, true); |
152 | 152 |
|
153 | 153 | VOptionList currentList = this.optionPages.get(this.currentListIdx).getOptionList(); |
154 | 154 | this.addWidget(currentList); |
@@ -197,6 +197,19 @@ private void addButtons() { |
197 | 197 | this.addWidget(this.applyButton); |
198 | 198 | this.addWidget(this.doneButton); |
199 | 199 | this.addWidget(this.supportButton); |
| 200 | + |
| 201 | + if (UpdateChecker.isUpdateAvailable()) { |
| 202 | + buttonWidth = minecraft.font.width(Component.translatable("vulkanmod.options.buttons.update_available")) + 10; |
| 203 | + var updateButton = new VButtonWidget( |
| 204 | + x0 - buttonWidth - buttonMargin, 6, |
| 205 | + buttonWidth, buttonHeight, |
| 206 | + Component.translatable("vulkanmod.options.buttons.update_available").withStyle(ChatFormatting.UNDERLINE), |
| 207 | + button -> Util.getPlatform().openUri("https://modrinth.com/mod/vulkanmod") |
| 208 | + ); |
| 209 | + |
| 210 | + this.buttons.add(updateButton); |
| 211 | + this.addWidget(updateButton); |
| 212 | + } |
200 | 213 | } |
201 | 214 |
|
202 | 215 | @Override |
@@ -235,9 +248,8 @@ public void render(GuiGraphics guiGraphics, int mouseX, int mouseY, float delta) |
235 | 248 | GuiRenderer.guiGraphics = guiGraphics; |
236 | 249 | VRenderSystem.enableBlend(); |
237 | 250 |
|
238 | | - int size = minecraft.font.lineHeight * 4; |
239 | | - |
240 | | - guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ICON, 30, 4, 0f, 0f, size, size, size, size); |
| 251 | + int size = 36; |
| 252 | + guiGraphics.blit(RenderPipelines.GUI_TEXTURED, ICON, MARGIN + 40 - 18, 4, 0f, 0f, size, size, size, size); |
241 | 253 |
|
242 | 254 | VOptionList currentList = this.optionPages.get(this.currentListIdx).getOptionList(); |
243 | 255 | currentList.updateState(mouseX, mouseY); |
|
0 commit comments