runelite-client: clean up fps overlay. Move near XP orb.
This commit is contained in:
@@ -25,12 +25,30 @@
|
|||||||
|
|
||||||
package net.runelite.client.plugins.fpsinfo;
|
package net.runelite.client.plugins.fpsinfo;
|
||||||
|
|
||||||
|
import java.awt.Font;
|
||||||
|
import java.awt.GraphicsEnvironment;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
|
|
||||||
public class FPS extends Plugin
|
public class FPS extends Plugin
|
||||||
{
|
{
|
||||||
private final Overlay overlay = new FPSOverlay();
|
private final Overlay overlay = new FPSOverlay(this);
|
||||||
|
|
||||||
|
private Font font;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void startUp() throws Exception
|
||||||
|
{
|
||||||
|
font = Font.createFont(Font.TRUETYPE_FONT, getClass().getResourceAsStream("/runescape.ttf"));
|
||||||
|
font = font.deriveFont(Font.BOLD, 16);
|
||||||
|
GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
||||||
|
ge.registerFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void shutDown() throws Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Overlay getOverlay()
|
public Overlay getOverlay()
|
||||||
@@ -38,13 +56,8 @@ public class FPS extends Plugin
|
|||||||
return overlay;
|
return overlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Font getFont()
|
||||||
protected void startUp() throws Exception
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void shutDown() throws Exception
|
|
||||||
{
|
{
|
||||||
|
return font;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,10 +26,14 @@ package net.runelite.client.plugins.fpsinfo;
|
|||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Dimension;
|
import java.awt.Dimension;
|
||||||
|
import java.awt.Font;
|
||||||
import java.awt.FontMetrics;
|
import java.awt.FontMetrics;
|
||||||
import java.awt.Graphics2D;
|
import java.awt.Graphics2D;
|
||||||
|
import java.awt.geom.Rectangle2D;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.Client;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
|
import net.runelite.api.widgets.Widget;
|
||||||
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.RuneLite;
|
import net.runelite.client.RuneLite;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayPosition;
|
import net.runelite.client.ui.overlay.OverlayPosition;
|
||||||
@@ -38,10 +42,12 @@ import net.runelite.client.ui.overlay.OverlayPriority;
|
|||||||
public class FPSOverlay extends Overlay
|
public class FPSOverlay extends Overlay
|
||||||
{
|
{
|
||||||
private static final Client client = RuneLite.getClient();
|
private static final Client client = RuneLite.getClient();
|
||||||
|
private final FPS plugin;
|
||||||
|
|
||||||
public FPSOverlay()
|
public FPSOverlay(FPS plugin)
|
||||||
{
|
{
|
||||||
super(OverlayPosition.TOP_RIGHT, OverlayPriority.HIGH);
|
super(OverlayPosition.DYNAMIC, OverlayPriority.HIGH);
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -53,21 +59,32 @@ public class FPSOverlay extends Overlay
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Font font = plugin.getFont();
|
||||||
|
if (font != null)
|
||||||
|
{
|
||||||
|
graphics.setFont(font);
|
||||||
|
}
|
||||||
|
|
||||||
FontMetrics fm = graphics.getFontMetrics();
|
FontMetrics fm = graphics.getFontMetrics();
|
||||||
String str = String.valueOf(client.getFPS());
|
String str = String.valueOf(client.getFPS());
|
||||||
|
|
||||||
int x = 0;
|
Widget xpOrb = client.getWidget(WidgetInfo.MINIMAP_XP_ORG);
|
||||||
int y = fm.getHeight();
|
Rectangle2D bounds = xpOrb.getBounds().getBounds2D();
|
||||||
|
|
||||||
|
int x = (int) (bounds.getX() + ((bounds.getWidth() / 2) - (fm.stringWidth(str) / 2)));
|
||||||
|
int y = (int) (bounds.getY() - (fm.getHeight() / 2));
|
||||||
|
|
||||||
//outline
|
//outline
|
||||||
graphics.setColor(Color.black);
|
graphics.setColor(Color.BLACK);
|
||||||
graphics.drawString(str, x - 1, y + 1);
|
graphics.drawString(str, x - 1, y + 1);
|
||||||
graphics.drawString(str, x - 1, y - 1);
|
graphics.drawString(str, x - 1, y - 1);
|
||||||
graphics.drawString(str, x + 1, y + 1);
|
graphics.drawString(str, x + 1, y + 1);
|
||||||
graphics.drawString(str, x + 1, y - 1);
|
graphics.drawString(str, x + 1, y - 1);
|
||||||
|
|
||||||
//actual text
|
//actual text
|
||||||
graphics.setColor(Color.white);
|
graphics.setColor(Color.WHITE);
|
||||||
graphics.drawString(str, x, y);
|
graphics.drawString(str, x, y);
|
||||||
|
|
||||||
return new Dimension(fm.stringWidth(str), y);
|
return new Dimension(fm.stringWidth(str), fm.getHeight());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user