rft: WpfGui重构 拆分一键长草-刷理智任务 (#11223)

This commit is contained in:
status102
2024-12-02 20:19:08 +08:00
committed by GitHub
parent fca7ad6a6a
commit c2c47cf6b7
9 changed files with 1032 additions and 1017 deletions

View File

@@ -694,9 +694,9 @@ namespace MaaWpfGui.Main
case AsstMsg.TaskChainError:
{
// 对剿灭的特殊处理,如果刷完了剿灭还选了剿灭会因为找不到入口报错
if (taskChain == "Fight" && (Instances.TaskQueueViewModel.Stage == "Annihilation"))
if (taskChain == "Fight" && (SettingsViewModel.FightTask.Stage == "Annihilation"))
{
if (Instances.TaskQueueViewModel.Stages.Any(stage => Instances.TaskQueueViewModel.IsStageOpen(stage) && (stage != "Annihilation")))
if (SettingsViewModel.FightTask.Stages.Any(stage => Instances.TaskQueueViewModel.IsStageOpen(stage) && (stage != "Annihilation")))
{
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("AnnihilationTaskFailed"), UiLogColor.Warning);
}
@@ -757,7 +757,7 @@ namespace MaaWpfGui.Main
case "Mall":
{
if (Instances.TaskQueueViewModel.Stage != string.Empty && SettingsViewModel.MallTask.CreditFightTaskEnabled)
if (SettingsViewModel.FightTask.Stage != string.Empty && SettingsViewModel.MallTask.CreditFightTaskEnabled)
{
SettingsViewModel.MallTask.LastCreditFightTaskTime = DateTime.UtcNow.ToYjDate().ToFormattedString();
Instances.TaskQueueViewModel.AddLog(LocalizationHelper.GetString("CompleteTask") + LocalizationHelper.GetString("CreditFight"));
@@ -827,7 +827,7 @@ namespace MaaWpfGui.Main
bool buyWine = _latestTaskId.ContainsKey(TaskType.Mall) && Instances.SettingsViewModel.DidYouBuyWine();
_latestTaskId.Clear();
Instances.TaskQueueViewModel.ResetFightVariables();
SettingsViewModel.FightTask.ResetFightVariables();
Instances.TaskQueueViewModel.ResetTaskSelection();
_runningState.SetIdle(true);
@@ -2015,8 +2015,8 @@ namespace MaaWpfGui.Main
taskParams["client_type"] = SettingsViewModel.GameSettings.ClientType;
taskParams["penguin_id"] = Instances.SettingsViewModel.PenguinId;
taskParams["DrGrandet"] = Instances.SettingsViewModel.IsDrGrandet;
taskParams["expiring_medicine"] = isMainFight && Instances.SettingsViewModel.UseExpiringMedicine ? 9999 : 0;
taskParams["DrGrandet"] = SettingsViewModel.FightTask.IsDrGrandet;
taskParams["expiring_medicine"] = isMainFight && SettingsViewModel.FightTask.UseExpiringMedicine ? 9999 : 0;
taskParams["server"] = Instances.SettingsViewModel.ServerType;
return taskParams;
}

View File

@@ -454,7 +454,7 @@ namespace MaaWpfGui.Services.RemoteControl
case "Settings-Stage1":
await Execute.OnUIThreadAsync(() =>
{
Instances.TaskQueueViewModel.Stage1 = data;
SettingsViewModel.FightTask.Stage1 = data;
});
break;

View File

@@ -70,6 +70,11 @@ namespace MaaWpfGui.ViewModels.UI
#region Model
/// <summary>
/// Gets 战斗任务Model
/// </summary>
public static FightSettingsUserControlModel FightTask { get; } = new();
/// <summary>
/// Gets 信用及购物任务Model
/// </summary>
@@ -422,196 +427,6 @@ namespace MaaWpfGui.ViewModels.UI
#endregion
#region
private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty);
/// <summary>
/// Gets or sets the id of PenguinStats.
/// </summary>
public string PenguinId
{
get => _penguinId;
set
{
SetAndNotify(ref _penguinId, value);
ConfigurationHelper.SetValue(ConfigurationKeys.PenguinId, value);
}
}
private bool _enablePenguin = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnablePenguin, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to enable penguin upload.
/// </summary>
public bool EnablePenguin
{
get => _enablePenguin;
set
{
SetAndNotify(ref _enablePenguin, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EnablePenguin, value.ToString());
}
}
private bool _enableYituliu = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnableYituliu, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to enable yituliu upload.
/// </summary>
public bool EnableYituliu
{
get => _enableYituliu;
set
{
SetAndNotify(ref _enableYituliu, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EnableYituliu, value.ToString());
}
}
private bool _isDrGrandet = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.IsDrGrandet, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use DrGrandet mode.
/// </summary>
public bool IsDrGrandet
{
get => _isDrGrandet;
set
{
SetAndNotify(ref _isDrGrandet, value);
ConfigurationHelper.SetValue(ConfigurationKeys.IsDrGrandet, value.ToString());
}
}
private bool _useAlternateStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseAlternateStage, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use alternate stage.
/// </summary>
public bool UseAlternateStage
{
get => _useAlternateStage;
set
{
SetAndNotify(ref _useAlternateStage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UseAlternateStage, value.ToString());
if (value)
{
HideUnavailableStage = false;
}
}
}
private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString));
public bool UseRemainingSanityStage
{
get => _useRemainingSanityStage;
set
{
SetAndNotify(ref _useRemainingSanityStage, value);
Instances.TaskQueueViewModel.UseRemainingSanityStage = value;
ConfigurationHelper.SetValue(ConfigurationKeys.UseRemainingSanityStage, value.ToString());
}
}
private bool _allowUseStoneSave = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowUseStoneSave, bool.FalseString));
public bool AllowUseStoneSave
{
get => _allowUseStoneSave;
set
{
if (value)
{
var result = MessageBoxHelper.Show(
LocalizationHelper.GetString("AllowUseStoneSaveWarning"),
LocalizationHelper.GetString("Warning"),
MessageBoxButton.YesNo,
MessageBoxImage.Warning,
no: LocalizationHelper.GetString("Confirm"),
yes: LocalizationHelper.GetString("Cancel"),
iconBrushKey: "DangerBrush");
if (result != MessageBoxResult.No)
{
return;
}
}
SetAndNotify(ref _allowUseStoneSave, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AllowUseStoneSave, value.ToString());
}
}
private bool _useExpiringMedicine = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseExpiringMedicine, bool.FalseString));
public bool UseExpiringMedicine
{
get => _useExpiringMedicine;
set
{
SetAndNotify(ref _useExpiringMedicine, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UseExpiringMedicine, value.ToString());
Instances.TaskQueueViewModel.SetFightParams();
}
}
private bool _hideUnavailableStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideUnavailableStage, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to hide unavailable stages.
/// </summary>
public bool HideUnavailableStage
{
get => _hideUnavailableStage;
set
{
SetAndNotify(ref _hideUnavailableStage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.HideUnavailableStage, value.ToString());
if (value)
{
UseAlternateStage = false;
}
Instances.TaskQueueViewModel.UpdateStageList();
}
}
private bool _hideSeries = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideSeries, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to hide series.
/// </summary>
public bool HideSeries
{
get => _hideSeries;
set
{
SetAndNotify(ref _hideSeries, value);
ConfigurationHelper.SetValue(ConfigurationKeys.HideSeries, value.ToString());
}
}
private bool _customStageCode = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomStageCode, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use custom stage code.
/// </summary>
public bool CustomStageCode
{
get => _customStageCode;
set
{
SetAndNotify(ref _customStageCode, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CustomStageCode, value.ToString());
Instances.TaskQueueViewModel.CustomStageCode = value;
}
}
#endregion
#region
/// <summary>
@@ -1124,6 +939,55 @@ namespace MaaWpfGui.ViewModels.UI
#endregion SettingsGuide
#region
private string _penguinId = ConfigurationHelper.GetValue(ConfigurationKeys.PenguinId, string.Empty);
/// <summary>
/// Gets or sets the id of PenguinStats.
/// </summary>
public string PenguinId
{
get => _penguinId;
set
{
SetAndNotify(ref _penguinId, value);
ConfigurationHelper.SetValue(ConfigurationKeys.PenguinId, value);
}
}
private bool _enablePenguin = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnablePenguin, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to enable penguin upload.
/// </summary>
public bool EnablePenguin
{
get => _enablePenguin;
set
{
SetAndNotify(ref _enablePenguin, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EnablePenguin, value.ToString());
}
}
private bool _enableYituliu = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.EnableYituliu, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to enable yituliu upload.
/// </summary>
public bool EnableYituliu
{
get => _enableYituliu;
set
{
SetAndNotify(ref _enableYituliu, value);
ConfigurationHelper.SetValue(ConfigurationKeys.EnableYituliu, value.ToString());
}
}
#endregion
#region
private enum NotifyType
@@ -1290,7 +1154,7 @@ namespace MaaWpfGui.ViewModels.UI
// EventArgs 不能省略,否则会报错
// ReSharper disable once UnusedMember.Global
// ReSharper disable once UnusedParameter.Global
public void MakeComboBoxSearchable(object sender, EventArgs e)
public static void MakeComboBoxSearchable(object sender, EventArgs e)
{
(sender as ComboBox)?.MakeComboBoxSearchable();
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,780 @@
// <copyright file="FightSettingsUserControlModel.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License v3.0 only as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY
// </copyright>
#nullable enable
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Services;
using MaaWpfGui.Utilities.ValueType;
using MaaWpfGui.ViewModels.UI;
using Stylet;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
/// <summary>
/// 刷理智
/// </summary>
public class FightSettingsUserControlModel : PropertyChangedBase
{
private ObservableCollection<CombinedData> _stageList = [];
/// <summary>
/// Gets or private sets the list of stages.
/// </summary>
public ObservableCollection<CombinedData> StageList
{
get => _stageList;
private set => SetAndNotify(ref _stageList, value);
}
private ObservableCollection<CombinedData> _remainingSanityStageList = [];
public ObservableCollection<CombinedData> RemainingSanityStageList
{
get => _remainingSanityStageList;
private set => SetAndNotify(ref _remainingSanityStageList, value);
}
/// <summary>
/// Gets the stage.
/// </summary>
public string Stage
{
get
{
Stage1 ??= _stage1Fallback;
if (!SettingsViewModel.FightTask.UseAlternateStage)
{
return Stage1;
}
if (Instances.TaskQueueViewModel.IsStageOpen(Stage1))
{
return Stage1;
}
if (Instances.TaskQueueViewModel.IsStageOpen(Stage2))
{
return Stage2;
}
return Instances.TaskQueueViewModel.IsStageOpen(Stage3) ? Stage3 : Stage1;
}
}
private readonly Dictionary<string, string> _stageDictionary = new()
{
{ "AN", "Annihilation" },
{ "剿灭", "Annihilation" },
{ "CE", "CE-6" },
{ "龙门币", "CE-6" },
{ "LS", "LS-6" },
{ "经验", "LS-6" },
{ "狗粮", "LS-6" },
{ "CA", "CA-5" },
{ "技能", "CA-5" },
{ "AP", "AP-5" },
{ "红票", "AP-5" },
{ "SK", "SK-5" },
{ "碳", "SK-5" },
{ "炭", "SK-5" },
};
/// <summary>
/// Gets or private sets the list of series.
/// </summary>
public List<string> SeriesList { get; private set; } = ["1", "2", "3", "4", "5", "6"];
public string?[] Stages => [Stage1, Stage2, Stage3];
/// <remarks>Try to fix: issues#5742. 关卡选择为 null 时的一个补丁,可能是 StageList 改变后wpf binding 延迟更新的问题。</remarks>
public string _stage1Fallback = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty;
private string? _stage1 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage1, string.Empty) ?? string.Empty;
/// <summary>
/// Gets or sets the stage1.
/// </summary>
public string? Stage1
{
get => _stage1;
set
{
if (_stage1 == value)
{
SetAndNotify(ref _stage1, value);
return;
}
if (CustomStageCode)
{
// 从后往前删
if (_stage1?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
}
SetAndNotify(ref _stage1, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.Stage1, value);
Instances.TaskQueueViewModel.UpdateDatePrompt();
}
}
private string _stage2 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage2, string.Empty) ?? string.Empty;
/// <summary>
/// Gets or sets the stage2.
/// </summary>
public string Stage2
{
get => _stage2;
set
{
if (_stage2 == value)
{
SetAndNotify(ref _stage2, value);
return;
}
if (CustomStageCode)
{
if (_stage2?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
}
SetAndNotify(ref _stage2, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.Stage2, value);
Instances.TaskQueueViewModel.UpdateDatePrompt();
}
}
private string _stage3 = ConfigurationHelper.GetValue(ConfigurationKeys.Stage3, string.Empty) ?? string.Empty;
/// <summary>
/// Gets or sets the stage2.
/// </summary>
public string Stage3
{
get => _stage3;
set
{
if (_stage3 == value)
{
SetAndNotify(ref _stage3, value);
return;
}
if (CustomStageCode)
{
if (_stage3?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
}
SetAndNotify(ref _stage3, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.Stage3, value);
Instances.TaskQueueViewModel.UpdateDatePrompt();
}
}
private bool _useRemainingSanityStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseRemainingSanityStage, bool.TrueString));
public bool UseRemainingSanityStage
{
get => _useRemainingSanityStage;
set => SetAndNotify(ref _useRemainingSanityStage, value);
}
private bool _customStageCode = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomStageCode, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use custom stage code.
/// </summary>
public bool CustomStageCode
{
get => _customStageCode;
set => SetAndNotify(ref _customStageCode, value);
}
private string _remainingSanityStage = ConfigurationHelper.GetValue(ConfigurationKeys.RemainingSanityStage, string.Empty) ?? string.Empty;
public string RemainingSanityStage
{
get => _remainingSanityStage;
set
{
if (_remainingSanityStage == value)
{
SetAndNotify(ref _remainingSanityStage, value);
return;
}
if (CustomStageCode)
{
if (_remainingSanityStage?.Length != 3 && value != null)
{
value = ToUpperAndCheckStage(value);
}
}
SetAndNotify(ref _remainingSanityStage, value);
Instances.TaskQueueViewModel.SetFightRemainingSanityParams();
ConfigurationHelper.SetValue(ConfigurationKeys.RemainingSanityStage, value);
}
}
/// <summary>
/// Reset unsaved battle parameters.
/// </summary>
public void ResetFightVariables()
{
if (UseStoneWithNull == null)
{
UseStone = false;
}
if (UseMedicineWithNull == null)
{
UseMedicine = false;
}
if (HasTimesLimitedWithNull == null)
{
HasTimesLimited = false;
}
if (IsSpecifiedDropsWithNull == null)
{
IsSpecifiedDrops = false;
}
}
private bool? _useMedicineWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use medicine with null.
/// </summary>
public bool? UseMedicineWithNull
{
get => _useMedicineWithNull;
set
{
SetAndNotify(ref _useMedicineWithNull, value);
if (value == false)
{
UseStone = false;
}
Instances.TaskQueueViewModel.SetFightParams();
value ??= false;
ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicine, value.ToString());
}
}
/// <summary>
/// Gets or sets a value indicating whether to use medicine.
/// </summary>
public bool UseMedicine
{
get => UseMedicineWithNull != false;
set => UseMedicineWithNull = value;
}
private string _medicineNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicineQuantity, "999");
/// <summary>
/// Gets or sets the amount of medicine used.
/// </summary>
public string MedicineNumber
{
get => _medicineNumber;
set
{
if (_medicineNumber == value)
{
return;
}
SetAndNotify(ref _medicineNumber, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.UseMedicineQuantity, MedicineNumber);
}
}
public static string UseStoneString => LocalizationHelper.GetString("UseOriginitePrime");
private bool? _useStoneWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseMedicine, bool.FalseString)) &&
Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseStone, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use originiums with null.
/// </summary>
public bool? UseStoneWithNull
{
get => _useStoneWithNull;
set
{
if (!SettingsViewModel.FightTask.AllowUseStoneSave && value == true)
{
value = null;
}
SetAndNotify(ref _useStoneWithNull, value);
if (value != false)
{
MedicineNumber = "999";
if (!UseMedicine)
{
UseMedicineWithNull = value;
}
}
// IsEnabled="{c:Binding UseStone}"
NotifyOfPropertyChange(nameof(UseStone));
Instances.TaskQueueViewModel.SetFightParams();
if (SettingsViewModel.FightTask.AllowUseStoneSave)
{
ConfigurationHelper.SetValue(ConfigurationKeys.UseStone, (value ?? false).ToString());
}
}
}
/// <summary>
/// Gets or sets a value indicating whether to use originiums.
/// </summary>
// ReSharper disable once MemberCanBePrivate.Global
public bool UseStone
{
get => UseStoneWithNull != false;
set => UseStoneWithNull = value;
}
private string _stoneNumber = ConfigurationHelper.GetValue(ConfigurationKeys.UseStoneQuantity, "0");
/// <summary>
/// Gets or sets the amount of originiums used.
/// </summary>
public string StoneNumber
{
get => _stoneNumber;
set
{
if (_stoneNumber == value)
{
return;
}
SetAndNotify(ref _stoneNumber, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.UseStoneQuantity, StoneNumber);
}
}
private bool? _hasTimesLimitedWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimited, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether the number of times is limited with null.
/// </summary>
public bool? HasTimesLimitedWithNull
{
get => _hasTimesLimitedWithNull;
set
{
SetAndNotify(ref _hasTimesLimitedWithNull, value);
Instances.TaskQueueViewModel.SetFightParams();
value ??= false;
ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimited, value.ToString());
}
}
/// <summary>
/// Gets or sets a value indicating whether the number of times is limited.
/// </summary>
public bool HasTimesLimited
{
get => HasTimesLimitedWithNull != false;
set => HasTimesLimitedWithNull = value;
}
private string _maxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.TimesLimitedQuantity, "5");
/// <summary>
/// Gets or sets the max number of times.
/// </summary>
public string MaxTimes
{
get => _maxTimes;
set
{
if (MaxTimes == value)
{
return;
}
SetAndNotify(ref _maxTimes, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.TimesLimitedQuantity, MaxTimes);
}
}
private string _series = ConfigurationHelper.GetValue(ConfigurationKeys.SeriesQuantity, "1");
/// <summary>
/// Gets or sets the max number of times.
/// </summary>
// 所以为啥这玩意是 string 呢?改配置的时候把上面那些也都改成 int 吧
public string Series
{
get => _series;
set
{
if (_series == value)
{
return;
}
SetAndNotify(ref _series, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.SeriesQuantity, value);
}
}
#region Drops
private bool? _isSpecifiedDropsWithNull = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.DropsEnable, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether the drops are specified.
/// </summary>
public bool? IsSpecifiedDropsWithNull
{
get => _isSpecifiedDropsWithNull;
set
{
SetAndNotify(ref _isSpecifiedDropsWithNull, value);
Instances.TaskQueueViewModel.SetFightParams();
value ??= false;
ConfigurationHelper.SetValue(ConfigurationKeys.DropsEnable, value.ToString());
}
}
/// <summary>
/// Gets or sets a value indicating whether the drops are specified.
/// </summary>
public bool IsSpecifiedDrops
{
get => IsSpecifiedDropsWithNull != false;
set => IsSpecifiedDropsWithNull = value;
}
/// <summary>
/// Gets the list of all drops.
/// </summary>
private List<CombinedData> AllDrops { get; } = new();
/// <summary>
/// 关卡不可掉落的材料
/// </summary>
private static readonly HashSet<string> _excludedValues =
[
"3213", "3223", "3233", "3243", // 双芯片
"3253", "3263", "3273", "3283", // 双芯片
"7001", "7002", "7003", "7004", // 许可
"4004", "4005", // 凭证
"3105", "3131", "3132", "3233", // 龙骨/加固建材
"6001", // 演习券
"3141", "4002", // 源石
"32001", // 芯片助剂
"30115", // 聚合剂
"30125", // 双极纳米片
"30135", // D32钢
"30145", // 晶体电子单元
"30155", // 烧结核凝晶
];
public void InitDrops()
{
foreach (var (val, value) in ItemListHelper.ArkItems)
{
// 不是数字的东西都是正常关卡不会掉的(大概吧)
if (!int.TryParse(val, out _))
{
continue;
}
var dis = value.Name;
if (_excludedValues.Contains(val))
{
continue;
}
AllDrops.Add(new CombinedData { Display = dis, Value = val });
}
AllDrops.Sort((a, b) => string.Compare(a.Value, b.Value, StringComparison.Ordinal));
DropsList = new ObservableCollection<CombinedData>(AllDrops);
}
/// <summary>
/// Gets or private sets the list of drops.
/// </summary>
public ObservableCollection<CombinedData> DropsList { get; private set; }
private string _dropsItemId = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemId, string.Empty);
/// <summary>
/// Gets or sets the item ID of drops.
/// </summary>
public string DropsItemId
{
get => _dropsItemId;
set
{
SetAndNotify(ref _dropsItemId, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemId, DropsItemId);
}
}
private string _dropsItemName = ConfigurationHelper.GetValue(ConfigurationKeys.DropsItemName, LocalizationHelper.GetString("NotSelected"));
/// <summary>
/// Gets or sets the item Name of drops.
/// </summary>
public string DropsItemName
{
get => _dropsItemName;
set
{
SetAndNotify(ref _dropsItemName, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.DropsItemName, DropsItemName);
}
}
// UI 绑定的方法
// ReSharper disable once UnusedMember.Global
public void DropsListDropDownClosed()
{
foreach (var item in DropsList)
{
if (DropsItemName != item.Display)
{
continue;
}
DropsItemId = item.Value;
if (DropsItemName != item.Display || DropsItemId != item.Value)
{
DropsItemName = LocalizationHelper.GetString("NotSelected");
}
return;
}
DropsItemName = LocalizationHelper.GetString("NotSelected");
}
private string _dropsQuantity = ConfigurationHelper.GetValue(ConfigurationKeys.DropsQuantity, "5");
/// <summary>
/// Gets or sets the quantity of drops.
/// </summary>
public string DropsQuantity
{
get => _dropsQuantity;
set
{
SetAndNotify(ref _dropsQuantity, value);
Instances.TaskQueueViewModel.SetFightParams();
ConfigurationHelper.SetValue(ConfigurationKeys.DropsQuantity, DropsQuantity);
}
}
#endregion Drops
private bool _isDrGrandet = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.IsDrGrandet, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use DrGrandet mode.
/// </summary>
public bool IsDrGrandet
{
get => _isDrGrandet;
set
{
SetAndNotify(ref _isDrGrandet, value);
ConfigurationHelper.SetValue(ConfigurationKeys.IsDrGrandet, value.ToString());
}
}
private bool _useAlternateStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseAlternateStage, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to use alternate stage.
/// </summary>
public bool UseAlternateStage
{
get => _useAlternateStage;
set
{
SetAndNotify(ref _useAlternateStage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UseAlternateStage, value.ToString());
if (value)
{
HideUnavailableStage = false;
}
}
}
private bool _allowUseStoneSave = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.AllowUseStoneSave, bool.FalseString));
public bool AllowUseStoneSave
{
get => _allowUseStoneSave;
set
{
if (value)
{
var result = MessageBoxHelper.Show(
LocalizationHelper.GetString("AllowUseStoneSaveWarning"),
LocalizationHelper.GetString("Warning"),
MessageBoxButton.YesNo,
MessageBoxImage.Warning,
no: LocalizationHelper.GetString("Confirm"),
yes: LocalizationHelper.GetString("Cancel"),
iconBrushKey: "DangerBrush");
if (result != MessageBoxResult.No)
{
return;
}
}
SetAndNotify(ref _allowUseStoneSave, value);
ConfigurationHelper.SetValue(ConfigurationKeys.AllowUseStoneSave, value.ToString());
}
}
private bool _useExpiringMedicine = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.UseExpiringMedicine, bool.FalseString));
public bool UseExpiringMedicine
{
get => _useExpiringMedicine;
set
{
SetAndNotify(ref _useExpiringMedicine, value);
ConfigurationHelper.SetValue(ConfigurationKeys.UseExpiringMedicine, value.ToString());
Instances.TaskQueueViewModel.SetFightParams();
}
}
private bool _hideUnavailableStage = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideUnavailableStage, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to hide unavailable stages.
/// </summary>
public bool HideUnavailableStage
{
get => _hideUnavailableStage;
set
{
SetAndNotify(ref _hideUnavailableStage, value);
ConfigurationHelper.SetValue(ConfigurationKeys.HideUnavailableStage, value.ToString());
if (value)
{
UseAlternateStage = false;
}
Instances.TaskQueueViewModel.UpdateStageList();
}
}
private bool _hideSeries = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.HideSeries, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to hide series.
/// </summary>
public bool HideSeries
{
get => _hideSeries;
set
{
SetAndNotify(ref _hideSeries, value);
ConfigurationHelper.SetValue(ConfigurationKeys.HideSeries, value.ToString());
}
}
private string ToUpperAndCheckStage(string value)
{
if (string.IsNullOrEmpty(value))
{
return value;
}
string upperValue = value.ToUpper();
if (_stageDictionary.TryGetValue(upperValue, out var stage))
{
return stage;
}
if (StageList == null)
{
return value;
}
foreach (var item in StageList)
{
if (upperValue == item.Value.ToUpper() || upperValue == item.Display.ToUpper())
{
return item.Value;
}
}
return value;
}
#region
private bool _customInfrastPlanShowInFightSettings = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, bool.FalseString));
public bool CustomInfrastPlanShowInFightSettings
{
get => _customInfrastPlanShowInFightSettings;
set
{
SetAndNotify(ref _customInfrastPlanShowInFightSettings, value);
ConfigurationHelper.SetValue(ConfigurationKeys.CustomInfrastPlanShowInFightSettings, value.ToString());
}
}
#endregion
}

