Skip to content

Feat/continue game#961

Open
ChangeSuger wants to merge 3 commits into
OpenWebGAL:devfrom
ChangeSuger:feat/continue-game
Open

Feat/continue game#961
ChangeSuger wants to merge 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 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);

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.

1 participant