    001    package net.minecraft.client.gui;
    002
    003    import cpw.mods.fml.common.Side;
    004    import cpw.mods.fml.common.asm.SideOnly;
    005    import net.minecraft.client.settings.GameSettings;
    006    import net.minecraft.util.MathHelper;
    007
    008    @SideOnly(Side.CLIENT)
    009    public class ScaledResolution
    010    {
    011        private int scaledWidth;
    012        private int scaledHeight;
    013        private double scaledWidthD;
    014        private double scaledHeightD;
    015        private int scaleFactor;
    016
    017        public ScaledResolution(GameSettings par1GameSettings, int par2, int par3)
    018        {
    019            this.scaledWidth = par2;
    020            this.scaledHeight = par3;
    021            this.scaleFactor = 1;
    022            int var4 = par1GameSettings.guiScale;
    023
    024            if (var4 == 0)
    025            {
    026                var4 = 1000;
    027            }
    028
    029            while (this.scaleFactor < var4 && this.scaledWidth / (this.scaleFactor + 1) >= 320 && this.scaledHeight / (this.scaleFactor + 1) >= 240)
    030            {
    031                ++this.scaleFactor;
    032            }
    033
    034            this.scaledWidthD = (double)this.scaledWidth / (double)this.scaleFactor;
    035            this.scaledHeightD = (double)this.scaledHeight / (double)this.scaleFactor;
    036            this.scaledWidth = MathHelper.ceiling_double_int(this.scaledWidthD);
    037            this.scaledHeight = MathHelper.ceiling_double_int(this.scaledHeightD);
    038        }
    039
    040        public int getScaledWidth()
    041        {
    042            return this.scaledWidth;
    043        }
    044
    045        public int getScaledHeight()
    046        {
    047            return this.scaledHeight;
    048        }
    049
    050        public double getScaledWidth_double()
    051        {
    052            return this.scaledWidthD;
    053        }
    054
    055        public double getScaledHeight_double()
    056        {
    057            return this.scaledHeightD;
    058        }
    059
    060        public int getScaleFactor()
    061        {
    062            return this.scaleFactor;
    063        }
    064    }