Merge pull request #12893 from Hydrox6/timetracking-soonest
timetracking: Add option to show the soonest completion time of a tab
This commit is contained in:
@@ -40,6 +40,7 @@ public interface TimeTrackingConfig extends Config
|
||||
String BOTANIST = "botanist";
|
||||
String TIMERS = "timers";
|
||||
String STOPWATCHES = "stopwatches";
|
||||
String PREFER_SOONEST = "preferSoonest";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "timeFormatMode",
|
||||
@@ -120,6 +121,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",
|
||||
|
||||
@@ -51,6 +51,7 @@ import net.runelite.client.events.RuneScapeProfileChanged;
|
||||
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;
|
||||
@@ -173,6 +174,10 @@ public class TimeTrackingPlugin extends Plugin
|
||||
{
|
||||
clockManager.loadStopwatches();
|
||||
}
|
||||
else if (e.getKey().equals(PREFER_SOONEST))
|
||||
{
|
||||
farmingTracker.loadCompletionTimes();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
|
||||
@@ -407,7 +407,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;
|
||||
|
||||
@@ -426,7 +426,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());
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -443,7 +451,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;
|
||||
@@ -451,7 +459,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