Merge pull request #6409 from deathbeam/unlimit-stretched-mode

Unlimit stretched resizable mode and properly limit scaling factor
This commit is contained in:
Tomas Slusny
2018-11-11 02:09:24 +01:00
committed by GitHub

View File

@@ -24,7 +24,6 @@
*/
package net.runelite.mixins;
import com.google.common.primitives.Ints;
import java.awt.Container;
import java.awt.Dimension;
import net.runelite.api.Constants;
@@ -102,8 +101,6 @@ public abstract class StretchedModeMixin implements RSClient
@Override
public void setScalingFactor(int factor)
{
factor = Ints.constrainToRange(factor, 0, 100);
scalingFactor = 1 + (factor / 100D);
}
@@ -125,8 +122,18 @@ public abstract class StretchedModeMixin implements RSClient
int parentWidth = canvasParent.getWidth();
int parentHeight = canvasParent.getHeight();
int newWidth = Math.max(Constants.GAME_FIXED_WIDTH, (int) (parentWidth / scalingFactor));
int newHeight = Math.max(Constants.GAME_FIXED_HEIGHT, (int) (parentHeight / scalingFactor));
int newWidth = (int) (parentWidth / scalingFactor);
int newHeight = (int) (parentHeight / scalingFactor);
if (newWidth < Constants.GAME_FIXED_WIDTH || newHeight < Constants.GAME_FIXED_HEIGHT)
{
double scalingFactorW = (double)parentWidth / Constants.GAME_FIXED_WIDTH;
double scalingFactorH = (double)parentHeight / Constants.GAME_FIXED_HEIGHT;
double scalingFactor = Math.min(scalingFactorW, scalingFactorH);
newWidth = (int) (parentWidth / scalingFactor);
newHeight = (int) (parentHeight / scalingFactor);
}
cachedRealDimensions = new Dimension(newWidth, newHeight);
}