feat(timeline): 结局金色浮层(重新观看 + 回到上一个选择)
播到结局时在镜头下方弹金色星标浮层:显示结局文案/成败/奖励 + 两个按钮—— 「⟲ 重新观看」从头再播、「↶ 回到上一个选择」跳回最近分支点(位置重放正确)直接试另一条。 记录最近 choice/random/fight 节点供回跳;纯线性到结局则只显示重新观看。
This commit is contained in:
@ -219,7 +219,7 @@
|
||||
}
|
||||
|
||||
// ===================== 状态 & 挂载 =====================
|
||||
let S, model, playT = 0, playing = false, rafId = 0, lastTs = 0, stageCv, stageCtx, els = {}, pending = null, selNode = null, PX = 80, fitMode = false;
|
||||
let S, model, playT = 0, playing = false, rafId = 0, lastTs = 0, stageCv, stageCtx, els = {}, pending = null, selNode = null, PX = 80, fitMode = false, lastDecisionId = null;
|
||||
|
||||
const TEMPLATE =
|
||||
'<div class="tl-stagepanel">' +
|
||||
@ -309,7 +309,7 @@
|
||||
}
|
||||
// 从指定节点开始:先重放途中走位算进入位置,再从该节点构建演出。
|
||||
function startFrom(targetId, autoplay) {
|
||||
stopPlay(); hideChoices(); clearSelection();
|
||||
stopPlay(); hideChoices(); clearSelection(); lastDecisionId = null;
|
||||
const path = pathTo(S, targetId);
|
||||
S.entryPos = path ? replayPositions(S, path) : {};
|
||||
resetAccum(S);
|
||||
@ -436,6 +436,7 @@
|
||||
|
||||
// ---- 选项浮层(镜头下方)----
|
||||
function showChoices(node, kind) {
|
||||
lastDecisionId = node.id; // 记录最近分支点,供结局「回到上一个选择」
|
||||
const box = els.choices; box.innerHTML = "";
|
||||
let q, opts;
|
||||
if (kind === "fight") {
|
||||
@ -483,8 +484,28 @@
|
||||
}
|
||||
}
|
||||
function onReachEnd() {
|
||||
if (pending && (pending.kind === "choice" || pending.kind === "choice_once" || pending.kind === "fight" || pending.kind === "random"))
|
||||
if (!pending) return;
|
||||
if (pending.kind === "choice" || pending.kind === "choice_once" || pending.kind === "fight" || pending.kind === "random")
|
||||
showChoices(pending.node, pending.kind);
|
||||
else if (pending.kind === "ending")
|
||||
showEnding(pending.node);
|
||||
}
|
||||
function grantText(g) {
|
||||
if (g.kind === "银两") return "银两" + (g.value > 0 ? "+" : "") + g.value;
|
||||
if (g.kind === "道具") return "道具" + g.item + "×" + g.value;
|
||||
if (g.kind === "友好度") return S.nm(g.target) + " 友好+" + g.value;
|
||||
if (g.kind === "入门") return S.nm(g.target) + " 入门";
|
||||
return g.kind;
|
||||
}
|
||||
function showEnding(node) {
|
||||
const box = els.choices; box.innerHTML = "";
|
||||
const res = { success: "成功", fail: "失败", end: "中性" }[node.result || "success"];
|
||||
const grants = (node.grants && node.grants.length) ? " 奖励:" + node.grants.map(grantText).join(",") : "";
|
||||
box.appendChild(Object.assign(document.createElement("div"), { className: "tl-choices-q tl-ending-q", textContent: "★ 结局:" + (node.summary || node.id) + "(" + res + ")" + grants }));
|
||||
const mk = (txt, fn) => { const b = document.createElement("button"); b.className = "tl-choice-btn tl-ending-btn"; b.textContent = txt; b.onclick = fn; box.appendChild(b); };
|
||||
mk("⟲ 重新观看", () => startFrom(firstNode(S.IR), true));
|
||||
if (lastDecisionId && S.nodes[lastDecisionId]) mk("↶ 回到上一个选择", () => startFrom(lastDecisionId, true));
|
||||
box.classList.remove("hidden");
|
||||
}
|
||||
function tick(ts) {
|
||||
if (!playing) return;
|
||||
|
||||
Reference in New Issue
Block a user