Implement auto-updater screen for 1.12.2

This commit is contained in:
Vojtěch Šokala
2026-06-07 23:01:08 +02:00
parent 1d7cb1e6fc
commit 00b47fc776
7 changed files with 77 additions and 25 deletions
@@ -155,16 +155,21 @@ public class TexturedButtonWidget extends Button
@Override
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
if (this.visible) {
//Render vanilla background
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
int i = this.getHoverState(this.hovered);
GlStateManager.enableBlend();
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
GlStateManager.blendFunc(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA);
this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
if (this.renderBackground)
{
//Render vanilla background
mc.getTextureManager().bindTexture(BUTTON_TEXTURES);
this.drawTexturedModalRect(this.x, this.y, 0, 46 + i * 20, this.width / 2, this.height);
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
}
//Render DH texture
mc.getTextureManager().bindTexture(textureResourceLocation);
@@ -1030,7 +1030,7 @@ class DhConfigScreen extends DhScreen
ChangelogScreen changelogScreen = new ChangelogScreen(this);
if (changelogScreen.usable)
{
Minecraft.getMinecraft().displayGuiScreen(changelogScreen);
DhScreenUtil.setScreen(changelogScreen);
}
else
{
@@ -186,7 +186,7 @@ public class ChangelogScreen extends DhScreen
this.addBtn( // Close
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
#if MC_VER <= MC_1_12_2
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
DhScreenUtil.setScreen(this.parent);
#else
this.onClose();
#endif
@@ -11,6 +11,7 @@ import com.seibel.distanthorizons.core.jar.installer.ModrinthGetter;
import com.seibel.distanthorizons.core.jar.updater.SelfUpdater;
import com.seibel.distanthorizons.core.logging.DhLogger;
#if MC_VER <= MC_1_12_2
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen;
#else
import net.minecraft.client.gui.screens.Screen;
@@ -298,4 +299,24 @@ public class UpdateModScreen extends DhScreen
#endif
}
#if MC_VER <= MC_1_12_2
@Override
protected void actionPerformed(GuiButton button)
{
super.actionPerformed(button);
if(button.id == changelogButton_id)
{
ChangelogScreen changelogScreen = new ChangelogScreen(this);
if (changelogScreen.usable)
{
DhScreenUtil.setScreen(changelogScreen);
}
else
{
LOGGER.warn("Changelog was not able to open");
}
}
}
#endif
}