timetracking: Add option to show the soonest completion time of a tab
This commit is contained in:
@@ -38,6 +38,7 @@ public interface TimeTrackingConfig extends Config
|
||||
String BOTANIST = "botanist";
|
||||
String TIMERS = "timers";
|
||||
String STOPWATCHES = "stopwatches";
|
||||
String PREFER_SOONEST = "preferSoonest";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "timeFormatMode",
|
||||
@@ -118,6 +119,17 @@ public interface TimeTrackingConfig extends Config
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = PREFER_SOONEST,
|
||||
name = "Prefer soonest completion",
|
||||
description = "When displaying completion times on the overview, prefer showing the soonest any patch will complete.",
|
||||
position = 7
|
||||
)
|
||||
default boolean preferSoonest()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "activeTab",
|
||||
name = "Active Tab",
|
||||
|
||||
@@ -49,6 +49,7 @@ import net.runelite.client.game.ItemManager;
|
||||
import net.runelite.client.plugins.Plugin;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.CONFIG_GROUP;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.PREFER_SOONEST;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.STOPWATCHES;
|
||||
import static net.runelite.client.plugins.timetracking.TimeTrackingConfig.TIMERS;
|
||||
import net.runelite.client.plugins.timetracking.clocks.ClockManager;
|
||||
@@ -172,6 +173,10 @@ public class TimeTrackingPlugin extends Plugin
|
||||
{
|
||||
clockManager.loadStopwatches();
|
||||
}
|
||||
else if (e.getKey().equals(PREFER_SOONEST))
|
||||
{
|
||||
farmingTracker.loadCompletionTimes();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -277,7 +277,7 @@ public class FarmingTracker
|
||||
{
|
||||
for (Map.Entry<Tab, Set<FarmingPatch>> tab : farmingWorld.getTabs().entrySet())
|
||||
{
|
||||
long maxCompletionTime = 0;
|
||||
long extremumCompletionTime = config.preferSoonest() ? Long.MAX_VALUE : 0;
|
||||
boolean allUnknown = true;
|
||||
boolean allEmpty = true;
|
||||
|
||||
@@ -296,7 +296,15 @@ public class FarmingTracker
|
||||
allEmpty = false;
|
||||
|
||||
// update max duration if this patch takes longer to grow
|
||||
maxCompletionTime = Math.max(maxCompletionTime, prediction.getDoneEstimate());
|
||||
if (config.preferSoonest())
|
||||
{
|
||||
extremumCompletionTime = Math.min(extremumCompletionTime, prediction.getDoneEstimate());
|
||||
}
|
||||
else
|
||||
{
|
||||
extremumCompletionTime = Math.max(extremumCompletionTime, prediction.getDoneEstimate());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -313,7 +321,7 @@ public class FarmingTracker
|
||||
state = SummaryState.EMPTY;
|
||||
completionTime = -1L;
|
||||
}
|
||||
else if (maxCompletionTime <= Instant.now().getEpochSecond())
|
||||
else if (extremumCompletionTime <= Instant.now().getEpochSecond())
|
||||
{
|
||||
state = SummaryState.COMPLETED;
|
||||
completionTime = 0;
|
||||
@@ -321,7 +329,7 @@ public class FarmingTracker
|
||||
else
|
||||
{
|
||||
state = SummaryState.IN_PROGRESS;
|
||||
completionTime = maxCompletionTime;
|
||||
completionTime = extremumCompletionTime;
|
||||
}
|
||||
summaries.put(tab.getKey(), state);
|
||||
completionTimes.put(tab.getKey(), completionTime);
|
||||
|
||||
Reference in New Issue
Block a user