mirror of
https://github.com/MaaAssistantArknights/MaaAssistantArknights.git
synced 2026-07-18 10:10:45 +08:00
refactor: 生息演算任务参数枚举
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using MaaWpfGui.Configuration.Single.MaaTask;
|
||||
using MaaWpfGui.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
@@ -28,7 +29,7 @@ public class AsstReclamationTask : AsstBaseTask
|
||||
/// <summary>
|
||||
/// Gets or sets 生息演算主题
|
||||
/// </summary>
|
||||
public string Theme { get; set; } = "Tales";
|
||||
public ReclamationTheme Theme { get; set; } = ReclamationTheme.Tales;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 生息演算模式
|
||||
@@ -43,7 +44,7 @@ public class AsstReclamationTask : AsstBaseTask
|
||||
/// </item>
|
||||
/// </list>
|
||||
/// </summary>
|
||||
public int Mode { get; set; } = 0;
|
||||
public ReclamationMode Mode { get; set; } = ReclamationMode.NoArchive;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 点击类型:0 连点;1 长按
|
||||
@@ -69,8 +70,8 @@ public class AsstReclamationTask : AsstBaseTask
|
||||
{
|
||||
var data = new JObject
|
||||
{
|
||||
["theme"] = Theme,
|
||||
["mode"] = Mode,
|
||||
["theme"] = Theme.ToString(),
|
||||
["mode"] = (int)Mode,
|
||||
["increment_mode"] = IncrementMode,
|
||||
["num_craft_batches"] = MaxCraftCountPerRound,
|
||||
["tools_to_craft"] = new JArray(ToolToCraft),
|
||||
|
||||
@@ -22,7 +22,8 @@ using MaaWpfGui.Services;
|
||||
using MaaWpfGui.Utilities.ValueType;
|
||||
using MaaWpfGui.ViewModels.UI;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
using Theme = MaaWpfGui.Configuration.Single.MaaTask.ReclamationTheme;
|
||||
using Mode= MaaWpfGui.Configuration.Single.MaaTask.ReclamationMode;
|
||||
namespace MaaWpfGui.ViewModels.UserControl.TaskQueue;
|
||||
|
||||
public class ReclamationSettingsUserControlModel : TaskViewModel
|
||||
@@ -37,42 +38,42 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
|
||||
/// <summary>
|
||||
/// Gets the list of reclamation themes.
|
||||
/// </summary>
|
||||
public List<CombinedData> ReclamationThemeList { get; } =
|
||||
public List<GenericCombinedData<Theme>> ReclamationThemeList { get; } =
|
||||
[
|
||||
new() { Display = $"{LocalizationHelper.GetString("ReclamationThemeFire")} ({LocalizationHelper.GetString("ClosedStage")})", Value = "Fire" },
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationThemeTales"), Value = "Tales" },
|
||||
new() { Display = $"{LocalizationHelper.GetString("ReclamationThemeFire")} ({LocalizationHelper.GetString("ClosedStage")})", Value = Theme.Fire },
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationThemeTales"), Value = Theme.Tales },
|
||||
];
|
||||
|
||||
private string _reclamationTheme = ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationTheme, "Tales");
|
||||
private Theme _reclamationTheme = ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationTheme, Theme.Tales);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Reclamation theme.
|
||||
/// </summary>
|
||||
public string ReclamationTheme
|
||||
public Theme ReclamationTheme
|
||||
{
|
||||
get => _reclamationTheme;
|
||||
set
|
||||
{
|
||||
SetAndNotify(ref _reclamationTheme, value);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.ReclamationTheme, value);
|
||||
ConfigurationHelper.SetValue(ConfigurationKeys.ReclamationTheme, value.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the list of reclamation modes.
|
||||
/// </summary>
|
||||
public List<GenericCombinedData<int>> ReclamationModeList { get; } =
|
||||
public List<GenericCombinedData<Mode>> ReclamationModeList { get; } =
|
||||
[
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityNoSave"), Value = 0 },
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityInSave"), Value = 1 },
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityNoSave"), Value = Mode.NoArchive },
|
||||
new() { Display = LocalizationHelper.GetString("ReclamationModeProsperityInSave"), Value = Mode.Archive },
|
||||
];
|
||||
|
||||
private int _reclamationMode = int.TryParse(ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationMode, "1"), out var outMode) ? outMode : 1;
|
||||
private Mode _reclamationMode = ConfigurationHelper.GetValue(ConfigurationKeys.ReclamationMode, Mode.Archive);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets 策略,无存档刷生息点数 / 有存档刷生息点数
|
||||
/// </summary>
|
||||
public int ReclamationMode
|
||||
public Mode ReclamationMode
|
||||
{
|
||||
get => _reclamationMode;
|
||||
set
|
||||
@@ -173,7 +174,7 @@ public class ReclamationSettingsUserControlModel : TaskViewModel
|
||||
/// <returns>返回(Asst任务类型, 参数)</returns>
|
||||
public override (AsstTaskType Type, JObject Params) Serialize()
|
||||
{
|
||||
return new AsstReclamationTask()
|
||||
return new AsstReclamationTask
|
||||
{
|
||||
Theme = ReclamationTheme,
|
||||
Mode = ReclamationMode,
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
xmlns:s="https://github.com/canton7/Stylet"
|
||||
xmlns:setting="clr-namespace:MaaWpfGui.ViewModels.UI"
|
||||
xmlns:sv="clr-namespace:MaaWpfGui.Models"
|
||||
xmlns:task="clr-namespace:MaaWpfGui.Configuration.Single.MaaTask"
|
||||
xmlns:viewModels="clr-namespace:MaaWpfGui.ViewModels.UserControl.TaskQueue"
|
||||
d:Background="White"
|
||||
d:DataContext="{d:DesignInstance {x:Type viewModels:ReclamationSettingsUserControlModel}}"
|
||||
@@ -22,6 +23,7 @@
|
||||
<ComboBox
|
||||
Margin="0,5"
|
||||
hc:InfoElement.Title="{DynamicResource ReclamationTheme}"
|
||||
DisplayMemberPath="Display"
|
||||
IsHitTestVisible="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
|
||||
ItemsSource="{Binding ReclamationThemeList}"
|
||||
SelectedValue="{Binding ReclamationTheme}"
|
||||
@@ -47,12 +49,12 @@
|
||||
VerticalContentAlignment="Center"
|
||||
hc:InfoElement.Placeholder="{DynamicResource ReclamationToolToCraftPlaceholder}"
|
||||
hc:InfoElement.Title="{DynamicResource ReclamationToolToCraftTip}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == "1"'}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == task:ReclamationMode.Archive'}"
|
||||
Text="{Binding ReclamationToolToCraft}" />
|
||||
<ComboBox
|
||||
Margin="0,5"
|
||||
hc:InfoElement.Title="{DynamicResource ReclamationIncrementMode}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == "1"'}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == task:ReclamationMode.Archive'}"
|
||||
IsHitTestVisible="{Binding Idle, Source={x:Static setting:TaskQueueViewModel.TaskSettingDataContext}}"
|
||||
ItemsSource="{Binding ReclamationIncrementModeList}"
|
||||
SelectedValue="{Binding ReclamationIncrementMode}"
|
||||
@@ -60,13 +62,13 @@
|
||||
<hc:NumericUpDown
|
||||
Margin="0,5"
|
||||
hc:InfoElement.Title="{DynamicResource ReclamationMaxCraftCountPerRound}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == "1"'}"
|
||||
IsEnabled="{c:Binding 'ReclamationMode == task:ReclamationMode.Archive'}"
|
||||
Minimum="0"
|
||||
Value="{Binding ReclamationMaxCraftCountPerRound}" />
|
||||
<CheckBox
|
||||
Margin="0,10"
|
||||
IsChecked="{Binding ReclamationClearStore}"
|
||||
Visibility="{c:Binding 'ReclamationMode == 0'}">
|
||||
Visibility="{c:Binding 'ReclamationMode == task:ReclamationMode.NoArchive'}">
|
||||
<TextBlock
|
||||
Block.TextAlignment="Left"
|
||||
Text="{DynamicResource ReclamationClearStore}"
|
||||
|
||||
Reference in New Issue
Block a user