rft: WpfGui重构 拆分一键长草-公招任务 (#11311)

This commit is contained in:
status102
2024-12-08 14:53:29 +08:00
committed by GitHub
parent 9b2400040f
commit 74aa188bd4
8 changed files with 425 additions and 389 deletions

View File

@@ -1324,7 +1324,7 @@ namespace MaaWpfGui.Main
case "RecruitSpecialTag":
{
string special = subTaskDetails!["tag"]!.ToString();
if (special == "支援机械" && Instances.SettingsViewModel.NotChooseLevel1 == false)
if (special == "支援机械" && SettingsViewModel.RecruitTask.NotChooseLevel1 == false)
{
break;
}

View File

@@ -176,8 +176,6 @@ namespace MaaWpfGui.ViewModels.UI
}
}
public static SettingsViewModel RecruitSettingDataContext => Instances.SettingsViewModel;
private bool _recruitCaught;
/// <summary>
@@ -221,7 +219,7 @@ namespace MaaWpfGui.ViewModels.UI
levelList.Add(6);
}
Instances.AsstProxy.AsstStartRecruitCalc(levelList.ToArray(), RecruitAutoSetTime, RecruitSettingDataContext.ChooseLevel3Time, RecruitSettingDataContext.ChooseLevel4Time, RecruitSettingDataContext.ChooseLevel5Time);
Instances.AsstProxy.AsstStartRecruitCalc(levelList.ToArray(), RecruitAutoSetTime, SettingsViewModel.RecruitTask.ChooseLevel3Time, SettingsViewModel.RecruitTask.ChooseLevel4Time, SettingsViewModel.RecruitTask.ChooseLevel5Time);
}
private bool _recruitmentShowPotential = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitmentShowPotential, bool.TrueString));

View File

