Merge pull request #188 from Kyleeld/Kyleeld-agility-1

Kyleeld agility 1
This commit is contained in:
Ganom
2019-05-05 17:17:03 -04:00
committed by GitHub
3 changed files with 55 additions and 20 deletions

View File

@@ -54,11 +54,33 @@ public interface AgilityConfig extends Config
return 5; return 5;
} }
@ConfigItem(
keyName = "lapsToLevel",
name = "Show Laps Until Level",
description = "Show number of laps remaining until next level is reached.",
position = 3
)
default boolean lapsToLevel()
{
return true;
}
@ConfigItem(
keyName = "lapsToGoal",
name = "Show Laps Until Goal",
description = "Show number of laps remaining until experience tracker goal is reached",
position = 4
)
default boolean lapsToGoal()
{
return false;
}
@ConfigItem( @ConfigItem(
keyName = "overlayColor", keyName = "overlayColor",
name = "Overlay Color", name = "Overlay Color",
description = "Color of Agility overlay", description = "Color of Agility overlay",
position = 3 position = 5
) )
default Color getOverlayColor() default Color getOverlayColor()
{ {
@@ -69,7 +91,7 @@ public interface AgilityConfig extends Config
keyName = "highlightMarks", keyName = "highlightMarks",
name = "Highlight Marks of Grace", name = "Highlight Marks of Grace",
description = "Enable/disable the highlighting of retrievable Marks of Grace", description = "Enable/disable the highlighting of retrievable Marks of Grace",
position = 4 position = 6
) )
default boolean highlightMarks() default boolean highlightMarks()
{ {
@@ -80,7 +102,7 @@ public interface AgilityConfig extends Config
keyName = "markHighlight", keyName = "markHighlight",
name = "Mark Highlight Color", name = "Mark Highlight Color",
description = "Color of highlighted Marks of Grace", description = "Color of highlighted Marks of Grace",
position = 5 position = 7
) )
default Color getMarkColor() default Color getMarkColor()
{ {
@@ -91,29 +113,18 @@ public interface AgilityConfig extends Config
keyName = "highlightShortcuts", keyName = "highlightShortcuts",
name = "Highlight Agility Shortcuts", name = "Highlight Agility Shortcuts",
description = "Enable/disable the highlighting of Agility shortcuts", description = "Enable/disable the highlighting of Agility shortcuts",
position = 6 position = 8
) )
default boolean highlightShortcuts() default boolean highlightShortcuts()
{ {
return true; return true;
} }
@ConfigItem(
keyName = "addLevelsToShortcutOptions",
name = "Show shortcut agility req. in options",
description = "Enable/disable showing shortcut agility level requirements in right-click options",
position = 7
)
default boolean showShortcutLevel()
{
return true;
}
@ConfigItem( @ConfigItem(
keyName = "trapOverlay", keyName = "trapOverlay",
name = "Show Trap Overlay", name = "Show Trap Overlay",
description = "Enable/disable the highlighting of traps on Agility courses", description = "Enable/disable the highlighting of traps on Agility courses",
position = 8 position = 9
) )
default boolean showTrapOverlay() default boolean showTrapOverlay()
{ {
@@ -124,7 +135,7 @@ public interface AgilityConfig extends Config
keyName = "trapHighlight", keyName = "trapHighlight",
name = "Trap Overlay Color", name = "Trap Overlay Color",
description = "Color of Agility trap overlay", description = "Color of Agility trap overlay",
position = 9 position = 10
) )
default Color getTrapColor() default Color getTrapColor()
{ {
@@ -135,7 +146,7 @@ public interface AgilityConfig extends Config
keyName = "agilityArenaNotifier", keyName = "agilityArenaNotifier",
name = "Agility Arena notifier", name = "Agility Arena notifier",
description = "Notify on ticket location change in Agility Arena", description = "Notify on ticket location change in Agility Arena",
position = 10 position = 11
) )
default boolean notifyAgilityArena() default boolean notifyAgilityArena()
{ {
@@ -146,10 +157,21 @@ public interface AgilityConfig extends Config
keyName = "agilityArenaTimer", keyName = "agilityArenaTimer",
name = "Agility Arena timer", name = "Agility Arena timer",
description = "Configures whether Agility Arena timer is displayed", description = "Configures whether Agility Arena timer is displayed",
position = 11 position = 12
) )
default boolean showAgilityArenaTimer() default boolean showAgilityArenaTimer()
{ {
return true; return true;
} }
@ConfigItem(
keyName = "addLevelsToShortcutOptions",
name = "Show shortcut agility req. in options",
description = "Enable/disable showing shortcut agility level requirements in right-click options",
position = 13
)
default boolean showShortcutLevel()
{
return true;
}
} }

View File

@@ -30,6 +30,7 @@ import lombok.Setter;
import net.runelite.api.Client; import net.runelite.api.Client;
import net.runelite.api.Experience; import net.runelite.api.Experience;
import net.runelite.api.Skill; import net.runelite.api.Skill;
import net.runelite.api.VarPlayer;
@Getter @Getter
@Setter @Setter
@@ -39,6 +40,7 @@ class AgilitySession
private Instant lastLapCompleted; private Instant lastLapCompleted;
private int totalLaps; private int totalLaps;
private int lapsTillLevel; private int lapsTillLevel;
private int lapsTillGoal;
AgilitySession(Courses course) AgilitySession(Courses course)
{ {
@@ -61,11 +63,14 @@ class AgilitySession
} while (remainingXp < 0); } while (remainingXp < 0);
lapsTillLevel = remainingXp > 0 ? (int) Math.ceil(remainingXp / course.getTotalXp()) : 0; lapsTillLevel = remainingXp > 0 ? (int) Math.ceil(remainingXp / course.getTotalXp()) : 0;
int goalRemainingXp = client.getVar(VarPlayer.AGILITY_GOAL_END) - currentExp;
lapsTillGoal = goalRemainingXp > 0 ? (int) Math.ceil(goalRemainingXp / course.getTotalXp()) : 0;
} }
void resetLapCount() void resetLapCount()
{ {
totalLaps = 0; totalLaps = 0;
lapsTillLevel = 0; lapsTillLevel = 0;
lapsTillGoal = 0;
} }
} }

View File

@@ -85,7 +85,7 @@ class LapCounterOverlay extends Overlay
.right(Integer.toString(session.getTotalLaps())) .right(Integer.toString(session.getTotalLaps()))
.build()); .build());
if (session.getLapsTillLevel() > 0) if (config.lapsToLevel() && session.getLapsTillLevel() > 0)
{ {
panelComponent.getChildren().add(LineComponent.builder() panelComponent.getChildren().add(LineComponent.builder()
.left("Laps until level:") .left("Laps until level:")
@@ -93,6 +93,14 @@ class LapCounterOverlay extends Overlay
.build()); .build());
} }
if (config.lapsToGoal() && session.getLapsTillGoal() > 0)
{
panelComponent.getChildren().add(LineComponent.builder()
.left("Laps until goal:")
.right(Integer.toString(session.getLapsTillGoal()))
.build());
}
return panelComponent.render(graphics); return panelComponent.render(graphics);
} }
} }