Added a TransientScaledResolution workaround for compatibility with .2 and .10.

This commit is contained in:
Vasco Lavos committed 2014-07-11 14:21:47 +01:00
1 parent 78beeac1cd
commit bdc17c6a4d
2 files changed
+65 -2

No files matched your search

@@ -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;
@@ -0,0 +1,63 @@
/**
* This class was created by <Vazkii>. 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;
}
}