Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 31 additions & 11 deletions src/main/java/com/attacktimer/AttackTimerMetronomeTileOverlay.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.attacktimer;
Copy link
Owner

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.

Copy link
Author

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.

Copy link
Owner

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?

Copy link
Author

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 :)

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;
Expand All @@ -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)
Expand All @@ -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);
Copy link
Owner

Choose a reason for hiding this comment

The 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.

Copy link
Author

Choose a reason for hiding this comment

The 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.
That being said I can attempt to make it a option in the config.

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