added coords

This commit is contained in:
2026-07-11 19:07:41 +02:00
parent a2d8780238
commit bf0fdb2b98
3 changed files with 32 additions and 3 deletions
@@ -18,6 +18,10 @@ public class QuestsPanel {
private static final int ACCENT = 0x64de4b;
// holds the currently open panel's Handle (if any) so tick() can refresh it
private static Handle activeHandle;
private static int tickCounter = 0;
private record QuestData(String title, String description, int requiredPlaytime) {
boolean isUnlocked() {
return PlaytimeTracker.getCurrentPlaytimeSeconds() >= requiredPlaytime;
@@ -134,7 +138,29 @@ public class QuestsPanel {
);
content.child(scrollArea);
return new Handle(playtimeLabel, percentLabel, barFill, barWidth, quests);
Handle handle = new Handle(playtimeLabel, percentLabel, barFill, barWidth, quests);
activeHandle = handle;
return handle;
}
/**
* Call this once per client tick (e.g. from ClientTickEvents.END_CLIENT_TICK)
* to keep the open panel's playtime/progress/quest state live.
* Throttled to once every 20 ticks (~1x/sec) since playtime itself only
* updates that often server-side.
*/
public static void tick() {
if (activeHandle != null && tickCounter++ % 20 == 0) {
activeHandle.refresh();
}
}
/**
* Call this from the screen's onClose() so a closed panel stops being
* refreshed and can be garbage collected.
*/
public static void clearActiveHandle() {
activeHandle = null;
}
private static String formatPlaytime(int seconds) {