mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-03-25 09:29:49 +08:00
* feat: add custom drawer control and integrate it into the UI * 更新仓库UI * feat: implement Git-based repository update mechanism and improve error handling * feat: add reset repository functionality with confirmation dialog * 修改打开队伍配置界面的重试次数和日志 * feat: add drawer open/close events and improve drawer closing logic * feat: enhance WebpagePanel navigation handling and improve initialization logic * feat: add drawer opened event handling and improve navigation completion logic * feat: implement dynamic height adjustment for WebpagePanel using Grid container * feat: update drawer dimensions and apply dynamic sizing based on position * feat: add CustomDrawer component and integrate with MapPathingViewModel for enhanced navigation * feat: integrate WebView2 for Markdown file navigation in MapPathingViewModel
90 lines
2.7 KiB
C#
90 lines
2.7 KiB
C#
using BetterGenshinImpact.Core.Config;
|
|
using BetterGenshinImpact.Core.Script;
|
|
using BetterGenshinImpact.GameTask;
|
|
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
|
using BetterGenshinImpact.Model;
|
|
using BetterGenshinImpact.Service.Interface;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using Wpf.Ui;
|
|
|
|
namespace BetterGenshinImpact.ViewModel.Pages.View;
|
|
|
|
public partial class AutoFightViewModel : ObservableObject, IViewModel
|
|
{
|
|
public AllConfig Config { get; set; }
|
|
|
|
public AutoFightViewModel()
|
|
{
|
|
Config = TaskContext.Instance().Config;
|
|
_strategyList = LoadCustomScript(Global.Absolute(@"User\AutoGeniusInvokation"));
|
|
_combatStrategyList = ["根据队伍自动选择", .. LoadCustomScript(Global.Absolute(@"User\AutoFight"))];
|
|
}
|
|
|
|
public AutoFightViewModel(AllConfig config)
|
|
{
|
|
Config = config;
|
|
_strategyList = LoadCustomScript(Global.Absolute(@"User\AutoGeniusInvokation"));
|
|
_combatStrategyList = ["根据队伍自动选择", .. LoadCustomScript(Global.Absolute(@"User\AutoFight"))];
|
|
}
|
|
|
|
[ObservableProperty]
|
|
private string[] _combatStrategyList;
|
|
|
|
[ObservableProperty]
|
|
private string[] _strategyList;
|
|
|
|
private string[] LoadCustomScript(string folder)
|
|
{
|
|
var files = Directory.GetFiles(folder, "*.*",
|
|
SearchOption.AllDirectories);
|
|
|
|
var strategyList = new string[files.Length];
|
|
for (var i = 0; i < files.Length; i++)
|
|
{
|
|
if (files[i].EndsWith(".txt"))
|
|
{
|
|
var strategyName = files[i].Replace(folder, "").Replace(".txt", "");
|
|
if (strategyName.StartsWith('\\'))
|
|
{
|
|
strategyName = strategyName[1..];
|
|
}
|
|
|
|
strategyList[i] = strategyName;
|
|
}
|
|
}
|
|
|
|
return strategyList;
|
|
}
|
|
|
|
[RelayCommand]
|
|
public void OnStrategyDropDownOpened(string type)
|
|
{
|
|
switch (type)
|
|
{
|
|
case "Combat":
|
|
CombatStrategyList = ["根据队伍自动选择", .. LoadCustomScript(Global.Absolute(@"User\AutoFight"))];
|
|
break;
|
|
|
|
case "GeniusInvocation":
|
|
StrategyList = LoadCustomScript(Global.Absolute(@"User\AutoGeniusInvokation"));
|
|
break;
|
|
}
|
|
}
|
|
|
|
[RelayCommand]
|
|
public void OnOpenLocalScriptRepo()
|
|
{
|
|
Config.ScriptConfig.ScriptRepoHintDotVisible = false;
|
|
ScriptRepoUpdater.Instance.OpenScriptRepoWindow();
|
|
}
|
|
|
|
[RelayCommand]
|
|
public void OnOpenFightFolder()
|
|
{
|
|
Process.Start("explorer.exe", Global.Absolute(@"User\AutoFight\"));
|
|
}
|
|
} |