Skip to content
Open
Show file tree
Hide file tree
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
127 changes: 120 additions & 7 deletions src/main/java/com/visualticks/VisualTicksConfig.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.visualticks;

import com.visualticks.config.TickShape;
import net.runelite.api.Skill;
import net.runelite.client.config.*;

import java.awt.*;
Expand All @@ -8,12 +10,24 @@
public interface VisualTicksConfig extends Config
{
String GROUP_NAME = "visualticks";
String GENERAL_SETTINGS = "General-settings";
String RESET_SETTINGS = "Reset-settings";

// General settings
@ConfigSection(
position = 0,
name = "General",
description = "General settings"

)
String generalSettings = GENERAL_SETTINGS;

@ConfigItem(
position = 0,
keyName = "numberOfTicks",
name = "Number of ticks",
description = "Number of tick circles to display"
description = "Number of tick circles to display",
section = generalSettings
)
@Range(min = 2, max = 30)
default int numberOfTicks()
Expand All @@ -25,7 +39,8 @@ default int numberOfTicks()
position = 1,
keyName = "tickColour",
name = "Tick colour",
description = "The colour of the ticks"
description = "The colour of the ticks",
section = generalSettings
)
@Alpha
default Color tickColour()
Expand All @@ -37,7 +52,8 @@ default Color tickColour()
position = 2,
keyName = "currentTickColour",
name = "Current tick colour",
description = "The colour of the current tick"
description = "The colour of the current tick",
section = generalSettings
)
@Alpha
default Color currentTickColour()
Expand All @@ -49,18 +65,20 @@ default Color currentTickColour()
position = 3,
keyName = "amountPerRow",
name = "Amount per row",
description = "How many ticks to display per row"
description = "How many ticks to display per row",
section = generalSettings
)
default int amountPerRow()
{
return 8;
}

@ConfigItem(
position = 3,
position = 4,
keyName = "sizeOfTickShapes",
name = "Size of ticks",
description = "How many pixels to make the tick shapes"
description = "How many pixels to make the tick shapes",
section = generalSettings
)
default int sizeOfTickShapes()
{
Expand All @@ -71,10 +89,105 @@ default int sizeOfTickShapes()
position = 5,
keyName = "paddingBetweenTicks",
name = "Padding between ticks",
description = "The amount of space between ticks"
description = "The amount of space between ticks",
section = generalSettings
)
default int tickPadding()
{
return 5;
}


@ConfigItem(
position = 6,
keyName = "arcOnTicks",
name = "Arc",
description = "Arc (if using Rounded Square)",
section = generalSettings
)
default int getTickArc() {
return 5;
}

@ConfigItem(
position =7,
keyName = "tickShape",
name = "Shape",
description = "The shape of the visual ticks",
section = generalSettings
)
default TickShape getTickShape()
{
return TickShape.CIRCLE;
}

@ConfigSection(
position = 1,
name = "Reset counter",
description = "Reset counter"

)
String resetSettings = RESET_SETTINGS;


@ConfigItem(
position = 0,
keyName = "reset-conter",
name = "Reset counter on xp drop",
description = "Reset the tick-counter after xp-drop.",
section = resetSettings
)
default boolean isResetCounter() {
return false;
}

@ConfigItem(
position = 1,
keyName = "startTick",
name = "Start on tick",
description = "Which tick to start on after the reset.",
section = resetSettings
)
@Range(max = 30)
default int getOffset() {
return 0;
}


@ConfigItem(
position = 2,
keyName = "skill",
name = "Skill",
description = "Which skill you want to trigger the reset",
section = resetSettings
)
default Skill getResetSkill() {
return Skill.HITPOINTS;
}

@ConfigItem(
position = 3,
keyName = "currentResetTickColour",
name = "Current reset tick colour",
description = "The colour of the reset tick when active",
section = resetSettings
)
@Alpha
default Color getCurrentResetTickColour()
{
return Color.GREEN;
}

@ConfigItem(
position = 4,
keyName = "resetTickColour",
name = "Reset tick colour",
description = "The colour of the reset tick when not active",
section = resetSettings
)
@Alpha
default Color getResetTickColour()
{
return Color.decode("#0D430D");
}
}
44 changes: 42 additions & 2 deletions src/main/java/com/visualticks/VisualTicksOverlay.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.visualticks;