View File

@@ -240,7 +240,7 @@
PanningMode="Both"
VerticalScrollBarVisibility="Auto">
<hc:SimpleStackPanel Width="220" Margin="0,0,10,0">
<userControl:FightSettingsUserControl Visibility="{c:Binding TaskSettingVisibilities.Combat}" />
<taskQueue:FightSettingsUserControl DataContext="{Binding TaskSettingDataContext.FightTask}" Visibility="{c:Binding DataContext.TaskSettingVisibilities.Combat, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}" />
<userControl:AutoRecruitSettingsUserControl
s:View.ActionTarget="{Binding DataContext, RelativeSource={RelativeSource Self}}"
DataContext="{Binding TaskSettingDataContext}"

View File

@@ -1,5 +1,5 @@
<UserControl
x:Class="MaaWpfGui.Views.UserControl.FightSettingsUserControl"
x:Class="MaaWpfGui.Views.UserControl.TaskQueue.FightSettingsUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:c="clr-namespace:CalcBinding;assembly=CalcBinding"
@@ -9,12 +9,16 @@
xmlns:helper="clr-namespace:MaaWpfGui.Helper"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:setting="clr-namespace:MaaWpfGui.ViewModels.UI"
xmlns:taskQueue="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
d:DataContext="{d:DesignInstance {x:Type ui:TaskQueueViewModel}}"
d:Background="White"
d:DataContext="{d:DesignInstance {x:Type taskQueue:FightSettingsUserControlModel}}"
d:DesignWidth="220"
s:View.ActionTarget="{Binding}"
mc:Ignorable="d">
<StackPanel>
<Grid Visibility="{c:Binding !TaskSettingVisibilities.EnableAdvancedSettings}">
<Grid Visibility="{c:Binding !EnableAdvancedSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
@@ -42,7 +46,7 @@
Height="30"
Margin="6"
VerticalContentAlignment="Center"
Content="{c:Binding 'UseStoneString + (TaskSettingDataContext.AllowUseStoneSave ? &quot;&quot; : &quot;*&quot;)'}"
Content="{c:Binding 'UseStoneString + (AllowUseStoneSave ? &quot;&quot; : &quot;*&quot;)'}"
IsChecked="{Binding UseStoneWithNull}"
MouseRightButtonUp="{s:Action ToggleCheckBoxNullOnRightClick,
Target={x:Type helper:CheckBoxHelper}}"
@@ -124,7 +128,8 @@
IsEditable="True"
IsTextSearchEnabled="False"
ItemsSource="{Binding DropsList}"
Loaded="{s:Action MakeComboBoxSearchable}"
Loaded="{s:Action MakeComboBoxSearchable,
Target={x:Type setting:SettingsViewModel}}"
SelectedValue="{Binding DropsItemId}"
SelectedValuePath="Value"
Text="{Binding DropsItemName}" />
@@ -141,7 +146,7 @@
Value="{Binding DropsQuantity, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</Grid>
<Grid Grid.Row="2" Visibility="{c:Binding !TaskSettingDataContext.HideSeries}">
<Grid Grid.Row="2" Visibility="{c:Binding !HideSeries}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
@@ -162,7 +167,8 @@
Height="30"
Margin="6"
VerticalContentAlignment="Center"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding SeriesList}"
SelectedValue="{Binding Series}" />
</StackPanel>
@@ -182,7 +188,7 @@
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid>
<Grid Height="42" Visibility="{c:Binding TaskSettingDataContext.UseAlternateStage}">
<Grid Height="42" Visibility="{c:Binding UseAlternateStage}">
<controls:TextBlock
Margin="6"
HorizontalAlignment="Center"
@@ -191,7 +197,7 @@
TextAlignment="Center"
TextWrapping="Wrap" />
</Grid>
<Grid Height="42" Visibility="{c:Binding TaskSettingDataContext.UseAlternateStage}">
<Grid Height="42" Visibility="{c:Binding UseAlternateStage}">
<!-- a placeholder -->
<controls:TextBlock
Margin="6"
@@ -221,20 +227,22 @@
Margin="6"
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding StageList}"
SelectedValue="{Binding Stage1}"
SelectedValuePath="Value" />
<StackPanel
IsEnabled="{c:Binding TaskSettingDataContext.UseAlternateStage}"
IsEnabled="{c:Binding UseAlternateStage}"
Orientation="Vertical"
Visibility="{c:Binding TaskSettingDataContext.UseAlternateStage}">
Visibility="{c:Binding UseAlternateStage}">
<ComboBox
Height="30"
Margin="6"
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding StageList}"
SelectedValue="{Binding Stage2}"
SelectedValuePath="Value" />
@@ -243,7 +251,8 @@
Margin="6"
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding StageList}"
SelectedValue="{Binding Stage3}"
SelectedValuePath="Value" />
@@ -254,7 +263,8 @@
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsEnabled="{c:Binding UseRemainingSanityStage}"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding RemainingSanityStageList}"
SelectedValue="{Binding RemainingSanityStage}"
SelectedValuePath="Value"
@@ -269,25 +279,28 @@
Height="30"
Margin="6"
VerticalContentAlignment="Center"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
Text="{Binding Stage1, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{DynamicResource CustomStageCodeTip}" />
<StackPanel
IsEnabled="{c:Binding TaskSettingDataContext.UseAlternateStage}"
IsEnabled="{c:Binding UseAlternateStage}"
Orientation="Vertical"
Visibility="{c:Binding TaskSettingDataContext.UseAlternateStage}">
Visibility="{c:Binding UseAlternateStage}">
<TextBox
Height="30"
Margin="6"
VerticalContentAlignment="Center"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
Text="{Binding Stage2, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{DynamicResource CustomStageCodeTip}" />
<TextBox
Height="30"
Margin="6"
VerticalContentAlignment="Center"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
Text="{Binding Stage3, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{DynamicResource CustomStageCodeTip}" />
</StackPanel>
@@ -296,14 +309,15 @@
Margin="6"
VerticalContentAlignment="Center"
IsEnabled="{c:Binding UseRemainingSanityStage}"
IsHitTestVisible="{c:Binding !FightTaskRunning}"
IsHitTestVisible="{c:Binding !FightTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
Text="{Binding RemainingSanityStage, UpdateSourceTrigger=PropertyChanged}"
ToolTip="{DynamicResource UseRemainingSanityStageTip}"
Visibility="{c:Binding UseRemainingSanityStage}" />
</StackPanel>
</StackPanel>
</Grid>
<Grid Grid.Row="4" Visibility="{c:Binding 'CustomInfrastEnabled and TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings'}">
<Grid Grid.Row="4" Visibility="{c:Binding 'CustomInfrastEnabled and TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings', Source={x:Static helper:Instances.TaskQueueViewModel}}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" MinWidth="100" />
<ColumnDefinition />
@@ -325,18 +339,16 @@
Margin="6"
VerticalContentAlignment="Center"
DisplayMemberPath="Display"
IsHitTestVisible="{c:Binding !InfrastTaskRunning}"
ItemsSource="{Binding CustomInfrastPlanList}"
SelectedValue="{Binding CustomInfrastPlanIndex}"
IsHitTestVisible="{c:Binding !InfrastTaskRunning,
Source={x:Static helper:Instances.TaskQueueViewModel}}"
ItemsSource="{Binding CustomInfrastPlanList, Source={x:Static helper:Instances.TaskQueueViewModel}}"
SelectedValue="{Binding CustomInfrastPlanIndex, Source={x:Static helper:Instances.TaskQueueViewModel}}"
SelectedValuePath="Value" />
</StackPanel>
</Grid>
</Grid>
<StackPanel
s:View.ActionTarget="{Binding DataContext, RelativeSource={RelativeSource Self}}"
DataContext="{Binding TaskSettingDataContext}"
Visibility="{c:Binding TaskSettingVisibilities.EnableAdvancedSettings}">
<StackPanel Visibility="{c:Binding EnableAdvancedSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}">
<CheckBox
Margin="0,10"
Content="{DynamicResource DrGrandet}"
@@ -377,22 +389,23 @@
<CheckBox
Margin="0,10"
Content="{DynamicResource CustomInfrastPlanShowInFightSettings}"
IsChecked="{Binding TaskSettingVisibilities.CustomInfrastPlanShowInFightSettings}" />
IsChecked="{Binding CustomInfrastPlanShowInFightSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}" />
<CheckBox
Margin="0,10"
Content="{DynamicResource EnablePenguin}"
IsChecked="{Binding EnablePenguin}" />
<TextBox
IsChecked="{Binding EnablePenguin, Source={x:Static helper:Instances.SettingsViewModel}}" />
<hc:TextBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource PenguinId}"
InputMethod.IsInputMethodEnabled="False"
Style="{StaticResource TextBoxExtend}"
Text="{Binding PenguinId}"
Visibility="{c:Binding EnablePenguin}" />
Text="{Binding PenguinId, Source={x:Static helper:Instances.SettingsViewModel}}"
Visibility="{c:Binding EnablePenguin,
Source={x:Static helper:Instances.SettingsViewModel}}" />
<CheckBox
Margin="0,10"
Content="{DynamicResource EnableYituliu}"
IsChecked="{Binding EnableYituliu}" />
IsChecked="{Binding EnableYituliu, Source={x:Static helper:Instances.SettingsViewModel}}" />
</StackPanel>
</StackPanel>
</UserControl>

View File

@@ -16,7 +16,7 @@ using System.Windows;
using System.Windows.Input;
using MaaWpfGui.Helper;
namespace MaaWpfGui.Views.UserControl
namespace MaaWpfGui.Views.UserControl.TaskQueue
{
/// <summary>
/// ParamSettingUserControl.xaml 的交互逻辑

View File

@@ -70,7 +70,7 @@
IsTextSearchEnabled="False"
ItemsSource="{Binding RoguelikeCoreCharList}"
Loaded="{s:Action MakeComboBoxSearchable,
Target={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
Target={x:Type setting:SettingsViewModel}}"
ToolTip="{DynamicResource StartingCoreCharTip}">
<hc:ComboBox.Text>
<Binding Path="RoguelikeCoreChar" UpdateSourceTrigger="PropertyChanged">