Show goal intro then milestone reminders

This commit is contained in:
Daddy32
2025-12-14 14:54:05 +01:00
parent d7f9fe9af3
commit f6d35f47cf

View File

@@ -520,6 +520,7 @@
spawnInitialBurst(); spawnInitialBurst();
startSpawner(); startSpawner();
} }
showGoalIntro();
}; };
const setHighlight = (body, on) => { const setHighlight = (body, on) => {
@@ -1074,11 +1075,11 @@
return null; return null;
}; };
const formatGoalMessage = (goal) => { const formatGoalMessage = (goal, { includeProgress = true } = {}) => {
if (!goal) return null; if (!goal) return null;
const title = goal.hint || goal.label || "Goal"; const title = goal.hint || goal.label || "Goal";
const pieces = [`Goal: ${title}`]; const pieces = [`Goal: ${title}`];
if (Number.isFinite(goal.progress)) { if (includeProgress && Number.isFinite(goal.progress)) {
const pct = Math.max(0, Math.min(100, Math.round(goal.progress))); const pct = Math.max(0, Math.min(100, Math.round(goal.progress)));
pieces.push(`${pct}% complete`); pieces.push(`${pct}% complete`);
} }
@@ -1109,6 +1110,25 @@
} }
}; };
const showGoalIntro = () => {
const goal = getGoalState();
const text =
config.messages?.text ||
formatGoalMessage(goal, { includeProgress: false });
if (!text) return;
const colors =
(Array.isArray(config.messages?.colors) && config.messages.colors) ||
goal?.colors ||
null;
ui.showFloatingMessage(
{ text, colors },
{
durationMs: config.messages.durationMs,
position: config.messages.position,
},
);
};
const clampBodiesIntoView = (prevWidth, prevHeight) => { const clampBodiesIntoView = (prevWidth, prevHeight) => {
const scaleX = width / (prevWidth || width); const scaleX = width / (prevWidth || width);
const scaleY = height / (prevHeight || height); const scaleY = height / (prevHeight || height);