diff --git a/BetterGenshinImpact/BetterGenshinImpact.csproj b/BetterGenshinImpact/BetterGenshinImpact.csproj index 1ba8a46a..6edc2fa6 100644 --- a/BetterGenshinImpact/BetterGenshinImpact.csproj +++ b/BetterGenshinImpact/BetterGenshinImpact.csproj @@ -10,7 +10,7 @@ true Assets\Images\logo.ico BetterGI - 0.39.5 + 0.39.6 x64 embedded diff --git a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs index 0ebd0030..794764f4 100644 --- a/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs +++ b/BetterGenshinImpact/GameTask/AutoDomain/AutoDomainTask.cs @@ -436,6 +436,7 @@ public class AutoDomainTask : ISoloTask finally { Logger.LogInformation("自动战斗线程结束"); + combatScenes.AfterTask(); } }, cts.Token); diff --git a/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs b/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs index ba260122..7d4c26a0 100644 --- a/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs +++ b/BetterGenshinImpact/GameTask/AutoFight/Model/CombatScenes.cs @@ -70,6 +70,7 @@ public class CombatScenes : IDisposable { throw new Exception("当前处于联机状态,但是队伍人数超过4人,无法识别"); } + // 联机状态下判断 var onePRa = imageRegion.Find(AutoFightAssets.Instance.OnePRa); var p = "p"; @@ -246,6 +247,21 @@ public class CombatScenes : IDisposable } } + public void AfterTask() + { + var mwk = SelectAvatar("玛薇卡"); + if (mwk != null) + { + foreach (var avatar in Avatars) + { + if (avatar.Name != "玛薇卡") + { + avatar.Switch(); + } + } + } + } + public Avatar? SelectAvatar(string name) { return AvatarMap.GetValueOrDefault(name); @@ -381,4 +397,4 @@ public class CombatScenes : IDisposable { _predictor.Dispose(); } -} +} \ No newline at end of file diff --git a/BetterGenshinImpact/Helpers/DirectoryHelper.cs b/BetterGenshinImpact/Helpers/DirectoryHelper.cs index 71cf1f83..00f9df40 100644 --- a/BetterGenshinImpact/Helpers/DirectoryHelper.cs +++ b/BetterGenshinImpact/Helpers/DirectoryHelper.cs @@ -109,4 +109,34 @@ public class DirectoryHelper CopyDirectory(subDir, destSubDir); // 递归拷贝子目录 } } + + /// + /// 递归删除指定目录及其所有子目录和文件 + /// + /// 要删除的目录的路径 + public static void DeleteDirectoryRecursively(string directoryPath) + { + // 检查目录是否存在 + if (Directory.Exists(directoryPath)) + { + // 获取目录中的所有子目录 + string[] subDirectories = Directory.GetDirectories(directoryPath); + foreach (string subDirectory in subDirectories) + { + // 递归调用删除子目录 + DeleteDirectoryRecursively(subDirectory); + } + + // 获取目录中的所有文件 + string[] files = Directory.GetFiles(directoryPath); + foreach (string file in files) + { + // 删除文件 + File.Delete(file); + } + + // 删除空目录 + Directory.Delete(directoryPath); + } + } } diff --git a/BetterGenshinImpact/Helpers/Ui/WindowHelper.cs b/BetterGenshinImpact/Helpers/Ui/WindowHelper.cs index f0820b3c..c6c5d8c1 100644 --- a/BetterGenshinImpact/Helpers/Ui/WindowHelper.cs +++ b/BetterGenshinImpact/Helpers/Ui/WindowHelper.cs @@ -1,4 +1,5 @@ -using System.Windows.Media; +using System.Diagnostics; +using System.Windows.Media; using BetterGenshinImpact.GameTask; using Wpf.Ui.Controls; @@ -8,31 +9,30 @@ public class WindowHelper { public static void TryApplySystemBackdrop(System.Windows.Window window) { - window.Background = new SolidColorBrush(Colors.Transparent); - if (WindowBackdrop.IsSupported(TaskContext.Instance().Config.CommonConfig.CurrentBackdropType)) { if (TaskContext.Instance().Config.CommonConfig.CurrentBackdropType == WindowBackdropType.Acrylic) { window.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0)); } + else + { + window.Background = new SolidColorBrush(Colors.Transparent); + } WindowBackdrop.ApplyBackdrop(window, TaskContext.Instance().Config.CommonConfig.CurrentBackdropType); return; } - - if (WindowBackdrop.IsSupported(WindowBackdropType.Mica)) - { - WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Mica); - } - else if (WindowBackdrop.IsSupported(WindowBackdropType.Tabbed)) - { - WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Tabbed); - } - else if (WindowBackdrop.IsSupported(WindowBackdropType.Acrylic)) + if (WindowBackdrop.IsSupported(WindowBackdropType.Acrylic)) { + window.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0)); WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Acrylic); } + else if (WindowBackdrop.IsSupported(WindowBackdropType.Mica)) + { + window.Background = new SolidColorBrush(Colors.Transparent); + WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Mica); + } } } \ No newline at end of file diff --git a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs index ea5c5724..d126f456 100644 --- a/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs +++ b/BetterGenshinImpact/ViewModel/MainWindowViewModel.cs @@ -66,12 +66,16 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel [RelayCommand] private void OnSwitchBackdrop() { + if (!OsVersionHelper.IsWindows11_22523_OrGreater) + { + return; // win10 不支持切换主题 + } + CurrentBackdropType = CurrentBackdropType switch { WindowBackdropType.Mica => WindowBackdropType.Acrylic, - WindowBackdropType.Acrylic => WindowBackdropType.Tabbed, - WindowBackdropType.Tabbed => WindowBackdropType.Mica, - _ => WindowBackdropType.Mica + WindowBackdropType.Acrylic => WindowBackdropType.Mica, + _ => WindowBackdropType.Acrylic }; Config.CommonConfig.CurrentBackdropType = CurrentBackdropType; @@ -79,7 +83,6 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel if (Application.Current.MainWindow is MainWindow mainWindow) { mainWindow.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0)); - ; WindowBackdrop.ApplyBackdrop(mainWindow, CurrentBackdropType); } } @@ -153,14 +156,14 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel && Directory.Exists(Global.Absolute("BetterGI/User")) ) { - var res = await MessageBox.ShowAsync("检测到旧的 BetterGI 配置,是否迁移配置并清理旧目录?", "BetterGI", System.Windows.MessageBoxButton.YesNo); + var res = await MessageBox.ShowAsync("检测到旧的 BetterGI 配置,是否迁移配置并清理旧目录?", "BetterGI", System.Windows.MessageBoxButton.YesNo, MessageBoxImage.Question); if (res == System.Windows.MessageBoxResult.Yes) { var dir = Global.Absolute("BetterGI/User"); // 迁移配置,拷贝整个目录并覆盖 DirectoryHelper.CopyDirectory(dir, Global.Absolute("User")); // 删除旧目录 - Directory.Delete(Global.Absolute("BetterGI")); + DirectoryHelper.DeleteDirectoryRecursively(Global.Absolute("BetterGI")); } } diff --git a/BetterGenshinImpact/ViewModel/Pages/ScriptControlViewModel.cs b/BetterGenshinImpact/ViewModel/Pages/ScriptControlViewModel.cs index 0fd06377..23d592ce 100644 --- a/BetterGenshinImpact/ViewModel/Pages/ScriptControlViewModel.cs +++ b/BetterGenshinImpact/ViewModel/Pages/ScriptControlViewModel.cs @@ -747,6 +747,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware private List LoadAllJsScriptProjects() { var path = Global.ScriptPath(); + Directory.CreateDirectory(path); // 获取所有脚本项目 var projects = Directory.GetDirectories(path) .Select(x => new ScriptProject(Path.GetFileName(x)))