From fcbfe1da2c38a6e2b672e62c93eb3985533b92d6 Mon Sep 17 00:00:00 2001 From: xianhongtao Date: Wed, 5 Aug 2026 15:37:59 +0800 Subject: [PATCH] =?UTF-8?q?fix(instance-install):=20=E6=B8=B8=E6=88=8F?= =?UTF-8?q?=E8=BF=90=E8=A1=8C=E6=9C=9F=E9=97=B4=E7=A6=81=E7=94=A8=E5=AE=9E?= =?UTF-8?q?=E4=BE=8B=E4=BF=AE=E6=94=B9=E4=B8=8E=E9=87=8D=E7=BD=AE=E6=8C=89?= =?UTF-8?q?=E9=92=AE=E9=81=BF=E5=85=8D=E5=B4=A9=E6=BA=83=20[DeepSeek-V4-Fl?= =?UTF-8?q?ash-0731]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PCL.Core/App/Localization/Languages/en-US.xaml | 1 + PCL.Core/App/Localization/Languages/zh-CN.xaml | 1 + .../PageInstance/PageInstanceInstall.xaml | 3 ++- .../PageInstance/PageInstanceInstall.xaml.cs | 18 ++++++++++++++++-- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/PCL.Core/App/Localization/Languages/en-US.xaml b/PCL.Core/App/Localization/Languages/en-US.xaml index c090e7a13..747344308 100644 --- a/PCL.Core/App/Localization/Languages/en-US.xaml +++ b/PCL.Core/App/Localization/Languages/en-US.xaml @@ -799,6 +799,7 @@ No extra installation You are resetting the current instance. PCL CE will re-download the files required for this instance from the internet and reinstall mod loaders (if any). This operation will not lose your saves, mods, resource packs, etc. Reset this instance + Cannot change the version while the game is running diff --git a/PCL.Core/App/Localization/Languages/zh-CN.xaml b/PCL.Core/App/Localization/Languages/zh-CN.xaml index 9bae29f93..22931f4b7 100644 --- a/PCL.Core/App/Localization/Languages/zh-CN.xaml +++ b/PCL.Core/App/Localization/Languages/zh-CN.xaml @@ -799,6 +799,7 @@ 无附加安装 你正在重置当前实例。 PCL CE 将会重新联网下载该实例所需的文件,并重新安装模组加载器(如有)。 此操作不会丢失你的存档、模组、资源包等。 重置此实例 + 无法在游戏运行期间更改版本 diff --git a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml index 1d658d7f2..d0505f839 100644 --- a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml +++ b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml @@ -400,7 +400,8 @@ Click="BtnSelectStart_Click" HorizontalAlignment="Center" VerticalAlignment="Bottom" IsEnabled="False" LogoScale="0.95" - SvgIcon="lucide/download" /> + SvgIcon="lucide/download" + ToolTipService.ShowOnDisabled="True" /> diff --git a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs index fe5e3e0b2..1545ca0f8 100644 --- a/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs +++ b/Plain Craft Launcher 2/Pages/PageInstance/PageInstanceInstall.xaml.cs @@ -36,6 +36,8 @@ public PageInstanceInstall() private void LoaderInit() { disabledPageAnimControls.Add(BtnSelectStart); + // 游戏运行期间禁用"开始修改/重置"按钮(防止文件被游戏占用导致崩溃 #3494) + ModVideoBack.GamingStateChanged += (_, _) => ModBase.RunInUi(_RefreshStartButtonState); // PageLoaderInit(LoadMinecraft, PanLoad, PanBack, Nothing, DlClientListLoader, AddressOf LoadMinecraft_OnFinish) PageLoaderInit(LoadMinecraft, PanLoad, PanAllBack, null, ModDownload.dlClientListLoader, _ => GetCurrentInfo()); LoadOptiFine.StateChanged += (_, _, _) => { OptiFine_Loaded(); ReloadSelected(); }; @@ -96,6 +98,18 @@ private void Init() #region 安装 + /// + /// 根据游戏运行状态刷新"开始修改/重置"按钮的可用性。 + /// 游戏运行期间禁止修改或重置实例(防止文件被游戏占用导致崩溃), + /// 并显示提示 Tooltip。 + /// + private void _RefreshStartButtonState() + { + var blockedByGame = ModVideoBack.IsGaming; + BtnSelectStart.IsEnabled = !blockedByGame; + BtnSelectStart.ToolTip = blockedByGame ? Lang.Text("Instance.Install.ToolTip.GameRunning") : null; + } + private void BtnSelectStart_Click(object sender, MouseButtonEventArgs mouseButtonEventArgs) { // Quilt 实例无法通过安装管线重装/修改(已移除 Quilt 安装支持) @@ -442,7 +456,7 @@ private void ReloadSelected() // 主预览 ItemSelect.Title = PageInstanceLeft.McInstance.Name; ItemSelect.Logo = GetSelectLogo(); - BtnSelectStart.IsEnabled = true; + _RefreshStartButtonState(); if ((selectedInfo ?? "") == (currentInfo ?? "")) { ItemSelect.Info = selectedInfo; @@ -1034,7 +1048,7 @@ private object GetCurrentOptiFabric() public void GetCurrentInfo() { ClearSelected(); - BtnSelectStart.IsEnabled = true; + _RefreshStartButtonState(); var currentInstance = PageInstanceLeft.McInstance.Info; _vanillaName = currentInstance.VanillaName; if (currentInstance.HasLiteLoader)