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> _onlyPickEliteDropsSource = new() { new KeyValuePair("Closed", "关闭功能"), new KeyValuePair("AllowAutoPickupForNonElite", "非精英允许自动拾取"), new KeyValuePair("DisableAutoPickupForNonElite", "非精英关闭自动拾取") }; //跳过策略 //GroupPhysicalPathSkipPolicy: 配置组且物理路径相同跳过 //PhysicalPathSkipPolicy: 物理路径相同跳过 //SameNameSkipPolicy: 同类型同名跳过 [ObservableProperty] private ObservableCollection> _skipPolicySource = new() { new KeyValuePair("GroupPhysicalPathSkipPolicy", "配置组且物理路径相同跳过"), new KeyValuePair("PhysicalPathSkipPolicy", "物理路径相同跳过"), new KeyValuePair("SameNameSkipPolicy", "同类型同名跳过") }; [ObservableProperty] private ObservableCollection> _referencePointSource = new() { new KeyValuePair("StartTime", "开始时间"), new KeyValuePair("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-自动吃食物")); } }