Merge pull request #302 from Noremac201/fixStyle
Changed attack style plugin to render over right side of chatbox
This commit is contained in:
@@ -34,6 +34,8 @@ import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||
|
||||
public class AttackIndicatorOverlay extends Overlay
|
||||
{
|
||||
private static final int COMPONENT_WIDTH = 80;
|
||||
|
||||
private final AttackIndicatorConfig config;
|
||||
private final AttackIndicatorPlugin plugin;
|
||||
private final PanelComponent panelComponent = new PanelComponent();
|
||||
@@ -41,7 +43,7 @@ public class AttackIndicatorOverlay extends Overlay
|
||||
@Inject
|
||||
public AttackIndicatorOverlay(AttackIndicatorPlugin plugin, AttackIndicatorConfig config)
|
||||
{
|
||||
setPosition(OverlayPosition.BOTTOM_RIGHT);
|
||||
setPosition(OverlayPosition.ABOVE_CHATBOX_RIGHT);
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
}
|
||||
@@ -56,7 +58,8 @@ public class AttackIndicatorOverlay extends Overlay
|
||||
|
||||
final String attackStyleString = plugin.getAttackStyle().getName();
|
||||
panelComponent.setTitle(attackStyleString);
|
||||
panelComponent.setWidth(80);
|
||||
panelComponent.setWidth(COMPONENT_WIDTH);
|
||||
|
||||
return panelComponent.render(graphics, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,5 +45,9 @@ public enum OverlayPosition
|
||||
/**
|
||||
* 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;
|
||||
}
|
||||
|
||||
@@ -187,6 +187,10 @@ public class OverlayRenderer
|
||||
? new Rectangle(viewport.getBounds())
|
||||
: 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);
|
||||
final Point topLeftPoint = new Point();
|
||||
topLeftPoint.move(BORDER_LEFT, BORDER_TOP);
|
||||
@@ -196,6 +200,8 @@ public class OverlayRenderer
|
||||
bottomLeftPoint.move(BORDER_LEFT, bounds.y + bounds.height - BORDER_BOTTOM);
|
||||
final Point bottomRightPoint = new Point();
|
||||
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()
|
||||
.filter(overlay -> shouldDrawOverlay(client, overlay))
|
||||
@@ -217,6 +223,9 @@ public class OverlayRenderer
|
||||
case TOP_RIGHT:
|
||||
subPosition.setLocation(topRightPoint);
|
||||
break;
|
||||
case ABOVE_CHATBOX_RIGHT:
|
||||
subPosition.setLocation(rightChatboxPoint);
|
||||
break;
|
||||
}
|
||||
|
||||
if (overlay.getPosition().equals(OverlayPosition.DYNAMIC))
|
||||
@@ -249,6 +258,9 @@ public class OverlayRenderer
|
||||
case TOP_RIGHT:
|
||||
topRightPoint.y += dimension.height + (dimension.height == 0 ? 0 : PADDING);
|
||||
break;
|
||||
case ABOVE_CHATBOX_RIGHT:
|
||||
rightChatboxPoint.y -= dimension.height + (dimension.height == 0 ? 0 : PADDING);
|
||||
break;
|
||||
}
|
||||
|
||||
final Point transformed = OverlayUtil.transformPosition(overlay.getPosition(), dimension);
|
||||
|
||||
@@ -337,6 +337,7 @@ public class OverlayUtil
|
||||
result.y = result.y - dimension.height;
|
||||
break;
|
||||
case BOTTOM_RIGHT:
|
||||
case ABOVE_CHATBOX_RIGHT:
|
||||
result.y = result.y - dimension.height;
|
||||
case TOP_RIGHT:
|
||||
result.x = result.x - dimension.width;
|
||||
|
||||
Reference in New Issue
Block a user