- ${Utils.t("waitingInit")}
+ ${Utils.t("initMessage")}
@@ -3273,43 +3300,63 @@
}
updateStats = async () => {
- if (!state.imageLoaded) return; // Only show stats if image is loaded
+ // Check if the bot has been initialized by checking for colors
+ if (!state.colorsChecked) {
+ statsArea.innerHTML = `
+
+
${Utils.t("initMessage")}
+
`;
+ return;
+ }
- const { charges, cooldown } = await WPlaceService.getCharges()
- state.currentCharges = Math.floor(charges)
- state.cooldown = cooldown
+ const { charges, cooldown } = await WPlaceService.getCharges();
+ state.currentCharges = Math.floor(charges);
+ state.cooldown = cooldown;
- const progress = state.totalPixels > 0 ? Math.round((state.paintedPixels / state.totalPixels) * 100) : 0
- const remainingPixels = state.totalPixels - state.paintedPixels
+ // --- Generate HTML for Image-Specific Stats ---
+ let imageStatsHTML = '';
+ if (state.imageLoaded) {
+ const progress = state.totalPixels > 0 ? Math.round((state.paintedPixels / state.totalPixels) * 100) : 0;
+ const remainingPixels = state.totalPixels - state.paintedPixels;
+ state.estimatedTime = Utils.calculateEstimatedTime(remainingPixels, state.currentCharges, state.cooldown);
+ progressBar.style.width = `${progress}%`;
- state.estimatedTime = Utils.calculateEstimatedTime(remainingPixels, state.currentCharges, state.cooldown)
+ imageStatsHTML = `
+
+
${Utils.t("progress")}
+
${progress}%
+
+
+
${Utils.t("pixels")}
+
${state.paintedPixels}/${state.totalPixels}
+
+
+
${Utils.t("estimatedTime")}
+
${Utils.formatTime(state.estimatedTime)}
+
+ `;
+ }
- progressBar.style.width = `${progress}%`
+ // --- Generate HTML for Available Colors ---
+ const colorSwatchesHTML = state.availableColors.map(color => {
+ const rgbString = `rgb(${color.rgb.join(',')})`;
+ return `
`;
+ }).join('');
+ // --- Combine all stats and update the panel ---
statsArea.innerHTML = `
-
-
${Utils.t("progress")}
-
${progress}%
-
-
-
${Utils.t("pixels")}
-
${state.paintedPixels}/${state.totalPixels}
-
+ ${imageStatsHTML}
${Utils.t("charges")}
${Math.floor(state.currentCharges)}
- ${
- state.imageLoaded
- ? `
-
-
${Utils.t("estimatedTime")}
-
${Utils.formatTime(state.estimatedTime)}
+
+
Available Colors
+
+ ${colorSwatchesHTML}
+
- `
- : ""
- }
- `
+ `;
}
// Helper function to update data management buttons