diff --git a/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs b/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs index 8e7882e448..467c9f8494 100644 --- a/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs +++ b/src/MaaWpfGui/ViewModels/UserControl/Settings/GameSettingsUserControlModel.cs @@ -15,6 +15,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Threading.Tasks; using MaaWpfGui.Constants; using MaaWpfGui.Helper; using MaaWpfGui.States; @@ -86,16 +87,43 @@ public class GameSettingsUserControlModel : PropertyChangedBase set { - SetAndNotify(ref _clientType, value); + var oldValue = _clientType; + if (!SetAndNotify(ref _clientType, value)) + { + return; + } + ConfigurationHelper.SetValue(ConfigurationKeys.ClientType, value); VersionUpdateSettings.ResourceInfoUpdate(); Instances.TaskQueueViewModel.UpdateStageList(); Instances.TaskQueueViewModel.UpdateDatePrompt(); - Instances.AsstProxy.LoadResource(); - SettingsViewModel.AskRestartToApplySettings(_clientType is "YoStarEN"); + + if (!NeedRestartAfterClientTypeChange(oldValue, value)) + { + return; + } + + Task.Run(() => + { + Instances.AsstProxy.LoadResource(); + }); + + SettingsViewModel.AskRestartToApplySettings(value is "YoStarEN"); } } + private static bool NeedRestartAfterClientTypeChange(string oldType, string newType) + { + if (string.IsNullOrEmpty(oldType) || oldType == newType) + { + return false; + } + + // 官服 <-> B服 之间切换不需要重启 + return (oldType != "Official" || newType != "Bilibili") && + (oldType != "Bilibili" || newType != "Official"); + } + private bool _deploymentWithPause = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RoguelikeDeploymentWithPause, bool.FalseString)); public bool DeploymentWithPause