import com.visualticks.utils.ResetUtils;
import lombok.extern.slf4j.Slf4j;
import net.runelite.client.ui.overlay.Overlay;
import net.runelite.client.ui.overlay.OverlayPosition;
Expand Down Expand Up @@ -30,9 +31,9 @@ public Dimension render(Graphics2D graphics)
{
int x = position * config.sizeOfTickShapes() + position * config.tickPadding();
int y = row * config.sizeOfTickShapes() + row * config.tickPadding();
graphics.setColor(plugin.tick == tick ? config.currentTickColour() : config.tickColour());

graphics.fillOval(x, y, config.sizeOfTickShapes(), config.sizeOfTickShapes());
setTickColor(graphics, tick);
setTickShape(graphics, x, y);

position++;
if(position > config.amountPerRow() - 1) {
Expand All @@ -49,4 +50,43 @@ public Dimension render(Graphics2D graphics)

return new Dimension(width, height);
}

private void setTickShape(Graphics2D graphics, int xPosition, int yPosition) {
switch (config.getTickShape()) {
case SQUARE:
graphics.fillRect(xPosition, yPosition, config.sizeOfTickShapes(), config.sizeOfTickShapes());
break;
case ROUNDED_SQUARE:
graphics.fillRoundRect(xPosition, yPosition ,config.sizeOfTickShapes() , config.sizeOfTickShapes(), config.getTickArc(), config.getTickArc());
break;
default:
graphics.fillOval(xPosition, yPosition, config.sizeOfTickShapes(), config.sizeOfTickShapes());
break;
}
}

private void setTickColor(Graphics2D graphics, int tick) {
if (plugin.tick == tick) {
graphics.setColor(setCurrentColor(tick));
} else if (config.isResetCounter() && isResetTick(tick)) {
graphics.setColor(config.getResetTickColour());
} else {
graphics.setColor(config.tickColour());
}
}

private Color setCurrentColor(int tick) {
if (!config.isResetCounter()) {
return config.currentTickColour();
}
if (isResetTick(tick)) {
return config.getCurrentResetTickColour();
} else {
return config.currentTickColour();
}
}

private boolean isResetTick(int tick) {
return (tick == ResetUtils.calculateOffset(config.getOffset(), config.numberOfTicks()));
}
}
20 changes: 19 additions & 1 deletion src/main/java/com/visualticks/VisualTicksPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import com.google.inject.Provides;
import javax.inject.Inject;
import com.visualticks.utils.ResetUtils;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.StatChanged;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.Plugin;
Expand All @@ -25,6 +27,7 @@ public class VisualTicksPlugin extends Plugin
@Inject
private VisualTicksOverlay overlay;
public int tick = 0;
private boolean isReset = false;

@Override
protected void startUp() throws Exception
Expand All @@ -38,10 +41,25 @@ protected void shutDown() throws Exception
overlayManager.remove(overlay);
}

@Subscribe
public void onStatChanged(StatChanged statChanged)
{
if (statChanged.getSkill() == config.getResetSkill())
{
if (config.isResetCounter()) {
isReset = true;
}
}
}

@Subscribe
private void onGameTick(GameTick gameTick) {
tick++;
if (isReset) {
tick = ResetUtils.calculateOffset(config.getOffset(), config.numberOfTicks());
isReset = false;
} else {
tick++;
}
if(tick > config.numberOfTicks() - 1) tick = 0;
}

Expand Down
10 changes: 10 additions & 0 deletions src/main/java/com/visualticks/config/TickShape.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.visualticks.config;

import lombok.Getter;

@Getter
public enum TickShape {
SQUARE,
CIRCLE,
ROUNDED_SQUARE;
}
11 changes: 11 additions & 0 deletions src/main/java/com/visualticks/utils/ResetUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.visualticks.utils;

public class ResetUtils {

public static int calculateOffset(int offset, int numberOfTicks) {
if (offset < numberOfTicks){
return offset;
}
return offset % numberOfTicks;
}
}