Skip to content

fix: 游戏运行期间禁用 实例修改与重置 按钮避免启动器崩溃 - #3497

Open
xianhongtao wants to merge 1 commit into
PCL-Community:devfrom
xianhongtao:xianhongtao/issue3494
Open

fix: 游戏运行期间禁用 实例修改与重置 按钮避免启动器崩溃#3497
xianhongtao wants to merge 1 commit into
PCL-Community:devfrom
xianhongtao:xianhongtao/issue3494

Conversation

@xianhongtao

@xianhongtao xianhongtao commented Aug 4, 2026

Copy link
Copy Markdown

Generated by DeepSeek V4 Flash 0731 using VSCode Github Copilot Chat.

游戏运行时修改游戏版本会导致启动器崩溃
#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:

  • Disable the instance modification/reset start button when the game is running to prevent crashes caused by modifying files in use.

Enhancements:

  • Introduce centralized logic to update the start button state and tooltip based on current game running status.

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:

  • Prevent launcher crashes by disabling the instance modification/reset start button when the game is running.

Enhancements:

  • Centralize the logic that updates the instance modification/reset button state and tooltip based on the current game running status.

Copilot AI lite review requested due to automatic review settings August 4, 2026 07:39
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 size: S PR 大小评估:小型 labels Aug 4, 2026
@sourcery-ai

sourcery-ai Bot commented Aug 4, 2026