@@ -75,6 +75,11 @@ namespace MaaWpfGui.ViewModels.UI
/// </summary>
public static FightSettingsUserControlModel FightTask { get; } = new();
/// <summary>
/// Gets 招募任务Model
/// </summary>
public static RecruitSettingsUserControlModel RecruitTask { get; } = new();
/// <summary>
/// Gets 信用及购物任务Model
/// </summary>
@@ -427,360 +432,6 @@ namespace MaaWpfGui.ViewModels.UI
#endregion
#region
/// <summary>
/// Gets the list of auto recruit selecting extra tags.
/// </summary>
public List<CombinedData> AutoRecruitSelectExtraTagsList { get; } =
[
new() { Display = LocalizationHelper.GetString("DefaultNoExtraTags"), Value = "0" },
new() { Display = LocalizationHelper.GetString("SelectExtraTags"), Value = "1" },
new() { Display = LocalizationHelper.GetString("SelectExtraOnlyRareTags"), Value = "2" },
];
private static readonly List<string> _autoRecruitTagList = ["近战位", "远程位", "先锋干员", "近卫干员", "狙击干员", "重装干员", "医疗干员", "辅助干员", "术师干员", "治疗", "费用回复", "输出", "生存", "群攻", "防护", "减速",];
private static readonly Lazy<List<CombinedData>> _autoRecruitTagShowList = new(() =>
_autoRecruitTagList.Select<string, (string, string)?>(tag => DataHelper.RecruitTags.TryGetValue(tag, out var value) ? value : null)
.Where(tag => tag is not null)
.Cast<(string Display, string Client)>()
.Select(tag => new CombinedData() { Display = tag.Display, Value = tag.Client })
.ToList());
public static List<CombinedData> AutoRecruitTagShowList
{
get => _autoRecruitTagShowList.Value;
}
private object[] _autoRecruitFirstList = ConfigurationHelper
.GetValue(ConfigurationKeys.AutoRecruitFirstList, string.Empty)
.Split(';')
.Select(tag => _autoRecruitTagShowList.Value.FirstOrDefault(i => i.Value == tag))
.Where(tag => tag is not null)
.Cast<CombinedData>()
.ToArray();
public object[] AutoRecruitFirstList
{
get => _autoRecruitFirstList;
set
{
SetAndNotify(ref _autoRecruitFirstList, value);
var config = string.Join(';', value.Cast<CombinedData>().Select(i => i.Value));
ConfigurationHelper.SetValue(ConfigurationKeys.AutoRecruitFirstList, config);
}
}
private string _recruitMaxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.RecruitMaxTimes, "4");
/// <summary>
/// Gets or sets the maximum times of recruit.
/// </summary>
public string RecruitMaxTimes
{
get => _recruitMaxTimes;
set
{
SetAndNotify(ref _recruitMaxTimes, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitMaxTimes, value);
}
}
private bool _refreshLevel3 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RefreshLevel3, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to refresh level 3.
/// </summary>
public bool RefreshLevel3
{
get => _refreshLevel3;
set
{
SetAndNotify(ref _refreshLevel3, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RefreshLevel3, value.ToString());
}
}
private bool _forceRefresh = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.ForceRefresh, bool.TrueString));
/// <summary>
/// Gets or Sets a value indicating whether to refresh when recruit permit ran out.
/// </summary>
public bool ForceRefresh
{
get => _forceRefresh;
set
{
SetAndNotify(ref _forceRefresh, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ForceRefresh, value.ToString());
}
}
private bool _useExpedited;
/// <summary>
/// Gets or sets a value indicating whether to use expedited.
/// </summary>
public bool UseExpedited
{
get => _useExpedited;
set => SetAndNotify(ref _useExpedited, value);
}
private string _selectExtraTags = ConfigurationHelper.GetValue(ConfigurationKeys.SelectExtraTags, "0");
/// <summary>
/// Gets or sets a value indicating three tags are always selected or select only rare tags as many as possible .
/// </summary>
public string SelectExtraTags
{
get
{
if (int.TryParse(_selectExtraTags, out _))
{
return _selectExtraTags;
}
var value = "0";
if (bool.TryParse(_selectExtraTags, out bool boolValue))
{
value = boolValue ? "1" : "0";
}
SetAndNotify(ref _selectExtraTags, value);
ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
return value;
}
set
{
SetAndNotify(ref _selectExtraTags, value);
ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
}
}
private bool _notChooseLevel1 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.NotChooseLevel1, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether not to choose level 1.
/// </summary>
public bool NotChooseLevel1
{
get => _notChooseLevel1;
set
{
SetAndNotify(ref _notChooseLevel1, value);
ConfigurationHelper.SetValue(ConfigurationKeys.NotChooseLevel1, value.ToString());
}
}
private bool _chooseLevel3 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel3, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 3.
/// </summary>
public bool ChooseLevel3
{
get => _chooseLevel3;
set
{
SetAndNotify(ref _chooseLevel3, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel3, value.ToString());
}
}
private bool _chooseLevel4 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel4, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 4.
/// </summary>
public bool ChooseLevel4
{
get => _chooseLevel4;
set
{
SetAndNotify(ref _chooseLevel4, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel4, value.ToString());
}
}
private bool _chooseLevel5 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel5, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 5.
/// </summary>
public bool ChooseLevel5
{
get => _chooseLevel5;
set
{
SetAndNotify(ref _chooseLevel5, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel5, value.ToString());
}
}
private int _chooseLevel3Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540")) / 60;
public int ChooseLevel3Hour
{
get => _chooseLevel3Hour;
set
{
if (!SetAndNotify(ref _chooseLevel3Hour, value))
{
return;
}
ChooseLevel3Time = (value * 60) + ChooseLevel3Min;
}
}
private int _chooseLevel3Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540")) % 60) / 10 * 10;
public int ChooseLevel3Min
{
get => _chooseLevel3Min;
set
{
if (!SetAndNotify(ref _chooseLevel3Min, value))
{
return;
}
ChooseLevel3Time = (ChooseLevel3Hour * 60) + value;
}
}
private int _chooseLevel3Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540"));
public int ChooseLevel3Time
{
get => _chooseLevel3Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel3Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel3Time, value.ToString());
SetAndNotify(ref _chooseLevel3Hour, value / 60, nameof(ChooseLevel3Hour));
SetAndNotify(ref _chooseLevel3Min, value % 60, nameof(ChooseLevel3Min));
}
}
private int _chooseLevel4Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540")) / 60;
public int ChooseLevel4Hour
{
get => _chooseLevel4Hour;
set
{
if (!SetAndNotify(ref _chooseLevel4Hour, value))
{
return;
}
ChooseLevel4Time = (value * 60) + ChooseLevel4Min;
}
}
private int _chooseLevel4Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540")) % 60) / 10 * 10;
public int ChooseLevel4Min
{
get => _chooseLevel4Min;
set
{
if (!SetAndNotify(ref _chooseLevel4Min, value))
{
return;
}
ChooseLevel4Time = (ChooseLevel4Hour * 60) + value;
}
}
private int _chooseLevel4Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540"));
public int ChooseLevel4Time
{
get => _chooseLevel4Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel4Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel4Time, value.ToString());
SetAndNotify(ref _chooseLevel4Hour, value / 60, nameof(ChooseLevel4Hour));
SetAndNotify(ref _chooseLevel4Min, value % 60, nameof(ChooseLevel4Min));
}
}
private int _chooseLevel5Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540")) / 60;
public int ChooseLevel5Hour
{
get => _chooseLevel5Hour;
set
{
if (!SetAndNotify(ref _chooseLevel5Hour, value))
{
return;
}
ChooseLevel5Time = (value * 60) + ChooseLevel5Min;
}
}
private int _chooseLevel5Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540")) % 60) / 10 * 10;
public int ChooseLevel5Min
{
get => _chooseLevel5Min;
set
{
if (!SetAndNotify(ref _chooseLevel5Min, value))
{
return;
}
ChooseLevel5Time = (ChooseLevel5Hour * 60) + value;
}
}
private int _chooseLevel5Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540"));
public int ChooseLevel5Time
{
get => _chooseLevel5Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel5Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel5Time, value.ToString());
SetAndNotify(ref _chooseLevel5Hour, value / 60, nameof(ChooseLevel5Hour));
SetAndNotify(ref _chooseLevel5Min, value % 60, nameof(ChooseLevel5Min));
}
}
#endregion
#region HotKey
/// <summary>

