fix: custom base plan selection.

fix #8125
This commit is contained in:
uye
2024-02-02 18:48:41 +08:00
parent 434f1797f5
commit d945c21d71
2 changed files with 20 additions and 7 deletions

View File

@@ -1675,6 +1675,17 @@ namespace MaaWpfGui.ViewModels.UI
SetAndNotify(ref _customInfrastFile, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastFile, value);
Instances.TaskQueueViewModel.RefreshCustomInfrastPlan();
// SetAndNotify 在值没有变化时不会触发 PropertyChanged 事件,所以这里手动触发一下
var index = Instances.TaskQueueViewModel.CustomInfrastPlanIndex;
var count = Instances.TaskQueueViewModel.CustomInfrastPlanList.Count;
Instances.TaskQueueViewModel.NeedAddCustomInfrastPlanInfo = false;
{
Instances.TaskQueueViewModel.CustomInfrastPlanIndex = (index + 1) % count;
Instances.TaskQueueViewModel.CustomInfrastPlanIndex = index;
}
Instances.TaskQueueViewModel.NeedAddCustomInfrastPlanInfo = true;
}
}
@@ -3165,15 +3176,15 @@ namespace MaaWpfGui.ViewModels.UI
ConnectAddress = addresses.First();
break;
case > 1:
{
foreach (var address in addresses.Where(address => address != "emulator-5554"))
{
ConnectAddress = address;
foreach (var address in addresses.Where(address => address != "emulator-5554"))
{
ConnectAddress = address;
break;
}
break;
}
break;
}
}
if (ConnectAddress.Length == 0)

View File

@@ -2514,6 +2514,8 @@ namespace MaaWpfGui.ViewModels.UI
}
}
public bool NeedAddCustomInfrastPlanInfo { get; set; } = true;
private int _customInfrastPlanIndex = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanIndex, "0"));
public int CustomInfrastPlanIndex
@@ -2521,7 +2523,7 @@ namespace MaaWpfGui.ViewModels.UI
get => _customInfrastPlanIndex;
set
{
if (value != _customInfrastPlanIndex)
if (value != _customInfrastPlanIndex && NeedAddCustomInfrastPlanInfo)
{
var plan = CustomInfrastPlanInfoList[value];
AddLog(plan.Name, UiLogColor.Message);