Copy link
Copy Markdown
Contributor
审阅者指南(在小型 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
Loading

文件级改动

变更 详情 文件
将实例安装“开始修改/重置”操作的按钮启用/禁用逻辑集中管理,并与游戏运行状态关联。
  • 在 LoaderInit 中注册 GamingStateChanged 事件处理程序,以便在游戏运行状态变化时刷新启动按钮状态。
  • 引入私有辅助方法 _RefreshStartButtonState,从 ModVideoBack.IsGaming 派生 blockedByGame,按需切换 BtnSelectStart.IsEnabled,并在被阻止时设置本地化工具提示。
  • 用对 _RefreshStartButtonState 的调用替代 ReloadSelected 和 GetCurrentInfo 中直接赋值 BtnSelectStart.IsEnabled = true,以确保行为一致。
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs
更新 UI 和本地化配置,以在启动按钮被禁用时反映该状态,并在游戏运行时显示解释性工具提示。
  • 调整 PageInstanceInstall.xaml 中的绑定/模板,使启动按钮和工具提示与新的 _RefreshStartButtonState 逻辑集成。
  • 为在游戏运行时用作工具提示的字符串 "Instance.Install.ToolTip.GameRunning" 添加或更新 zh-CN 和 en-US 的本地化条目。
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml
PCL.Core/App/Localization/Languages/en-US.xaml
PCL.Core/App/Localization/Languages/zh-CN.xaml

针对关联 Issue 的评估

Issue 目标 是否解决 说明
#3494 当用户在游戏运行中(文件被占用)尝试修改或重置游戏实例时,防止启动器崩溃。

可能关联的 Issue


提示与命令

与 Sourcery 交互

  • 触发新审阅: 在 pull request 上评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审阅评论。
  • 从审阅评论生成 GitHub Issue: 在审阅评论下回复,请求 Sourcery 从该评论创建一个 Issue。你也可以回复 @sourcery-ai issue 来从该评论创建 Issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写上 @sourcery-ai,即可随时生成标题。你也可以在 pull request 上评论 @sourcery-ai title 以(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文的任意位置写上 @sourcery-ai summary,即可在你想要的位置生成 PR 摘要。你也可以在 pull request 上评论 @sourcery-ai summary 以(重新)生成摘要。
  • 生成审阅者指南: 在 pull request 上评论 @sourcery-ai guide,即可随时(重新)生成审阅者指南。
  • 一次性解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve,即可将所有 Sourcery 评论标记为已解决。如果你已处理所有评论且不想再看到它们,这会很有用。
  • 一次性忽略所有 Sourcery 审阅: 在 pull request 上评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审阅。若你想重新开始一轮新的审阅,这尤其有用 —— 记得之后再评论 @sourcery-ai review 触发新审阅!

自定义你的体验

访问你的 控制台 可以:

  • 启用或禁用审阅特性,如 Sourcery 生成的 pull request 摘要、审阅者指南等。
  • 更改审阅语言。
  • 添加、删除或编辑自定义审阅指令。
  • 调整其他审阅设置。

获取帮助

Original review guide in English
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Disables 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 changes

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
Loading

File-Level Changes

Change Details Files
Centralize and hook button enable/disable logic to game running state for the instance install "start modify/reset" action.
  • Register a GamingStateChanged event handler in LoaderInit to refresh the start button state when game run state changes.
  • Introduce a private _RefreshStartButtonState helper that derives blockedByGame from ModVideoBack.IsGaming, toggles BtnSelectStart.IsEnabled accordingly, and sets a localized tooltip when blocked.
  • Replace direct BtnSelectStart.IsEnabled = true assignments in ReloadSelected and GetCurrentInfo with calls to _RefreshStartButtonState to ensure consistent behavior.
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs
Update UI and localization to reflect disabled start button and show an explanatory tooltip when a game is running.
  • Adjust PageInstanceInstall.xaml bindings/templates so the start button and tooltip integrate with the new _RefreshStartButtonState logic.
  • Add or update zh-CN and en-US localization entries for the "Instance.Install.ToolTip.GameRunning" string used as the tooltip when the game is running.
Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml
PCL.Core/App/Localization/Languages/en-US.xaml
PCL.Core/App/Localization/Languages/zh-CN.xaml

Assessment against linked issues

Issue Objective Addressed Explanation
#3494 Prevent the launcher from crashing when the user attempts to modify or reset a game instance while the game is running (files in use).

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

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.

你好 —— 我在这里给了一些总体反馈:

  • 建议在适当的销毁/卸载路径中取消订阅 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.

Sourcery 对开源项目是免费的——如果你觉得我们的代码审查有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈不断改进代码审查质量。
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 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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Copilot AI left a comment

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.

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.

Comment thread PCL.Core/App/Localization/Languages/en-US.xaml
Comment thread PCL.Core/App/Localization/Languages/zh-CN.xaml
@pcl-ce-automation pcl-ce-automation Bot added size: M PR 大小评估:中型 and removed size: S PR 大小评估:小型 labels Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

Comment thread Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs Outdated
@pcl-ce-automation pcl-ce-automation Bot added size: S PR 大小评估:小型 and removed size: M PR 大小评估:中型 labels Aug 4, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 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".

@LuLu-ling LuLu-ling linked an issue Aug 4, 2026 that may be closed by this pull request
4 tasks
@xianhongtao
xianhongtao marked this pull request as draft August 5, 2026 04:18
@pcl-ce-automation pcl-ce-automation Bot added 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 and removed 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 labels Aug 5, 2026
@xianhongtao

Copy link
Copy Markdown
Author

要不我直接改成游戏运行时禁用实例设置按钮吧?

@Pigeon0v0

Copy link
Copy Markdown
Contributor

还真有人这么做啊...

我建议是禁用修改实例相关功能就行了,如果你想涉及其他部分的话得把边界做得比较细(比如 Mod 管理只禁用会修改 Mod 的按钮)

@Chiloven945 Chiloven945 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

请严格遵守 技术规范 重新修整你的 PR:

  1. PR 中的所有 Commit 必须要附带有效的、已验证的签名。参考 提交信息规范-提交签名要求 章节与 GPG 签名配置指南
  2. 如果使用了任意 AI 工具,应该在 PR 提交信息或者 Commit 信息内注明使用的模型、工具信息等。参考 项目开发规范-AI 工具使用规范 章节。

@xianhongtao

Copy link
Copy Markdown
Author

请严格遵守 技术规范 重新修整你的 PR:

  1. PR 中的所有 Commit 必须要附带有效的、已验证的签名。参考 提交信息规范-提交签名要求 章节与 GPG 签名配置指南
  2. 如果使用了任意 AI 工具,应该在 PR 提交信息或者 Commit 信息内注明使用的模型、工具信息等。参考 项目开发规范-AI 工具使用规范 章节。

您好,确认一下,我可以使用SSH签名吗?
我的工作流有SSH密钥管理工具没有GPG密钥管理工具,强制使用GPG会增加密钥管理负担并增加安全风险,我希望使用SSH密钥来签名。

@Pigeon0v0

Copy link
Copy Markdown
Contributor

您好,确认一下,我可以使用SSH签名吗?

可以,只需要 GitHub 中你的 Commit 显示为 Verified 就行

@xianhongtao
xianhongtao force-pushed the xianhongtao/issue3494 branch 2 times, most recently from 2b9259a to d1ca6de Compare August 5, 2026 07:39
@xianhongtao
xianhongtao force-pushed the xianhongtao/issue3494 branch from d1ca6de to fcbfe1d Compare August 5, 2026 07:48
@xianhongtao
xianhongtao marked this pull request as ready for review August 5, 2026 07:52
@pcl-ce-automation pcl-ce-automation Bot added 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查 and removed 🚧 正在处理 开发人员正在对该内容进行开发、测试或修复,进展中 labels Aug 5, 2026

@sourcery-ai sourcery-ai Bot left a comment

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.

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.

Sourcery 对开源项目免费——如果你觉得我们的代码评审有帮助,欢迎分享 ✨
帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据这些反馈持续改进为你提供的代码评审。
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 _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.
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.

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@MoYuan-CN
MoYuan-CN requested a review from Chiloven945 August 5, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: S PR 大小评估:小型 🛠️ 等待审查 Pull Request 已完善,等待维护者或负责人进行代码审查

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[C#]: 游戏运行时修改游戏版本会导致启动器崩溃

4 participants