View File

@@ -1718,49 +1718,49 @@ namespace MaaWpfGui.ViewModels.UI
private static bool AppendRecruit()
{
// for debug
if (!int.TryParse(Instances.SettingsViewModel.RecruitMaxTimes, out var maxTimes))
if (!int.TryParse(SettingsViewModel.RecruitTask.RecruitMaxTimes, out var maxTimes))
{
maxTimes = 0;
}
var firstList = Instances.SettingsViewModel.AutoRecruitFirstList;
var firstList = SettingsViewModel.RecruitTask.AutoRecruitFirstList;
var reqList = new List<int>();
var cfmList = new List<int>();
if (Instances.SettingsViewModel.ChooseLevel3)
if (SettingsViewModel.RecruitTask.ChooseLevel3)
{
cfmList.Add(3);
}
if (Instances.SettingsViewModel.ChooseLevel4)
if (SettingsViewModel.RecruitTask.ChooseLevel4)
{
reqList.Add(4);
cfmList.Add(4);
}
// ReSharper disable once InvertIf
if (Instances.SettingsViewModel.ChooseLevel5)
if (SettingsViewModel.RecruitTask.ChooseLevel5)
{
reqList.Add(5);
cfmList.Add(5);
}
_ = int.TryParse(Instances.SettingsViewModel.SelectExtraTags, out var selectExtra);
_ = int.TryParse(SettingsViewModel.RecruitTask.SelectExtraTags, out var selectExtra);
return Instances.AsstProxy.AsstAppendRecruit(
maxTimes,
firstList.Cast<CombinedData>().Select(i => i.Value).ToArray(),
[.. reqList],
[.. cfmList],
Instances.SettingsViewModel.RefreshLevel3,
Instances.SettingsViewModel.ForceRefresh,
Instances.SettingsViewModel.UseExpedited,
SettingsViewModel.RecruitTask.RefreshLevel3,
SettingsViewModel.RecruitTask.ForceRefresh,
SettingsViewModel.RecruitTask.UseExpedited,
selectExtra,
Instances.SettingsViewModel.NotChooseLevel1,
Instances.SettingsViewModel.ChooseLevel3Time,
Instances.SettingsViewModel.ChooseLevel4Time,
Instances.SettingsViewModel.ChooseLevel5Time);
SettingsViewModel.RecruitTask.NotChooseLevel1,
SettingsViewModel.RecruitTask.ChooseLevel3Time,
SettingsViewModel.RecruitTask.ChooseLevel4Time,
SettingsViewModel.RecruitTask.ChooseLevel5Time);
}
private static bool AppendRoguelike()

View File

