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
This commit is contained in:
Snorflake
2017-10-31 09:14:28 +08:00
committed by Alexander
parent f4dbf8d4fb
commit 408cc96133
2 changed files with 33 additions and 8 deletions

View File

@@ -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",

View File

@@ -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);