not bad
This commit is contained in:
parent
2741b93dea
commit
434f07cc4e
103 changed files with 8387 additions and 8152 deletions
35
js/restore_coordinator.js
Normal file
35
js/restore_coordinator.js
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
"use strict";
|
||||
|
||||
(function (global) {
|
||||
const Snapshot = global.TarinaiSnapshot;
|
||||
if (!Snapshot) throw new Error("TarinaiSnapshot is not available for restore_coordinator.js");
|
||||
|
||||
function renderWorldAfterRestore(worldRef = global.world) {
|
||||
if (!worldRef) return;
|
||||
if (typeof renderLog === "function") renderLog(worldRef.logs || []);
|
||||
if (typeof resetArchiveRenderState === "function") resetArchiveRenderState();
|
||||
if (typeof renderArchive === "function") renderArchive();
|
||||
if (typeof renderSelected === "function") renderSelected();
|
||||
if (typeof renderStats === "function") renderStats();
|
||||
if (typeof render === "function") render();
|
||||
if (typeof syncTopButtons === "function") syncTopButtons();
|
||||
}
|
||||
|
||||
function syncRestoreDependents(worldRef = global.world, context = {}) {
|
||||
global.TarinaiFreezeSystem?.afterWorldRestored?.(worldRef, context);
|
||||
worldRef?.emit?.("ui:restore-sync", { source: context.source || "restore" });
|
||||
renderWorldAfterRestore(worldRef);
|
||||
}
|
||||
|
||||
function restoreSnapshot(snapshot, worldRef = global.world, options = {}) {
|
||||
const result = Snapshot.restoreSnapshot(snapshot, worldRef);
|
||||
if (options.syncUi !== false) syncRestoreDependents(worldRef, { source: options.source || "snapshot", snapshotVersion: result?.snapshotVersion || Snapshot.version });
|
||||
return result;
|
||||
}
|
||||
|
||||
global.TarinaiRestoreCoordinator = {
|
||||
restoreSnapshot,
|
||||
syncRestoreDependents,
|
||||
renderWorldAfterRestore,
|
||||
};
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue