From c004747a88f39f3800f07524153907bba60bdb1a Mon Sep 17 00:00:00 2001 From: Kamiel Date: Thu, 1 Mar 2018 11:07:51 +0100 Subject: [PATCH] Add floor duration(s) to infobox tooltip --- .../client/plugins/raids/RaidsPlugin.java | 7 +++ .../client/plugins/raids/RaidsTimer.java | 49 ++++++++++++++++++- 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java index e0b1a5d29e..c0ffabb0e9 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsPlugin.java @@ -78,6 +78,7 @@ public class RaidsPlugin extends Plugin { private static final int LOBBY_PLANE = 3; private static final String RAID_START_MESSAGE = "The raid has begun!"; + private static final String LEVEL_COMPLETE_MESSAGE = "level complete!"; private static final String RAID_COMPLETE_MESSAGE = "Congratulations - your raid is complete!"; private static final int TOTAL_POINTS = 0, PERSONAL_POINTS = 1, TEXT_CHILD = 4; private static final DecimalFormat DECIMAL_FORMAT = new DecimalFormat("###.##"); @@ -258,10 +259,16 @@ public class RaidsPlugin extends Plugin infoBoxManager.addInfoBox(timer); } + if (timer != null && message.contains(LEVEL_COMPLETE_MESSAGE)) + { + timer.timeFloor(); + } + if (message.startsWith(RAID_COMPLETE_MESSAGE)) { if (timer != null) { + timer.timeFloor(); timer.setStopped(true); } diff --git a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java index 562105924a..8331789b64 100644 --- a/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java +++ b/runelite-client/src/main/java/net/runelite/client/plugins/raids/RaidsTimer.java @@ -36,7 +36,11 @@ import net.runelite.client.ui.overlay.infobox.InfoBox; public class RaidsTimer extends InfoBox { private final Instant startTime; + private Instant floorTime; private LocalTime time; + private LocalTime firstFloorTime; + private LocalTime secondFloorTime; + private LocalTime olmTime; @Setter private boolean stopped; @@ -45,9 +49,30 @@ public class RaidsTimer extends InfoBox { super(image); this.startTime = startTime; + floorTime = startTime; stopped = false; } + public void timeFloor() + { + Duration elapsed = Duration.between(floorTime, Instant.now()); + + if (firstFloorTime == null) + { + firstFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + else if (secondFloorTime == null) + { + secondFloorTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + else if (olmTime == null) + { + olmTime = LocalTime.ofSecondOfDay(elapsed.getSeconds()); + } + + floorTime = Instant.now(); + } + @Override public String getText() { @@ -84,6 +109,28 @@ public class RaidsTimer extends InfoBox @Override public String getTooltip() { - return "Elapsed raid time: " + time.format(DateTimeFormatter.ofPattern("HH:mm:ss")); + StringBuilder builder = new StringBuilder(); + builder.append("Elapsed raid time: "); + builder.append(time.format(DateTimeFormatter.ofPattern("HH:mm:ss"))); + + if (firstFloorTime != null) + { + builder.append("
First floor: "); + builder.append(firstFloorTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + if (secondFloorTime != null) + { + builder.append("
Second floor: "); + builder.append(secondFloorTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + if (olmTime != null) + { + builder.append("
Olm: "); + builder.append(olmTime.format(DateTimeFormatter.ofPattern("mm:ss"))); + } + + return builder.toString(); } }