From 215f46e48342b76fb1c7bb5d84ccbfd814f9666e Mon Sep 17 00:00:00 2001 From: Lotto Date: Sat, 19 May 2018 18:21:10 +0200 Subject: [PATCH 1/3] fpsindicator: fix overlay disappearing when using stretched fixed mode --- .../main/java/net/runelite/client/plugins/fps/FpsOverlay.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java index 0d26a3aef3..55c0a176e1 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java @@ -111,7 +111,7 @@ public class FpsOverlay extends Overlay final int fps = client.getFPS(); if (fps < FPS_SIZE) { - final int width = client.getCanvas().getWidth(); + final int width = (int) client.getRealDimensions().getWidth(); final Point point = new Point(width - VALUE_X_OFFSET - graphics.getFontMetrics().stringWidth(FPS_STRING), Y_OFFSET); OverlayUtil.renderTextLocation(graphics, point, fpsNums[fps] + FPS_STRING, getFpsValueColor()); } From 530d253b3780c2f23f80d06530f06bca5190207c Mon Sep 17 00:00:00 2001 From: Lotto Date: Sat, 19 May 2018 18:21:43 +0200 Subject: [PATCH 2/3] fpsindicator: fix overlay being cut off outside the canvas --- .../net/runelite/client/plugins/fps/FpsOverlay.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java index 55c0a176e1..420c0e6656 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java @@ -49,8 +49,8 @@ public class FpsOverlay extends Overlay { private static final int MAX_FPS = 50; private static final int FPS_SIZE = MAX_FPS + 1; - private static final int Y_OFFSET = 14; - private static final int VALUE_X_OFFSET = 15; + private static final int Y_OFFSET = 1; + private static final int VALUE_X_OFFSET = 1; private static final String FPS_STRING = " FPS"; // Cache of FPS number strings from 00-50 @@ -111,9 +111,13 @@ public class FpsOverlay extends Overlay final int fps = client.getFPS(); if (fps < FPS_SIZE) { + final String text = fpsNums[fps] + FPS_STRING; + final int textWidth = graphics.getFontMetrics().stringWidth(text); + final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); + final int width = (int) client.getRealDimensions().getWidth(); - final Point point = new Point(width - VALUE_X_OFFSET - graphics.getFontMetrics().stringWidth(FPS_STRING), Y_OFFSET); - OverlayUtil.renderTextLocation(graphics, point, fpsNums[fps] + FPS_STRING, getFpsValueColor()); + final Point point = new Point(width - textWidth - VALUE_X_OFFSET, textHeight + Y_OFFSET); + OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor()); } return null; From 9aed31d35399ac515b460ecbd9724f6d5a8ea9f8 Mon Sep 17 00:00:00 2001 From: Lotto Date: Tue, 14 Aug 2018 15:14:45 +0200 Subject: [PATCH 3/3] fpsindicator: remove caching of fps strings --- .../client/plugins/fps/FpsOverlay.java | 34 ++++--------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java index 420c0e6656..654277744b 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/fps/FpsOverlay.java @@ -47,15 +47,10 @@ import net.runelite.client.ui.overlay.OverlayUtil; */ public class FpsOverlay extends Overlay { - private static final int MAX_FPS = 50; - private static final int FPS_SIZE = MAX_FPS + 1; private static final int Y_OFFSET = 1; private static final int VALUE_X_OFFSET = 1; private static final String FPS_STRING = " FPS"; - // Cache of FPS number strings from 00-50 - private final String[] fpsNums; - // Local dependencies private final FpsConfig config; private final Client client; @@ -71,17 +66,6 @@ public class FpsOverlay extends Overlay setLayer(OverlayLayer.ABOVE_WIDGETS); setPriority(OverlayPriority.HIGH); setPosition(OverlayPosition.DYNAMIC); - - // Populate pre-allocated strings of FPS, these are constant and there's no reason - // to create additional garbage - // FPS should never exceed 50, we have 0-50 (51 entries) - String[] fpsNums = new String[FPS_SIZE]; - for (int i = 0; i < FPS_SIZE; i++) - { - fpsNums[i] = String.format("%02d", i); - } - this.fpsNums = fpsNums; - } void onFocusChanged(FocusChanged event) @@ -107,18 +91,14 @@ public class FpsOverlay extends Overlay { return null; } + + final String text = client.getFPS() + FPS_STRING; + final int textWidth = graphics.getFontMetrics().stringWidth(text); + final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); - final int fps = client.getFPS(); - if (fps < FPS_SIZE) - { - final String text = fpsNums[fps] + FPS_STRING; - final int textWidth = graphics.getFontMetrics().stringWidth(text); - final int textHeight = graphics.getFontMetrics().getAscent() - graphics.getFontMetrics().getDescent(); - - final int width = (int) client.getRealDimensions().getWidth(); - final Point point = new Point(width - textWidth - VALUE_X_OFFSET, textHeight + Y_OFFSET); - OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor()); - } + final int width = (int) client.getRealDimensions().getWidth(); + final Point point = new Point(width - textWidth - VALUE_X_OFFSET, textHeight + Y_OFFSET); + OverlayUtil.renderTextLocation(graphics, point, text, getFpsValueColor()); return null; }