Skip to content

Feat/continue game#961

Merged
MakinoharaShoko merged 3 commits into
OpenWebGAL:devfrom
ChangeSuger:feat/continue-game
May 27, 2026
Merged

Feat/continue game#961
MakinoharaShoko merged 3 commits into
OpenWebGAL:devfrom
ChangeSuger:feat/continue-game

Conversation

@ChangeSuger
Copy link
Copy Markdown
Contributor

#958

本提交旨在优化目前“继续游戏”功能与紧急回避存档的存储与读取逻辑,包含一下变更:

  • 新增 Enable_Continue 游戏配置项,用于控制标题页“继续游戏”按钮是否显示。
  • “继续游戏”逻辑改为读取最新的普通存档,而不是原先的读取紧急回避存档/开始游戏/回到舞台状态的逻辑。
    • “继续游戏”按钮会在无可用存档时置灰。
  • 存档数据新增 saveTimestamp 字段,用于更稳定地对存档进行排序(兼容旧存档的 saveTime 字段)。
    • 优化紧急回避存档的存储与读取逻辑,仅在非标题界面退出游戏时,保存紧急回避存档。
    • 仅在启动游戏时,检查是否有紧急回避存档,如果有,提示用户是否读取。

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request implements a 'Continue' feature and 'Fast Save' recovery logic, including timestamp-based save sorting and a prompt to restore temporary progress upon returning to the title screen. Feedback focuses on missing state updates to hide the title UI after loading a save, as well as off-by-one errors when fetching save data using the new MAX_SAVE_SIZE constant.

Comment on lines +108 to +112
onClick={() => {
if (!latestSave) return;
playSeClick();
loadGameFromStageData(latestSave);
}}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

“继续游戏”按钮逻辑中缺少了隐藏标题界面的 dispatch 调用。这会导致在加载存档数据后,标题界面仍然显示在最上层,用户无法看到游戏画面。建议添加 dispatch(setVisibility({ component: 'showTitle', visibility: false }));

Suggested change
onClick={() => {
if (!latestSave) return;
playSeClick();
loadGameFromStageData(latestSave);
}}
onClick={() => {
if (!latestSave) return;
playSeClick();
dispatch(setVisibility({ component: 'showTitle', visibility: false }));
loadGameFromStageData(latestSave);
}}

Comment thread packages/webgal/src/UI/Title/Title.tsx Outdated
Comment on lines +57 to +60
leftFunc: () => {
loadFastSaveGame();
setFastSaveLoaded(true);
},
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

与“继续游戏”按钮类似,紧急回避存档恢复对话框在用户选择“是”并加载存档时,也缺少了隐藏标题界面的逻辑。如果不隐藏标题界面,用户将无法看到恢复后的游戏内容。

        leftFunc: () => {
          dispatch(setVisibility({ component: 'showTitle', visibility: false }));
          loadFastSaveGame();
          setFastSaveLoaded(true);
        },

await getStorageAsync();
getFastSaveFromStorage();
getSavesFromStorage(0, 0);
getSavesFromStorage(0, MAX_SAVE_SIZE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

这里存在一个差一错误 (off-by-one error)。如果 MAX_SAVE_SIZE 为 200,且 getSavesFromStorage 内部使用 i <= endIndex 进行循环,则会处理 201 个存档位(0 到 200)。建议将结束索引改为 MAX_SAVE_SIZE - 1

Suggested change
getSavesFromStorage(0, MAX_SAVE_SIZE);
getSavesFromStorage(0, MAX_SAVE_SIZE - 1);

getStorage();
getFastSaveFromStorage();
getSavesFromStorage(0, 0);
getSavesFromStorage(0, MAX_SAVE_SIZE);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

同样存在差一错误 (off-by-one error)。建议将结束索引改为 MAX_SAVE_SIZE - 1 以确保只加载预期的 200 个存档位。

Suggested change
getSavesFromStorage(0, MAX_SAVE_SIZE);
getSavesFromStorage(0, MAX_SAVE_SIZE - 1);

@MakinoharaShoko MakinoharaShoko linked an issue May 23, 2026 that may be closed by this pull request
@MakinoharaShoko
Copy link
Copy Markdown
Member

许多游戏的继续游戏,是直接读取上一次退出游戏时的状态。我认为朝着这个方向实现一个随着游戏推进的自动保存是符合直觉的。如果遇到游戏结束的情况,那么我们将自动保存的存档删除,并将按钮置灰即可。

- 增加 Enable_Continue 参数,配置继续游戏按钮是否启用
- 继续游戏按钮会在没有自动存档时置灰
- 修改自动存档的记录逻辑,现在会在 end 结束时删除自动存档
@ChangeSuger ChangeSuger force-pushed the feat/continue-game branch from c02c3ab to 2a79ad3 Compare May 23, 2026 08:53
@ChangeSuger
Copy link
Copy Markdown
Contributor Author

ChangeSuger commented May 23, 2026

许多游戏的继续游戏,是直接读取上一次退出游戏时的状态。我认为朝着这个方向实现一个随着游戏推进的自动保存是符合直觉的。如果遇到游戏结束的情况,那么我们将自动保存的存档删除,并将按钮置灰即可。

已修改,目前的变更包括:

  • 增加 Enable_Continue 参数,配置“继续游戏”按钮是否启用(仅在设置 Enable_Continue:false 时隐藏按钮)
  • “继续游戏”按钮会在没有自动存档时置灰
  • 修改自动存档的记录逻辑,现在会在返回标题或者游戏中关闭游戏时保存自动存档,在通过 end 指令结束游戏时删除自动存档

@MakinoharaShoko MakinoharaShoko merged commit 643a8b9 into OpenWebGAL:dev May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

控制是否启用继续游戏功能

2 participants