Add floor duration(s) to infobox tooltip

This commit is contained in:
Kamiel
2018-03-01 11:07:51 +01:00
parent a84f8fbaa4
commit c004747a88
2 changed files with 55 additions and 1 deletions

View File

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

View File

@@ -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("</br>First floor: ");
builder.append(firstFloorTime.format(DateTimeFormatter.ofPattern("mm:ss")));
}
if (secondFloorTime != null)
{
builder.append("</br>Second floor: ");
builder.append(secondFloorTime.format(DateTimeFormatter.ofPattern("mm:ss")));
}
if (olmTime != null)
{
builder.append("</br>Olm: ");
builder.append(olmTime.format(DateTimeFormatter.ofPattern("mm:ss")));
}
return builder.toString();
}
}