Merge branch 'babalae:main' into main

This commit is contained in:
秋云
2025-01-24 20:42:18 +08:00
committed by GitHub
9 changed files with 85 additions and 16 deletions

View File

@@ -10,7 +10,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
<AssemblyName>BetterGI</AssemblyName>
<AssemblyVersion>0.39.5</AssemblyVersion>
<AssemblyVersion>0.39.6</AssemblyVersion>
<Platforms>x64</Platforms>
<DebugType>embedded</DebugType>
</PropertyGroup>

View File

@@ -436,6 +436,7 @@ public class AutoDomainTask : ISoloTask
finally
{
Logger.LogInformation("自动战斗线程结束");
combatScenes.AfterTask();
}
}, cts.Token);

View File

@@ -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();
}
}
}

View File

@@ -6,6 +6,7 @@ public class MoveModeEnum(string code, string msg)
{
public static readonly MoveModeEnum Walk = new("walk", "步行");
public static readonly MoveModeEnum Run = new("run", "奔跑");
public static readonly MoveModeEnum Dash = new("dash", "持续冲刺");
public static readonly MoveModeEnum Climb = new("climb", "攀爬");
public static readonly MoveModeEnum Fly = new("fly", "飞行");
public static readonly MoveModeEnum Jump = new("jump", "跳跃");

View File

@@ -680,7 +680,23 @@ public class PathExecutor
// 只有设置为run才会一直疾跑
if (waypoint.MoveMode == MoveModeEnum.Run.Code)
{
if (distance > 25) // 距离大于25时可以使用疾跑
if (distance > 20 != fastMode) // 距离大于20时可以使用疾跑/自由泳
{
if (fastMode)
{
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyUp);
}
else
{
Simulation.SendInput.SimulateAction(GIActions.SprintMouse, KeyType.KeyDown);
}
fastMode = !fastMode;
}
}
else if (waypoint.MoveMode == MoveModeEnum.Dash.Code)
{
if (distance > 20) // 距离大于25时可以使用疾跑
{
if (Math.Abs((fastModeColdTime - DateTime.UtcNow).TotalMilliseconds) > 1000) //冷却一会
{

View File

@@ -109,4 +109,34 @@ public class DirectoryHelper
CopyDirectory(subDir, destSubDir); // 递归拷贝子目录
}
}
/// <summary>
/// 递归删除指定目录及其所有子目录和文件
/// </summary>
/// <param name="directoryPath">要删除的目录的路径</param>
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);
}
}
}

View File

@@ -1,4 +1,5 @@
using System.Windows.Media;
using System.Diagnostics;
using System.Windows.Media;
using BetterGenshinImpact.GameTask;
using Wpf.Ui.Controls;
@@ -8,14 +9,16 @@ 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;
@@ -24,14 +27,12 @@ public class WindowHelper
if (WindowBackdrop.IsSupported(WindowBackdropType.Mica))
{
window.Background = new SolidColorBrush(Colors.Transparent);
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Mica);
}
else if (WindowBackdrop.IsSupported(WindowBackdropType.Tabbed))
{
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Tabbed);
}
else if (WindowBackdrop.IsSupported(WindowBackdropType.Acrylic))
{
window.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0));
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Acrylic);
}
}

View File

@@ -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"));
}
}

View File

@@ -702,6 +702,7 @@ public partial class ScriptControlViewModel : ObservableObject, INavigationAware
private List<ScriptProject> LoadAllJsScriptProjects()
{
var path = Global.ScriptPath();
Directory.CreateDirectory(path);
// 获取所有脚本项目
var projects = Directory.GetDirectories(path)
.Select(x => new ScriptProject(Path.GetFileName(x)))