From 408cc96133596916233bc4319f5f7012f3771774 Mon Sep 17 00:00:00 2001 From: Snorflake Date: Tue, 31 Oct 2017 09:14:28 +0800 Subject: [PATCH] Add option to swap sides of mouse highlighting (#168) * Add option to swap sides of mouse highlighting * Fix not drawing off of the top of the screen not fully working --- .../mousehighlight/MouseHighlightConfig.java | 10 ++++++ .../mousehighlight/MouseHighlightOverlay.java | 31 ++++++++++++++----- 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightConfig.java b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightConfig.java index 04c4b71975..9ff6a8753c 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightConfig.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightConfig.java @@ -46,6 +46,16 @@ public interface MouseHighlightConfig return true; } + @ConfigItem( + keyName = "display_left", + name = "Display to the left of mouse?", + description = "Display to the left of the mouse or the right?" + ) + default boolean display_left() + { + return true; + } + @ConfigItem( keyName = "border", name = "Border Color", diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java index cd00e250af..aaa220c0ca 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/mousehighlight/MouseHighlightOverlay.java @@ -125,17 +125,32 @@ class MouseHighlightOverlay extends Overlay } int height = fm.getHeight(); - x -= total_width + 6; // Draw to the left of the mouse + if (config.display_left()) + { + x -= total_width + 6; // Draw to the left of the mouse + + // Don't draw off of the screen (left) + if (x < 0) + { + x = 0; + } + } + else + { + // Don't draw off of the screen (right) + int canvas_width = client.getCanvas().getWidth(); + if (x + total_width + 7 > canvas_width) + { + x = canvas_width - total_width - 7; + } + } + y -= height / 2; // Draw slightly above the mouse - // Don't draw off of the screen - if (x < 0) + // Don't draw off of the screen (top) + if (y < height / 2) { - x = 0; - } - if (y < 0) - { - y = 0; + y = height / 2; } Color gray = new Color(Color.darkGray.getRed(), Color.darkGray.getGreen(), Color.darkGray.getBlue(), 190);