Files
better-genshin-impact/BetterGenshinImpact/ViewModel/Pages/View/ScriptGroupConfigViewModel.cs
2025-09-23 00:59:07 +08:00

106 lines
3.5 KiB
C#

using BetterGenshinImpact.Core.Config;
using BetterGenshinImpact.Core.Script.Group;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading.Tasks;
using Windows.System;
using Wpf.Ui.Violeta.Controls;
namespace BetterGenshinImpact.ViewModel.Pages.View;
public partial class ScriptGroupConfigViewModel : ObservableObject, IViewModel
{
[ObservableProperty]
private AutoFightViewModel _autoFightViewModel;
[ObservableProperty]
private ScriptGroupConfig _scriptGroupConfig;
[ObservableProperty]
private PathingPartyConfig _pathingConfig;
[ObservableProperty]
private ShellConfig _shellConfig;
[ObservableProperty]
private bool _enableShellConfig;
[ObservableProperty]
private ObservableCollection<KeyValuePair<string, string>> _onlyPickEliteDropsSource = new()
{
new KeyValuePair<string, string>("Closed", "关闭功能"),
new KeyValuePair<string, string>("AllowAutoPickupForNonElite", "非精英允许自动拾取"),
new KeyValuePair<string, string>("DisableAutoPickupForNonElite", "非精英关闭自动拾取")
};
//跳过策略
//GroupPhysicalPathSkipPolicy: 配置组且物理路径相同跳过
//PhysicalPathSkipPolicy: 物理路径相同跳过
//SameNameSkipPolicy: 同类型同名跳过
[ObservableProperty]
private ObservableCollection<KeyValuePair<string, string>> _skipPolicySource = new()
{
new KeyValuePair<string, string>("GroupPhysicalPathSkipPolicy", "配置组且物理路径相同跳过"),
new KeyValuePair<string, string>("PhysicalPathSkipPolicy", "物理路径相同跳过"),
new KeyValuePair<string, string>("SameNameSkipPolicy", "同类型同名跳过")
};
[ObservableProperty]
private ObservableCollection<KeyValuePair<string, string>> _referencePointSource = new()
{
new KeyValuePair<string, string>("StartTime", "开始时间"),
new KeyValuePair<string, string>("EndTime", "结束时间")
};
public ScriptGroupConfigViewModel(AllConfig config, ScriptGroupConfig scriptGroupConfig)
{
ScriptGroupConfig = scriptGroupConfig;
PathingConfig = scriptGroupConfig.PathingConfig;
AutoFightViewModel = new AutoFightViewModel(config);
ShellConfig = scriptGroupConfig.ShellConfig;
EnableShellConfig = scriptGroupConfig.EnableShellConfig;
}
[RelayCommand]
private void OnStrategyDropDownOpened(string type)
{
AutoFightViewModel.OnStrategyDropDownOpened(type);
}
[RelayCommand]
public void OnOpenLocalScriptRepo()
{
AutoFightViewModel.OnOpenLocalScriptRepo();
}
[RelayCommand]
public void OnGetExecutionOrder()
{
var index = _pathingConfig.TaskCycleConfig.GetExecutionOrder();
if (index == -1)
{
Toast.Error("计算失败,请检查参数!");
}
else
{
Toast.Success("当前执行序号为:"+index);
}
}
[RelayCommand]
public void OnOpenFightFolder()
{
AutoFightViewModel.OnOpenFightFolder();
}
[RelayCommand]
private void OnAutoFightEnabledChecked()
{
PathingConfig.Enabled = true;
}
[RelayCommand]
private async Task OnGoToAutoEatUrlAsync()
{
await Launcher.LaunchUriAsync(new Uri("https://bettergi.com/dev/js/dispatcher.html#autoeat-自动吃食物"));
}
}