mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-16 01:40:46 +08:00
perf: 优化客户端切换逻辑,官服B服切换无需重载
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user