Merge pull request #6409 from deathbeam/unlimit-stretched-mode
Unlimit stretched resizable mode and properly limit scaling factor
This commit is contained in:
@@ -24,7 +24,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.runelite.mixins;
|
package net.runelite.mixins;
|
||||||
|
|
||||||
import com.google.common.primitives.Ints;
|
|
||||||
import java.awt.Container;
|
import java.awt.Container;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
import net.runelite.api.Constants;
|
import net.runelite.api.Constants;
|
||||||
@@ -102,8 +101,6 @@ public abstract class StretchedModeMixin implements RSClient
|
|||||||
@Override
|
@Override
|
||||||
public void setScalingFactor(int factor)
|
public void setScalingFactor(int factor)
|
||||||
{
|
{
|
||||||
factor = Ints.constrainToRange(factor, 0, 100);
|
|
||||||
|
|
||||||
scalingFactor = 1 + (factor / 100D);
|
scalingFactor = 1 + (factor / 100D);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,8 +122,18 @@ public abstract class StretchedModeMixin implements RSClient
|
|||||||
int parentWidth = canvasParent.getWidth();
|
int parentWidth = canvasParent.getWidth();
|
||||||
int parentHeight = canvasParent.getHeight();
|
int parentHeight = canvasParent.getHeight();
|
||||||
|
|
||||||
int newWidth = Math.max(Constants.GAME_FIXED_WIDTH, (int) (parentWidth / scalingFactor));
|
int newWidth = (int) (parentWidth / scalingFactor);
|
||||||
int newHeight = Math.max(Constants.GAME_FIXED_HEIGHT, (int) (parentHeight / 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);
|
cachedRealDimensions = new Dimension(newWidth, newHeight);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user