Add new overlay position for above right side of chatbox

This commit is contained in:
noremac201
2018-01-02 08:37:53 -05:00
committed by Adam
parent a407af8672
commit bf23c47916
3 changed files with 18 additions and 1 deletions

View File

@@ -45,5 +45,9 @@ public enum OverlayPosition
/** /**
* Place overlay in the bottom right most area possible * Place overlay in the bottom right most area possible
*/ */
BOTTOM_RIGHT; BOTTOM_RIGHT,
/**
* Place overlay directly above right most area of chatbox possible
*/
ABOVE_CHATBOX_RIGHT;
} }

View File

@@ -187,6 +187,10 @@ public class OverlayRenderer
? new Rectangle(viewport.getBounds()) ? new Rectangle(viewport.getBounds())
: new Rectangle(0, 0, surface.getWidth(), surface.getHeight()); : new Rectangle(0, 0, surface.getWidth(), surface.getHeight());
final Widget chatbox = client.getWidget(WidgetInfo.CHATBOX);
final Rectangle chatboxBounds = chatbox != null
? chatbox.getBounds() : new Rectangle(0, bounds.height, 519, 165);
OverlayUtil.setGraphicProperties(graphics); OverlayUtil.setGraphicProperties(graphics);
final Point topLeftPoint = new Point(); final Point topLeftPoint = new Point();
topLeftPoint.move(BORDER_LEFT, BORDER_TOP); topLeftPoint.move(BORDER_LEFT, BORDER_TOP);
@@ -196,6 +200,8 @@ public class OverlayRenderer
bottomLeftPoint.move(BORDER_LEFT, bounds.y + bounds.height - BORDER_BOTTOM); bottomLeftPoint.move(BORDER_LEFT, bounds.y + bounds.height - BORDER_BOTTOM);
final Point bottomRightPoint = new Point(); final Point bottomRightPoint = new Point();
bottomRightPoint.move(bounds.x + bounds.width - BORDER_RIGHT, bounds.y + bounds.height - BORDER_BOTTOM); bottomRightPoint.move(bounds.x + bounds.width - BORDER_RIGHT, bounds.y + bounds.height - BORDER_BOTTOM);
final Point rightChatboxPoint = new Point();
rightChatboxPoint.move(bounds.x + chatboxBounds.width - BORDER_RIGHT,bounds.y + bounds.height - BORDER_BOTTOM);
overlays.stream() overlays.stream()
.filter(overlay -> shouldDrawOverlay(client, overlay)) .filter(overlay -> shouldDrawOverlay(client, overlay))
@@ -217,6 +223,9 @@ public class OverlayRenderer
case TOP_RIGHT: case TOP_RIGHT:
subPosition.setLocation(topRightPoint); subPosition.setLocation(topRightPoint);
break; break;
case ABOVE_CHATBOX_RIGHT:
subPosition.setLocation(rightChatboxPoint);
break;
} }
if (overlay.getPosition().equals(OverlayPosition.DYNAMIC)) if (overlay.getPosition().equals(OverlayPosition.DYNAMIC))
@@ -249,6 +258,9 @@ public class OverlayRenderer
case TOP_RIGHT: case TOP_RIGHT:
topRightPoint.y += dimension.height + (dimension.height == 0 ? 0 : PADDING); topRightPoint.y += dimension.height + (dimension.height == 0 ? 0 : PADDING);
break; break;
case ABOVE_CHATBOX_RIGHT:
rightChatboxPoint.y -= dimension.height + (dimension.height == 0 ? 0 : PADDING);
break;
} }
final Point transformed = OverlayUtil.transformPosition(overlay.getPosition(), dimension); final Point transformed = OverlayUtil.transformPosition(overlay.getPosition(), dimension);

View File

@@ -337,6 +337,7 @@ public class OverlayUtil
result.y = result.y - dimension.height; result.y = result.y - dimension.height;
break; break;
case BOTTOM_RIGHT: case BOTTOM_RIGHT:
case ABOVE_CHATBOX_RIGHT:
result.y = result.y - dimension.height; result.y = result.y - dimension.height;
case TOP_RIGHT: case TOP_RIGHT:
result.x = result.x - dimension.width; result.x = result.x - dimension.width;