@@ -0,0 +1,382 @@
// <copyright file="RecruitSettingsUserControlModel.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.Linq;
using MaaWpfGui.Constants;
using MaaWpfGui.Helper;
using MaaWpfGui.Utilities.ValueType;
using Stylet;
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue
{
public class RecruitSettingsUserControlModel : PropertyChangedBase
{
/// <summary>
/// Gets the list of auto recruit selecting extra tags.
/// </summary>
public List<CombinedData> AutoRecruitSelectExtraTagsList { get; } =
[
new() { Display = LocalizationHelper.GetString("DefaultNoExtraTags"), Value = "0" },
new() { Display = LocalizationHelper.GetString("SelectExtraTags"), Value = "1" },
new() { Display = LocalizationHelper.GetString("SelectExtraOnlyRareTags"), Value = "2" },
];
private static readonly List<string> _autoRecruitTagList = ["近战位", "远程位", "先锋干员", "近卫干员", "狙击干员", "重装干员", "医疗干员", "辅助干员", "术师干员", "治疗", "费用回复", "输出", "生存", "群攻", "防护", "减速",];
private static readonly Lazy<List<CombinedData>> _autoRecruitTagShowList = new(() =>
_autoRecruitTagList.Select<string, (string, string)?>(tag => DataHelper.RecruitTags.TryGetValue(tag, out var value) ? value : null)
.Where(tag => tag is not null)
.Cast<(string Display, string Client)>()
.Select(tag => new CombinedData() { Display = tag.Display, Value = tag.Client })
.ToList());
public static List<CombinedData> AutoRecruitTagShowList
{
get => _autoRecruitTagShowList.Value;
}
private object[] _autoRecruitFirstList = ConfigurationHelper
.GetValue(ConfigurationKeys.AutoRecruitFirstList, string.Empty)
.Split(';')
.Select(tag => _autoRecruitTagShowList.Value.FirstOrDefault(i => i.Value == tag))
.Where(tag => tag is not null)
.Cast<CombinedData>()
.ToArray();
public object[] AutoRecruitFirstList
{
get => _autoRecruitFirstList;
set
{
SetAndNotify(ref _autoRecruitFirstList, value);
var config = string.Join(';', value.Cast<CombinedData>().Select(i => i.Value));
ConfigurationHelper.SetValue(ConfigurationKeys.AutoRecruitFirstList, config);
}
}
private string _recruitMaxTimes = ConfigurationHelper.GetValue(ConfigurationKeys.RecruitMaxTimes, "4");
/// <summary>
/// Gets or sets the maximum times of recruit.
/// </summary>
public string RecruitMaxTimes
{
get => _recruitMaxTimes;
set
{
SetAndNotify(ref _recruitMaxTimes, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitMaxTimes, value);
}
}
private bool _refreshLevel3 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RefreshLevel3, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to refresh level 3.
/// </summary>
public bool RefreshLevel3
{
get => _refreshLevel3;
set
{
SetAndNotify(ref _refreshLevel3, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RefreshLevel3, value.ToString());
}
}
private bool _forceRefresh = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.ForceRefresh, bool.TrueString));
/// <summary>
/// Gets or Sets a value indicating whether to refresh when recruit permit ran out.
/// </summary>
public bool ForceRefresh
{
get => _forceRefresh;
set
{
SetAndNotify(ref _forceRefresh, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ForceRefresh, value.ToString());
}
}
private bool _useExpedited;
/// <summary>
/// Gets or sets a value indicating whether to use expedited.
/// </summary>
public bool UseExpedited
{
get => _useExpedited;
set => SetAndNotify(ref _useExpedited, value);
}
private string _selectExtraTags = ConfigurationHelper.GetValue(ConfigurationKeys.SelectExtraTags, "0");
/// <summary>
/// Gets or sets a value indicating three tags are always selected or select only rare tags as many as possible .
/// </summary>
public string SelectExtraTags
{
get
{
if (int.TryParse(_selectExtraTags, out _))
{
return _selectExtraTags;
}
ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, "0");
return "0";
// v4.28.0迁移不再支持bool类型
/*
var value = "0";
if (bool.TryParse(_selectExtraTags, out bool boolValue))
{
value = boolValue ? "1" : "0";
}
SetAndNotify(ref _selectExtraTags, value);
ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
return value;*/
}
set
{
SetAndNotify(ref _selectExtraTags, value);
ConfigurationHelper.SetValue(ConfigurationKeys.SelectExtraTags, value);
}
}
private bool _notChooseLevel1 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.NotChooseLevel1, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether not to choose level 1.
/// </summary>
public bool NotChooseLevel1
{
get => _notChooseLevel1;
set
{
SetAndNotify(ref _notChooseLevel1, value);
ConfigurationHelper.SetValue(ConfigurationKeys.NotChooseLevel1, value.ToString());
}
}
private bool _chooseLevel3 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel3, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 3.
/// </summary>
public bool ChooseLevel3
{
get => _chooseLevel3;
set
{
SetAndNotify(ref _chooseLevel3, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel3, value.ToString());
}
}
private bool _chooseLevel4 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel4, bool.TrueString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 4.
/// </summary>
public bool ChooseLevel4
{
get => _chooseLevel4;
set
{
SetAndNotify(ref _chooseLevel4, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel4, value.ToString());
}
}
private bool _chooseLevel5 = Convert.ToBoolean(ConfigurationHelper.GetValue(ConfigurationKeys.RecruitChooseLevel5, bool.FalseString));
/// <summary>
/// Gets or sets a value indicating whether to choose level 5.
/// </summary>
public bool ChooseLevel5
{
get => _chooseLevel5;
set
{
SetAndNotify(ref _chooseLevel5, value);
ConfigurationHelper.SetValue(ConfigurationKeys.RecruitChooseLevel5, value.ToString());
}
}
private int _chooseLevel3Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540")) / 60;
public int ChooseLevel3Hour
{
get => _chooseLevel3Hour;
set
{
if (!SetAndNotify(ref _chooseLevel3Hour, value))
{
return;
}
ChooseLevel3Time = (value * 60) + ChooseLevel3Min;
}
}
private int _chooseLevel3Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540")) % 60) / 10 * 10;
public int ChooseLevel3Min
{
get => _chooseLevel3Min;
set
{
if (!SetAndNotify(ref _chooseLevel3Min, value))
{
return;
}
ChooseLevel3Time = (ChooseLevel3Hour * 60) + value;
}
}
private int _chooseLevel3Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel3Time, "540"));
public int ChooseLevel3Time
{
get => _chooseLevel3Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel3Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel3Time, value.ToString());
SetAndNotify(ref _chooseLevel3Hour, value / 60, nameof(ChooseLevel3Hour));
SetAndNotify(ref _chooseLevel3Min, value % 60, nameof(ChooseLevel3Min));
}
}
private int _chooseLevel4Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540")) / 60;
public int ChooseLevel4Hour
{
get => _chooseLevel4Hour;
set
{
if (!SetAndNotify(ref _chooseLevel4Hour, value))
{
return;
}
ChooseLevel4Time = (value * 60) + ChooseLevel4Min;
}
}
private int _chooseLevel4Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540")) % 60) / 10 * 10;
public int ChooseLevel4Min
{
get => _chooseLevel4Min;
set
{
if (!SetAndNotify(ref _chooseLevel4Min, value))
{
return;
}
ChooseLevel4Time = (ChooseLevel4Hour * 60) + value;
}
}
private int _chooseLevel4Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel4Time, "540"));
public int ChooseLevel4Time
{
get => _chooseLevel4Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel4Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel4Time, value.ToString());
SetAndNotify(ref _chooseLevel4Hour, value / 60, nameof(ChooseLevel4Hour));
SetAndNotify(ref _chooseLevel4Min, value % 60, nameof(ChooseLevel4Min));
}
}
private int _chooseLevel5Hour = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540")) / 60;
public int ChooseLevel5Hour
{
get => _chooseLevel5Hour;
set
{
if (!SetAndNotify(ref _chooseLevel5Hour, value))
{
return;
}
ChooseLevel5Time = (value * 60) + ChooseLevel5Min;
}
}
private int _chooseLevel5Min = (Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540")) % 60) / 10 * 10;
public int ChooseLevel5Min
{
get => _chooseLevel5Min;
set
{
if (!SetAndNotify(ref _chooseLevel5Min, value))
{
return;
}
ChooseLevel5Time = (ChooseLevel5Hour * 60) + value;
}
}
private int _chooseLevel5Time = Convert.ToInt32(ConfigurationHelper.GetValue(ConfigurationKeys.ChooseLevel5Time, "540"));
public int ChooseLevel5Time
{
get => _chooseLevel5Time;
set
{
value = value switch
{
< 60 => 540,
> 540 => 60,
_ => value / 10 * 10,
};
SetAndNotify(ref _chooseLevel5Time, value);
ConfigurationHelper.SetValue(ConfigurationKeys.ChooseLevel5Time, value.ToString());
SetAndNotify(ref _chooseLevel5Hour, value / 60, nameof(ChooseLevel5Hour));
SetAndNotify(ref _chooseLevel5Min, value % 60, nameof(ChooseLevel5Min));
}
}
}
}

