Merge pull request #6315 from devLotto/stretchedmode-reducescalingtime
stretchedmode: reduce wait time after changing scaling percentage
This commit is contained in:
@@ -29,7 +29,6 @@ import com.google.common.eventbus.Subscribe;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.events.CanvasSizeChanged;
|
||||
import net.runelite.api.events.ConfigChanged;
|
||||
import net.runelite.api.events.ResizeableChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@@ -92,12 +91,6 @@ public class StretchedModePlugin extends Plugin
|
||||
client.invalidateStretching(true);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onCanvasSizeChanged(CanvasSizeChanged event)
|
||||
{
|
||||
client.invalidateStretching(false);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onConfigChanged(ConfigChanged event)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -51,4 +51,10 @@ public interface RSGameEngine extends GameEngine
|
||||
|
||||
@Import("replaceCanvasNextFrame")
|
||||
void setReplaceCanvasNextFrame(boolean replace);
|
||||
|
||||
@Import("maxCanvasWidth")
|
||||
void setMaxCanvasWidth(int width);
|
||||
|
||||
@Import("maxCanvasHeight")
|
||||
void setMaxCanvasHeight(int height);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user