Merge pull request #6315 from devLotto/stretchedmode-reducescalingtime
stretchedmode: reduce wait time after changing scaling percentage
This commit is contained in:
@@ -38,21 +38,39 @@ public abstract class StretchedModeMaxSizeMixin implements RSGameEngine
|
||||
@Shadow("clientInstance")
|
||||
private static RSClient client;
|
||||
|
||||
@Copy("resizeCanvas")
|
||||
abstract void rs$resizeCanvas();
|
||||
|
||||
@Replace("resizeCanvas")
|
||||
public void rl$resizeCanvas()
|
||||
{
|
||||
if (client.isStretchedEnabled())
|
||||
{
|
||||
client.invalidateStretching(false);
|
||||
|
||||
if (client.isResized())
|
||||
{
|
||||
Dimension realDimensions = client.getRealDimensions();
|
||||
|
||||
setMaxCanvasWidth(realDimensions.width);
|
||||
setMaxCanvasHeight(realDimensions.height);
|
||||
}
|
||||
}
|
||||
|
||||
rs$resizeCanvas();
|
||||
}
|
||||
|
||||
@Copy("setMaxCanvasSize")
|
||||
abstract void rs$setMaxCanvasSize(int width, int height);
|
||||
|
||||
@Replace("setMaxCanvasSize")
|
||||
public void setMaxCanvasSize(int width, int height)
|
||||
public void rl$setMaxCanvasSize(int width, int height)
|
||||
{
|
||||
if (client.isStretchedEnabled() && client.isResized())
|
||||
{
|
||||
Dimension realDimensions = client.getRealDimensions();
|
||||
return;
|
||||
}
|
||||
|
||||
rs$setMaxCanvasSize(realDimensions.width, realDimensions.height);
|
||||
}
|
||||
else
|
||||
{
|
||||
rs$setMaxCanvasSize(width, height);
|
||||
}
|
||||
rs$setMaxCanvasSize(width, height);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,24 +197,14 @@ public abstract class StretchedModeMixin implements RSClient
|
||||
@Override
|
||||
public void invalidateStretching(boolean resize)
|
||||
{
|
||||
cachedStretchedDimensions = null;
|
||||
cachedRealDimensions = null;
|
||||
cachedStretchedDimensions = null;
|
||||
|
||||
if (resize && isResized())
|
||||
{
|
||||
/*
|
||||
Tells the game to run resizeCanvas the next frame.
|
||||
|
||||
resizeCanvas in turn calls the method that
|
||||
determines the maximum size of the canvas,
|
||||
AFTER setting the size of the canvas.
|
||||
|
||||
The frame after that, the game sees that
|
||||
the maximum size of the canvas isn't
|
||||
the current size, so it runs resizeCanvas again.
|
||||
This time it uses our new maximum size
|
||||
as the bounds for the canvas size.
|
||||
|
||||
This is useful when resizeCanvas wouldn't usually run,
|
||||
for example when we've only changed the scaling factor
|
||||
and we still want the game's canvas to resize
|
||||
|
||||
Reference in New Issue
Block a user