From bdc17c6a4d4caaf51506113ee629a3f0a94e135d Mon Sep 17 00:00:00 2001 From: Vasco Lavos Date: Fri, 11 Jul 2014 14:21:47 +0100 Subject: [PATCH] Added a TransientScaledResolution workaround for compatibility with .2 and .10. --- .../InventoryBaublesButtonHandler.java | 4 +- .../helper/TransientScaledResolution.java | 63 +++++++++++++++++++ 2 files changed, 65 insertions(+), 2 deletions(-) create mode 100644 MODSRC/vazkii/botania/client/core/helper/TransientScaledResolution.java diff --git a/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java b/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java index d19acb044..a545ec3fb 100644 --- a/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java +++ b/MODSRC/vazkii/botania/client/core/handler/InventoryBaublesButtonHandler.java @@ -14,7 +14,6 @@ package vazkii.botania.client.core.handler; import java.util.Arrays; import net.minecraft.client.Minecraft; -import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.inventory.GuiContainerCreative; import net.minecraft.client.gui.inventory.GuiInventory; import net.minecraft.client.renderer.RenderHelper; @@ -27,6 +26,7 @@ import net.minecraft.util.StatCollector; import org.lwjgl.input.Mouse; import org.lwjgl.opengl.GL11; +import vazkii.botania.client.core.helper.TransientScaledResolution; import vazkii.botania.client.lib.LibResources; import baubles.client.gui.GuiPlayerExpanded; @@ -41,7 +41,7 @@ public final class InventoryBaublesButtonHandler { boolean creative = mc.currentScreen instanceof GuiContainerCreative; boolean baubles = mc.currentScreen instanceof GuiPlayerExpanded; - ScaledResolution res = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); + TransientScaledResolution res = new TransientScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight); int x = res.getScaledWidth() / 2 - 19; int y = res.getScaledHeight() / 2 - 75; diff --git a/MODSRC/vazkii/botania/client/core/helper/TransientScaledResolution.java b/MODSRC/vazkii/botania/client/core/helper/TransientScaledResolution.java new file mode 100644 index 000000000..329a441c5 --- /dev/null +++ b/MODSRC/vazkii/botania/client/core/helper/TransientScaledResolution.java @@ -0,0 +1,63 @@ +/** + * This class was created by . It's distributed as + * part of the Botania Mod. Get the Source Code in github: + * https://github.com/Vazkii/Botania + * + * Botania is Open Source and distributed under a + * Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License + * (http://creativecommons.org/licenses/by-nc-sa/3.0/deed.en_GB) + * + * File Created @ [Jul 11, 2014, 2:18:35 PM (GMT)] + */ +package vazkii.botania.client.core.helper; + +import net.minecraft.client.settings.GameSettings; +import net.minecraft.util.MathHelper; + +// Copy of ScaledResolution with 1.7.2 and 1.7.10 support. Will drop once 1.7.10 is in full use +public class TransientScaledResolution { + + private int scaledWidth; + private int scaledHeight; + private double scaledWidthD; + private double scaledHeightD; + private int scaleFactor; + + public TransientScaledResolution(GameSettings par1GameSettings, int par2, int par3) { + this.scaledWidth = par2; + this.scaledHeight = par3; + this.scaleFactor = 1; + int k = par1GameSettings.guiScale; + + if (k == 0) + k = 1000; + + while (this.scaleFactor < k && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240) + ++this.scaleFactor; + + this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor; + this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor; + this.scaledWidth = MathHelper.ceiling_double_int(this.scaledWidthD); + this.scaledHeight = MathHelper.ceiling_double_int(this.scaledHeightD); + } + + public int getScaledWidth() { + return this.scaledWidth; + } + + public int getScaledHeight() { + return this.scaledHeight; + } + + public double getScaledWidth_double() { + return this.scaledWidthD; + } + + public double getScaledHeight_double() { + return this.scaledHeightD; + } + + public int getScaleFactor() { + return this.scaleFactor; + } +} \ No newline at end of file