fix: 游戏运行期间禁用 实例修改与重置 按钮避免启动器崩溃 - #3497
Conversation
审阅者指南(在小型 PR 上折叠)审阅者指南通过集中管理按钮状态逻辑并将其与启动器的“游戏运行中”状态关联,在游戏会话运行时禁用实例修改/重置的启动按钮;同时添加本地化的工具提示文本和 XAML 绑定,以告知用户按钮被禁用的原因。 当游戏运行状态变化时更新启动按钮的时序图sequenceDiagram
participant ModVideoBack
participant PageInstanceInstall
participant BtnSelectStart
ModVideoBack->>PageInstanceInstall: GamingStateChanged
activate PageInstanceInstall
PageInstanceInstall->>PageInstanceInstall: _RefreshStartButtonState()
PageInstanceInstall->>PageInstanceInstall: blockedByGame = ModVideoBack.IsGaming
alt [game is running]
PageInstanceInstall->>BtnSelectStart: IsEnabled = false
PageInstanceInstall->>BtnSelectStart: ToolTip = Lang.Text(Instance.Install.ToolTip.GameRunning)
else [game not running]
PageInstanceInstall->>BtnSelectStart: IsEnabled = true
PageInstanceInstall->>BtnSelectStart: ToolTip = null
end
deactivate PageInstanceInstall
文件级改动
针对关联 Issue 的评估
可能关联的 Issue
提示与命令与 Sourcery 交互
自定义你的体验访问你的 控制台 可以:
获取帮助Original review guide in EnglishReviewer's guide (collapsed on small PRs)Reviewer's GuideDisables the instance modification/reset start button while a game session is running by centralizing button state logic and wiring it to the launcher’s game-running status, plus adds localized tooltip text and XAML bindings to inform the user why the button is disabled. Sequence diagram for updating start button when game running state changessequenceDiagram
participant ModVideoBack
participant PageInstanceInstall
participant BtnSelectStart
ModVideoBack->>PageInstanceInstall: GamingStateChanged
activate PageInstanceInstall
PageInstanceInstall->>PageInstanceInstall: _RefreshStartButtonState()
PageInstanceInstall->>PageInstanceInstall: blockedByGame = ModVideoBack.IsGaming
alt [game is running]
PageInstanceInstall->>BtnSelectStart: IsEnabled = false
PageInstanceInstall->>BtnSelectStart: ToolTip = Lang.Text(Instance.Install.ToolTip.GameRunning)
else [game not running]
PageInstanceInstall->>BtnSelectStart: IsEnabled = true
PageInstanceInstall->>BtnSelectStart: ToolTip = null
end
deactivate PageInstanceInstall
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
你好 —— 我在这里给了一些总体反馈:
- 建议在适当的销毁/卸载路径中取消订阅
ModVideoBack.GamingStateChanged(例如在 dispose/unload 中),以避免在页面生命周期中如果LoaderInit可能被多次调用时造成潜在的事件处理器泄漏。 - 建议在初始化阶段(
LoaderInit之后)调用一次_RefreshStartButtonState(),这样开始按钮的可用状态和提示信息就能立即反映当前的IsGaming状态,而不是只能在ReloadSelected/GetCurrentInfo或状态变化事件之后才更新。
面向 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- Consider unsubscribing from `ModVideoBack.GamingStateChanged` (e.g., in a dispose/unload path) to avoid potential handler leaks if `LoaderInit` can be called multiple times during the page’s lifecycle.
- It may be clearer to call `_RefreshStartButtonState()` once during initialization (after `LoaderInit`) so the button’s enabled state and tooltip immediately reflect the current `IsGaming` state, not only after `ReloadSelected`/`GetCurrentInfo` or a state change event.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈不断改进代码审查质量。
Original comment in English
Hey - I've left some high level feedback:
- Consider unsubscribing from
ModVideoBack.GamingStateChanged(e.g., in a dispose/unload path) to avoid potential handler leaks ifLoaderInitcan be called multiple times during the page’s lifecycle. - It may be clearer to call
_RefreshStartButtonState()once during initialization (afterLoaderInit) so the button’s enabled state and tooltip immediately reflect the currentIsGamingstate, not only afterReloadSelected/GetCurrentInfoor a state change event.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider unsubscribing from `ModVideoBack.GamingStateChanged` (e.g., in a dispose/unload path) to avoid potential handler leaks if `LoaderInit` can be called multiple times during the page’s lifecycle.
- It may be clearer to call `_RefreshStartButtonState()` once during initialization (after `LoaderInit`) so the button’s enabled state and tooltip immediately reflect the current `IsGaming` state, not only after `ReloadSelected`/`GetCurrentInfo` or a state change event.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a38ae95a0d
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Pull request overview
此 PR 针对 #3494:在游戏运行期间修改/重置实例可能触发文件占用(IOException)并导致启动器崩溃的问题,通过在实例安装/修改页面中基于“游戏是否正在运行”的状态禁用“开始修改/重置”按钮来规避该崩溃路径。
Changes:
- 在
PageInstanceInstall中新增集中化方法,根据ModVideoBack.IsGaming刷新“开始修改/重置”按钮可用性与 Tooltip。 - 监听游戏运行状态变化事件,在状态变化时刷新按钮状态。
- 为禁用状态下的按钮开启 Tooltip 展示,并补充中英文本地化提示语。
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs | 新增并接入按钮状态刷新逻辑,监听游戏运行状态变化以禁用修改/重置入口 |
| Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml | 允许按钮在禁用状态下仍可显示 Tooltip |
| PCL.Core/App/Localization/Languages/zh-CN.xaml | 新增“游戏运行期间不可操作”的提示语资源键 |
| PCL.Core/App/Localization/Languages/en-US.xaml | 新增“game running”提示语资源键 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 2065e55b95
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ba01b871c3
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
|
要不我直接改成游戏运行时禁用实例设置按钮吧? |
|
还真有人这么做啊... 我建议是禁用修改实例相关功能就行了,如果你想涉及其他部分的话得把边界做得比较细(比如 Mod 管理只禁用会修改 Mod 的按钮) |
Chiloven945
left a comment
There was a problem hiding this comment.
请严格遵守 技术规范 重新修整你的 PR:
- PR 中的所有 Commit 必须要附带有效的、已验证的签名。参考 提交信息规范-提交签名要求 章节与 GPG 签名配置指南。
- 如果使用了任意 AI 工具,应该在 PR 提交信息或者 Commit 信息内注明使用的模型、工具信息等。参考 项目开发规范-AI 工具使用规范 章节。
您好,确认一下,我可以使用SSH签名吗? |
可以,只需要 GitHub 中你的 Commit 显示为 Verified 就行 |
2b9259a to
d1ca6de
Compare
d1ca6de to
fcbfe1d
Compare
There was a problem hiding this comment.
Hey - 我在这里给出了一些高层次的反馈:
- 请考虑在相应的卸载/释放(unload/dispose)处理程序中取消订阅
ModVideoBack.GamingStateChanged,以避免在该页面被多次创建/销毁时可能出现的事件处理器泄漏问题。 - 私有方法
_RefreshStartButtonState的命名风格与该代码库中典型的 C# 私有方法命名不太一致;将其名称(例如改为RefreshStartButtonState)与现有约定保持一致,可以让文件风格更加统一。
供 AI Agents 使用的提示
Please address the comments from this code review:
## Overall Comments
- Consider unsubscribing from `ModVideoBack.GamingStateChanged` (e.g., in a corresponding unload/dispose handler) to avoid potential event handler leaks if this page is created/destroyed multiple times.
- The private method `_RefreshStartButtonState` uses a different naming style than typical C# private methods in this codebase; aligning the name (e.g., `RefreshStartButtonState`) with existing conventions will keep the file consistent.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈持续改进为你提供的代码评审。
Original comment in English
Hey - I've left some high level feedback:
- Consider unsubscribing from
ModVideoBack.GamingStateChanged(e.g., in a corresponding unload/dispose handler) to avoid potential event handler leaks if this page is created/destroyed multiple times. - The private method
_RefreshStartButtonStateuses a different naming style than typical C# private methods in this codebase; aligning the name (e.g.,RefreshStartButtonState) with existing conventions will keep the file consistent.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider unsubscribing from `ModVideoBack.GamingStateChanged` (e.g., in a corresponding unload/dispose handler) to avoid potential event handler leaks if this page is created/destroyed multiple times.
- The private method `_RefreshStartButtonState` uses a different naming style than typical C# private methods in this codebase; aligning the name (e.g., `RefreshStartButtonState`) with existing conventions will keep the file consistent.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
游戏运行时修改游戏版本会导致启动器崩溃
#3494 反应了在游戏运行期间修改实例设置会导致启动器崩溃。
本更改修改了 实例设置 -> 修改 页面最下方的 开始修改 / 开始重置 按钮,使游戏运行期间该按钮被禁用,避免了游戏运行期间修改游戏版本。
AI生成代码逻辑清晰,本人审查认为不需要人工重构。已通过所有测试,已实际启动测试确认。
Summary by Sourcery
防止在游戏会话运行期间修改或重置实例,以避免启动器崩溃。
Bug 修复:
增强功能:
Original summary in English
Summary by Sourcery
Prevent instance modification and reset while a game session is running to avoid launcher crashes.
Bug Fixes:
Enhancements:
Summary by Sourcery
在游戏会话运行期间禁用实例修改/重置操作,以防止启动器崩溃。
Bug 修复:
增强:
Original summary in English
Summary by Sourcery
Disable instance modification/reset actions while a game session is running to prevent launcher crashes.
Bug Fixes:
Enhancements: