Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions PCL.Core/App/Localization/Languages/en-US.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@
<sys:String x:Key="Instance.Install.NoExtraInstall">No extra installation</sys:String>
<sys:String x:Key="Instance.Install.Reset.Message">You are resetting the current instance.&#xA;PCL CE will re-download the files required for this instance from the internet and reinstall mod loaders (if any).&#xA;This operation will not lose your saves, mods, resource packs, etc.</sys:String>
<sys:String x:Key="Instance.Install.Reset.Title">Reset this instance</sys:String>
<sys:String x:Key="Instance.Install.ToolTip.GameRunning">Cannot change the version while the game is running</sys:String>

<!-- Instance.Export -->

Expand Down
1 change: 1 addition & 0 deletions PCL.Core/App/Localization/Languages/zh-CN.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@
<sys:String x:Key="Instance.Install.NoExtraInstall">无附加安装</sys:String>
<sys:String x:Key="Instance.Install.Reset.Message">你正在重置当前实例。&#xA;PCL CE 将会重新联网下载该实例所需的文件,并重新安装模组加载器(如有)。&#xA;此操作不会丢失你的存档、模组、资源包等。</sys:String>
<sys:String x:Key="Instance.Install.Reset.Title">重置此实例</sys:String>
<sys:String x:Key="Instance.Install.ToolTip.GameRunning">无法在游戏运行期间更改版本</sys:String>

<!-- Instance.Export -->

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
</Grid>
<local:MyCard HorizontalAlignment="Center" VerticalAlignment="Center" Margin="40,0" SnapsToDevicePixels="True"
x:Name="PanLoad" UseAnimation="False">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Comment thread
xianhongtao marked this conversation as resolved.
PageLoaderInit(LoadMinecraft, PanLoad, PanAllBack, null, ModDownload.dlClientListLoader, _ => GetCurrentInfo());
LoadOptiFine.StateChanged += (_, _, _) => { OptiFine_Loaded(); ReloadSelected(); };
Expand Down Expand Up @@ -96,6 +98,18 @@ private void Init()

#region 安装

/// <summary>
/// 根据游戏运行状态刷新"开始修改/重置"按钮的可用性。
/// 游戏运行期间禁止修改或重置实例(防止文件被游戏占用导致崩溃),
/// 并显示提示 Tooltip。
/// </summary>
private void _RefreshStartButtonState()
{
var blockedByGame = ModVideoBack.IsGaming;
BtnSelectStart.IsEnabled = !blockedByGame;
Comment thread
xianhongtao marked this conversation as resolved.
Comment thread
xianhongtao marked this conversation as resolved.
BtnSelectStart.ToolTip = blockedByGame ? Lang.Text("Instance.Install.ToolTip.GameRunning") : null;
}

private void BtnSelectStart_Click(object sender, MouseButtonEventArgs mouseButtonEventArgs)
{
// Quilt 实例无法通过安装管线重装/修改(已移除 Quilt 安装支持)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down