Merge pull request #302 from Noremac201/fixStyle

Changed attack style plugin to render over right side of chatbox
This commit is contained in:
Adam
2018-01-02 08:50:18 -05:00
committed by GitHub
4 changed files with 23 additions and 3 deletions

View File

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

View File

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

View File

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

View File

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