Implement auto-updater screen for 1.12.2
This commit is contained in:
@@ -578,7 +578,8 @@ if (isNotCommonProject) {
|
|||||||
new JsonSlurper()
|
new JsonSlurper()
|
||||||
.parse(input)
|
.parse(input)
|
||||||
.each { key, value ->
|
.each { key, value ->
|
||||||
writer.writeLine("${key}=${value.toString().replace("%", "%%").replace("\n", "\\n")}")
|
def text = value.toString().replaceAll(/%(?!((\d+)\$)?s|%)/, "%%").replace("\n", "\\n")
|
||||||
|
writer.writeLine("${key}=${text}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package com.seibel.distanthorizons.cleanroom.mixins.client;
|
||||||
|
|
||||||
|
import com.seibel.distanthorizons.common.commonMixins.DhUpdateScreenBase;
|
||||||
|
import com.seibel.distanthorizons.core.config.Config;
|
||||||
|
import com.seibel.distanthorizons.coreapi.ModInfo;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import org.spongepowered.asm.mixin.Mixin;
|
||||||
|
import org.spongepowered.asm.mixin.injection.At;
|
||||||
|
import org.spongepowered.asm.mixin.injection.Inject;
|
||||||
|
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||||
|
|
||||||
|
@Mixin(Minecraft.class)
|
||||||
|
public class MixinMinecraft
|
||||||
|
{
|
||||||
|
|
||||||
|
@Inject(method = "init", at = @At("TAIL"))
|
||||||
|
private void onInit(CallbackInfo ci)
|
||||||
|
{
|
||||||
|
if(Config.Client.Advanced.AutoUpdater.enableAutoUpdater.get() && !ModInfo.IS_DEV_BUILD) // weird lib class not found error can occur if we don't check if we are in dev
|
||||||
|
{
|
||||||
|
DhUpdateScreenBase.tryShowUpdateScreenAndRunAutoUpdateStartup(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,19 +1,20 @@
|
|||||||
{
|
{
|
||||||
"required": true,
|
"required": true,
|
||||||
"package": "com.seibel.distanthorizons.cleanroom.mixins",
|
"package": "com.seibel.distanthorizons.cleanroom.mixins",
|
||||||
"compatibilityLevel": "JAVA_8",
|
"compatibilityLevel": "JAVA_8",
|
||||||
"target": "@env(DEFAULT)",
|
"target": "@env(DEFAULT)",
|
||||||
"mixins": [
|
"mixins": [
|
||||||
"common.MixinThreadedFileIOBase"
|
"common.MixinThreadedFileIOBase"
|
||||||
],
|
],
|
||||||
"minVersion": "0.8.7",
|
"minVersion": "0.8.7",
|
||||||
"server": [
|
"server": [
|
||||||
"server.MixinEntityPlayerMP"
|
"server.MixinEntityPlayerMP"
|
||||||
],
|
],
|
||||||
"client": [
|
"client": [
|
||||||
"client.MixinEntityRenderer",
|
"client.MixinEntityRenderer",
|
||||||
"client.MixinNetHandlerPlayClient",
|
"client.MixinMinecraft",
|
||||||
"client.MixinOptionsScreen",
|
"client.MixinNetHandlerPlayClient",
|
||||||
"client.MixinRenderGlobal"
|
"client.MixinOptionsScreen",
|
||||||
]
|
"client.MixinRenderGlobal"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
+10
-5
@@ -155,16 +155,21 @@ public class TexturedButtonWidget extends Button
|
|||||||
@Override
|
@Override
|
||||||
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
public void drawButton(Minecraft mc, int mouseX, int mouseY, float partialTicks) {
|
||||||
if (this.visible) {
|
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;
|
this.hovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
|
||||||
int i = this.getHoverState(this.hovered);
|
int i = this.getHoverState(this.hovered);
|
||||||
|
|
||||||
GlStateManager.enableBlend();
|
GlStateManager.enableBlend();
|
||||||
GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
|
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);
|
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);
|
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
this.drawTexturedModalRect(this.x + this.width / 2, this.y, 200 - this.width / 2, 46 + i * 20, this.width / 2, this.height);
|
|
||||||
|
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
|
//Render DH texture
|
||||||
mc.getTextureManager().bindTexture(textureResourceLocation);
|
mc.getTextureManager().bindTexture(textureResourceLocation);
|
||||||
|
|||||||
+1
-1
@@ -1030,7 +1030,7 @@ class DhConfigScreen extends DhScreen
|
|||||||
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
ChangelogScreen changelogScreen = new ChangelogScreen(this);
|
||||||
if (changelogScreen.usable)
|
if (changelogScreen.usable)
|
||||||
{
|
{
|
||||||
Minecraft.getMinecraft().displayGuiScreen(changelogScreen);
|
DhScreenUtil.setScreen(changelogScreen);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -186,7 +186,7 @@ public class ChangelogScreen extends DhScreen
|
|||||||
this.addBtn( // Close
|
this.addBtn( // Close
|
||||||
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
|
MakeBtn(Translatable(ModInfo.ID + ".general.back"), 5, this.height - 25, 100, 20, (btn) -> {
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
Objects.requireNonNull(this.mc).displayGuiScreen(this.parent);
|
DhScreenUtil.setScreen(this.parent);
|
||||||
#else
|
#else
|
||||||
this.onClose();
|
this.onClose();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+21
@@ -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.jar.updater.SelfUpdater;
|
||||||
import com.seibel.distanthorizons.core.logging.DhLogger;
|
import com.seibel.distanthorizons.core.logging.DhLogger;
|
||||||
#if MC_VER <= MC_1_12_2
|
#if MC_VER <= MC_1_12_2
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
import net.minecraft.client.gui.GuiScreen;
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
#else
|
#else
|
||||||
import net.minecraft.client.gui.screens.Screen;
|
import net.minecraft.client.gui.screens.Screen;
|
||||||
@@ -298,4 +299,24 @@ public class UpdateModScreen extends DhScreen
|
|||||||
#endif
|
#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
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user