diff --git a/PCL.Core/App/Localization/Languages/en-US.xaml b/PCL.Core/App/Localization/Languages/en-US.xaml index 43250bafb..2c001c31c 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 4834027e9..4583c6e92 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)