mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-26 08:33:12 +09:00
Timeline support for recipe overlay
This commit is contained in:
1 parent
7db716eceb
commit
1c06611cca
1 file changed
+52
@@ -514,6 +514,35 @@ export default function CanvasMinimapPage() {
|
|||||||
|
|
||||||
setChartTagTimestamps(tagsWithTicks);
|
setChartTagTimestamps(tagsWithTicks);
|
||||||
|
|
||||||
|
// Collect recipe timestamps across visible recipe tiles
|
||||||
|
let recipeTicksAdded = 0;
|
||||||
|
for (let tileY = topTile; tileY <= bottomTile; tileY++) {
|
||||||
|
for (let tileX = leftTile; tileX <= rightTile; tileX++) {
|
||||||
|
try {
|
||||||
|
const recipeResp = await control.send(new GetRawRecipeTileRequest(
|
||||||
|
selectedInstance,
|
||||||
|
selectedSurface,
|
||||||
|
selectedForce,
|
||||||
|
tileX,
|
||||||
|
tileY
|
||||||
|
));
|
||||||
|
if (recipeResp.recipe_tile) {
|
||||||
|
const text = atob(recipeResp.recipe_tile);
|
||||||
|
const lines = text.trim().split('\n').filter(l => l.trim());
|
||||||
|
for (const line of lines) {
|
||||||
|
try {
|
||||||
|
const rec = JSON.parse(line);
|
||||||
|
if (rec.start_tick !== undefined) { allTicks.add(rec.start_tick); recipeTicksAdded++; }
|
||||||
|
if (rec.end_tick !== undefined) { allTicks.add(rec.end_tick); recipeTicksAdded++; }
|
||||||
|
} catch { /* ignore parse errors */ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn(`Failed to load recipe tile ${tileX},${tileY}:`, e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const sortedTicks = Array.from(allTicks).sort((a, b) => a - b);
|
const sortedTicks = Array.from(allTicks).sort((a, b) => a - b);
|
||||||
setAvailableTicks(sortedTicks);
|
setAvailableTicks(sortedTicks);
|
||||||
|
|
||||||
@@ -546,6 +575,7 @@ export default function CanvasMinimapPage() {
|
|||||||
tileStateCache.current.clear();
|
tileStateCache.current.clear();
|
||||||
chunkCache.current.clear();
|
chunkCache.current.clear();
|
||||||
loadingTiles.current.clear();
|
loadingTiles.current.clear();
|
||||||
|
recipeCache.current.clear();
|
||||||
};
|
};
|
||||||
|
|
||||||
const stepToTick = async (tickIndex: number) => {
|
const stepToTick = async (tickIndex: number) => {
|
||||||
@@ -558,6 +588,9 @@ export default function CanvasMinimapPage() {
|
|||||||
return; // No change needed
|
return; // No change needed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Clear recipe cache; will be repopulated for this tick
|
||||||
|
recipeCache.current.clear();
|
||||||
|
|
||||||
// Use incremental updates for loaded tiles instead of clearing cache
|
// Use incremental updates for loaded tiles instead of clearing cache
|
||||||
const updatePromises: Promise<void>[] = [];
|
const updatePromises: Promise<void>[] = [];
|
||||||
|
|
||||||
@@ -1451,6 +1484,7 @@ export default function CanvasMinimapPage() {
|
|||||||
tileStateCache.current.clear();
|
tileStateCache.current.clear();
|
||||||
chunkCache.current.clear();
|
chunkCache.current.clear();
|
||||||
loadingTiles.current.clear();
|
loadingTiles.current.clear();
|
||||||
|
recipeCache.current.clear();
|
||||||
}
|
}
|
||||||
}, [selectedInstance]);
|
}, [selectedInstance]);
|
||||||
|
|
||||||
@@ -1706,6 +1740,24 @@ export default function CanvasMinimapPage() {
|
|||||||
return () => { plugin.offRecipeUpdate(handleRecipeUpdate); };
|
return () => { plugin.offRecipeUpdate(handleRecipeUpdate); };
|
||||||
}, [control]);
|
}, [control]);
|
||||||
|
|
||||||
|
// Reload recipe overlay when timeline tick changes
|
||||||
|
useEffect(() => {
|
||||||
|
if (isTimelapseMode && currentTick !== null && showRecipes) {
|
||||||
|
// Clear existing icons
|
||||||
|
recipeCache.current.clear();
|
||||||
|
|
||||||
|
const visible = calculateVisibleTiles();
|
||||||
|
if (!visible) return;
|
||||||
|
|
||||||
|
const { leftTile, topTile, rightTile, bottomTile } = visible;
|
||||||
|
for (let ty = topTile; ty <= bottomTile; ty++) {
|
||||||
|
for (let tx = leftTile; tx <= rightTile; tx++) {
|
||||||
|
loadRecipeTile(tx, ty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, [currentTick, isTimelapseMode, showRecipes]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ padding: "20px" }}>
|
<div style={{ padding: "20px" }}>
|
||||||
<Row gutter={[16, 16]}>
|
<Row gutter={[16, 16]}>
|
||||||
|
|||||||
Reference in new issue
Block a user