-
Notifications
You must be signed in to change notification settings - Fork 28
Make Tick Counter Movable #44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,10 @@ | ||
| package com.attacktimer; | ||
| package net.runelite.client.plugins.attacktimer; | ||
|
|
||
| import net.runelite.api.Client; | ||
| import net.runelite.api.Perspective; | ||
| import net.runelite.api.Point; | ||
| import net.runelite.api.coords.LocalPoint; | ||
| import net.runelite.client.plugins.GameTickInfo.GameTickInfoPlugin; | ||
| import net.runelite.client.ui.FontManager; | ||
| import net.runelite.client.ui.overlay.Overlay; | ||
| import net.runelite.client.ui.overlay.OverlayPosition; | ||
|
|
@@ -18,14 +19,21 @@ | |
| import net.runelite.api.coords.WorldPoint; | ||
| import net.runelite.client.ui.overlay.OverlayLayer; | ||
| import net.runelite.client.ui.overlay.OverlayPriority; | ||
| import net.runelite.client.ui.overlay.components.PanelComponent; | ||
| import net.runelite.api.Client; | ||
| import net.runelite.client.ui.overlay.OverlayPanel; | ||
| import net.runelite.client.ui.overlay.OverlayPosition; | ||
| import net.runelite.client.ui.overlay.components.PanelComponent; | ||
| import net.runelite.client.ui.overlay.components.TitleComponent; | ||
|
|
||
|
|
||
| public class AttackTimerMetronomeTileOverlay extends Overlay | ||
| public class AttackTimerMetronomeTileOverlay extends OverlayPanel | ||
| { | ||
|
|
||
| private final Client client; | ||
| private final AttackTimerMetronomeConfig config; | ||
| private final AttackTimerMetronomePlugin plugin; | ||
| private final PanelComponent AttackTimerMetronomeTileOverlay = new PanelComponent(); | ||
|
|
||
| @Inject | ||
| public AttackTimerMetronomeTileOverlay(Client client, AttackTimerMetronomeConfig config, AttackTimerMetronomePlugin plugin) | ||
|
|
@@ -34,14 +42,16 @@ public AttackTimerMetronomeTileOverlay(Client client, AttackTimerMetronomeConfig | |
| this.client = client; | ||
| this.config = config; | ||
| this.plugin = plugin; | ||
| setPosition(OverlayPosition.DYNAMIC); | ||
| setLayer(OverlayLayer.UNDER_WIDGETS); | ||
| setPosition(OverlayPosition.TOP_LEFT); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This commit looks like it changes the default rendering - let's make sure that the default remains the same and any movability is opt-in via the config interface.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I imagine anything that is giving a timer for your attacks you would want overlayed any other rendered objects. |
||
| setLayer(OverlayLayer.ABOVE_WIDGETS); | ||
| setPriority(OverlayPriority.MED); | ||
| isResizable(); | ||
| } | ||
|
|
||
| @Override | ||
| public Dimension render(Graphics2D graphics) | ||
| { | ||
| int ticksRemaining = plugin.getTicksUntilNextAttack(); | ||
| if (plugin.attackState != AttackTimerMetronomePlugin.AttackState.DELAYED) { | ||
| return null; | ||
| } | ||
|
|
@@ -57,17 +67,27 @@ public Dimension render(Graphics2D graphics) | |
| graphics.setFont(new Font(config.fontType().toString(), Font.PLAIN, config.fontSize())); | ||
| } | ||
|
|
||
| final int height = client.getLocalPlayer().getLogicalHeight()+20; | ||
| final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); | ||
| final Point playerPoint = Perspective.localToCanvas(client, localLocation, client.getPlane(), height); | ||
| String timeToDisplay = String.valueOf(ticksRemaining); | ||
|
|
||
| AttackTimerMetronomeTileOverlay.getChildren().clear(); | ||
| AttackTimerMetronomeTileOverlay.getChildren().add(TitleComponent.builder() | ||
| .text(timeToDisplay) | ||
| .color(config.NumberColor()) | ||
| .build()); | ||
|
|
||
|
|
||
| // final int height = client.getLocalPlayer().getLogicalHeight()+20; | ||
| // final LocalPoint localLocation = client.getLocalPlayer().getLocalLocation(); | ||
| // final Point playerPoint = Perspective.localToCanvas(client, localLocation, client.getPlane(), height); | ||
|
|
||
| // Countdown ticks instead of up. | ||
| // plugin.tickCounter => ticksRemaining | ||
| int ticksRemaining = plugin.getTicksUntilNextAttack(); | ||
| OverlayUtil.renderTextLocation(graphics, playerPoint, String.valueOf(ticksRemaining), config.NumberColor()); | ||
| AttackTimerMetronomeTileOverlay.setPreferredSize(new Dimension(graphics.getFontMetrics().stringWidth(String.valueOf(GameTickInfoPlugin.timeSinceCycleStart))+10,0)); | ||
| //int ticksRemaining = plugin.getTicksUntilNextAttack(); | ||
| // OverlayUtil.renderTextLocation(graphics, playerPoint, String.valueOf(ticksRemaining), config.NumberColor()); | ||
| } | ||
|
|
||
| return null; | ||
| return AttackTimerMetronomeTileOverlay.render(graphics); | ||
| //return null; | ||
| } | ||
|
|
||
| private void renderTile(final Graphics2D graphics, final LocalPoint dest, final Color color, final Color fillColor, final double borderWidth) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to change the package name here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The package name automatically adjusted due to it being compiled in my intelij.
I imagine if you swap it back to the original line it would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you swap the name back in your PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will give it a shot, was busy making some other things Ill try to get around to it tonight :)