View File

@@ -15,6 +15,7 @@
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
xmlns:userControl="clr-namespace:MaaWpfGui.Views.UserControl"
MinWidth="720"
d:Background="White"
d:DataContext="{d:DesignInstance {x:Type ui:TaskQueueViewModel}}"
d:DesignHeight="495"
d:DesignWidth="800"
@@ -241,11 +242,12 @@
VerticalScrollBarVisibility="Auto">
<hc:SimpleStackPanel Width="220" Margin="0,0,10,0">
<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}"
IsEnabled="{Binding Idle}"
Visibility="{c:Binding TaskSettingVisibilities.Recruiting}" />
<taskQueue:RecruitSettingsUserControl
DataContext="{Binding TaskSettingDataContext.RecruitTask}"
IsEnabled="{Binding DataContext.Idle, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
Visibility="{c:Binding DataContext.TaskSettingVisibilities.Recruiting,
RelativeSource={RelativeSource Mode=FindAncestor,
AncestorType={x:Type UserControl}}}" />
<userControl:ConnectSettingsOnWakeUpUserControl
s:View.ActionTarget="{Binding DataContext, RelativeSource={RelativeSource Self}}"
DataContext="{Binding TaskSettingDataContext}"

View File

@@ -1,5 +1,5 @@
<UserControl
x:Class="MaaWpfGui.Views.UserControl.AutoRecruitSettingsUserControl"
x:Class="MaaWpfGui.Views.UserControl.TaskQueue.RecruitSettingsUserControl"
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,15 +9,18 @@
xmlns:hc="https://handyorg.github.io/handycontrol"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:s="https://github.com/canton7/Stylet"
xmlns:styles="clr-namespace:MaaWpfGui.Styles"
xmlns:setting="clr-namespace:MaaWpfGui.ViewModels.UI"
xmlns:taskQueue="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
xmlns:ui="clr-namespace:MaaWpfGui.ViewModels.UI"
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels"
xmlns:vm="clr-namespace:MaaWpfGui"
d:DataContext="{d:DesignInstance {x:Type ui:SettingsViewModel}}"
d:Background="White"
d:DataContext="{d:DesignInstance {x:Type taskQueue:RecruitSettingsUserControlModel}}"
d:DesignWidth="220"
s:View.ActionTarget="{Binding}"
mc:Ignorable="d">
<StackPanel>
<StackPanel Visibility="{c:Binding !TaskSettingVisibilities.EnableAdvancedSettings}">
<StackPanel Visibility="{c:Binding !EnableAdvancedSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}">
<CheckBox
Margin="0,10"
Content="{DynamicResource AutoUseExpedited}"
@@ -31,12 +34,12 @@
Value="{Binding RecruitMaxTimes}" />
</StackPanel>
<StackPanel Visibility="{c:Binding TaskSettingVisibilities.EnableAdvancedSettings}">
<ComboBox
<StackPanel Visibility="{c:Binding EnableAdvancedSettings, Source={x:Static setting:TaskQueueViewModel.TaskSettingVisibilities}}">
<hc:ComboBox
Margin="0,5"
hc:InfoElement.Title="{DynamicResource AutoRecruitSelectStrategy}"
DisplayMemberPath="Display"
IsHitTestVisible="{Binding Path=Idle}"
IsEnabled="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
ItemsSource="{Binding AutoRecruitSelectExtraTagsList}"
SelectedValue="{Binding SelectExtraTags}"
SelectedValuePath="Value"

View File

@@ -1,4 +1,4 @@
// <copyright file="AutoRecruitSettingsUserControl.xaml.cs" company="MaaAssistantArknights">
// <copyright file="RecruitSettingsUserControl.xaml.cs" company="MaaAssistantArknights">
// MaaWpfGui - A part of the MaaCoreArknights project
// Copyright (C) 2021 MistEO and Contributors
//
@@ -13,17 +13,17 @@
using System.Reflection;
namespace MaaWpfGui.Views.UserControl
namespace MaaWpfGui.Views.UserControl.TaskQueue
{
/// <summary>
/// AutoRecruitSettingsUserControl.xaml 的交互逻辑
/// RecruitSettingsUserControl.xaml 的交互逻辑
/// </summary>
public partial class AutoRecruitSettingsUserControl : System.Windows.Controls.UserControl
public partial class RecruitSettingsUserControl : System.Windows.Controls.UserControl
{
/// <summary>
/// Initializes a new instance of the <see cref="AutoRecruitSettingsUserControl"/> class.
/// Initializes a new instance of the <see cref="RecruitSettingsUserControl"/> class.
/// </summary>
public AutoRecruitSettingsUserControl()
public RecruitSettingsUserControl()
{
InitializeComponent();
}