Compare commits

...
Author SHA1 Message Date
辉鸭蛋 1852121e4f Revert "使用行为树对自动钓鱼进行了改写,以利往后的优化" 2025-01-25 16:53:30 +08:00
辉鸭蛋 5259b1f351 startOneDragon command line #998 2025-01-25 16:49:05 +08:00
辉鸭蛋 1afeb0818a #974 2025-01-25 15:55:36 +08:00
辉鸭蛋 99ab38d950 Merge remote-tracking branch 'origin/main' 2025-01-25 13:57:59 +08:00
辉鸭蛋 1d5f5c772e update ui 2025-01-25 13:55:19 +08:00
辉鸭蛋 869050283b Merge pull request #1045 from FishmanTheMurloc/main
使用行为树对自动钓鱼进行了改写,以利往后的优化
2025-01-25 13:53:15 +08:00
FishmanTheMurloc bb692a476e 添加纳塔鱼和鱼饵;添加鱼大类ray以合并两种细分的formalo ray和divda ray 2025-01-25 13:06:04 +08:00
FishmanTheMurloc 518ed95dbe Merge branch 'babalae:main' into main 2025-01-25 12:05:46 +08:00
辉鸭蛋 987e723b8c BetterGI.exe startOneDragon 2025-01-25 10:31:30 +08:00
辉鸭蛋 3c84f3817d auto tcg: fix error 2025-01-24 22:48:25 +08:00
辉鸭蛋 6beb9fddba Merge pull request #1058 from physligl/main
增加了地图移动的相关参数设置的界面
2025-01-24 22:00:18 +08:00
秋云 020c841bc2 Merge branch 'babalae:main' into main 2025-01-24 20:42:18 +08:00
秋云 b445c71e52 增加了地图移动的相关参数设置。 2025-01-24 20:38:45 +08:00
辉鸭蛋 a5e1478ecf revert & dash 2025-01-24 19:48:45 +08:00
辉鸭蛋 158688d435 fix patch 1 2025-01-24 18:08:56 +08:00
辉鸭蛋 8caa52e988 Acrylic first 2025-01-24 01:21:09 +08:00
辉鸭蛋 82275bd1e5 Merge remote-tracking branch 'origin/main' 2025-01-24 00:16:49 +08:00
辉鸭蛋 4129510029 0.39.6 2025-01-24 00:16:25 +08:00
辉鸭蛋 917ba1460d fix some bug 2025-01-24 00:16:11 +08:00
秋云 3cc3eb44a4 fix typos. 2025-01-23 23:00:57 +08:00
辉鸭蛋 29f219aee9 Merge pull request #1055 from mfkvfhpdx/main
调整删除逻辑,软链接目录直接删除目录而非文件递归删除,方便引入自己的目录,防止订阅全部时被删除。
2025-01-23 12:50:36 +08:00
zjl 1af75ecc64 调整删除逻辑,软链接目录直接删除目录而非文件递归删除,方便引入自己的目录,防止订阅全部时被删除。 2025-01-22 22:31:19 +08:00
辉鸭蛋 39d7422ab9 new world model 2025-01-21 23:09:47 +08:00
辉鸭蛋 12cc958705 updater 2025-01-21 23:01:35 +08:00
辉鸭蛋 197e991a89 0.39.5 2025-01-21 22:51:57 +08:00
辉鸭蛋 6ee4318d24 Merge pull request #1036 from mfkvfhpdx/main
调整“按日锄地摩拉统计”为“按日摩拉收益统计”,并增加统计突发事件委托收益。
2025-01-21 22:47:09 +08:00
mfkvfhpdx 6fcc0685e6 Merge branch 'babalae:main' into main 2025-01-21 08:33:33 +08:00
mfkvfhpdx 0b17dc30fe Merge branch 'babalae:main' into main 2025-01-20 13:39:56 +08:00
zjl 919818a424 调度器配置增加 “根据技能CD优化出招人员”配置。根据填入人或人和cd,来决定当此人元素战技cd未结束时,跳过此人出招,来优化战斗流程,可填入人名或人名数字(用逗号分隔),多种用分号分隔,例如:白术;钟离,12;,如果人名,则用内置cd检查(或填入数字也小于0),如果是人名和数字,则把数字当做出招cd(秒)。 2025-01-19 22:11:47 +08:00
FishmanTheMurloc 28cc3fb3e3 使用行为树对自动钓鱼进行了改写,以利往后的优化 2025-01-19 17:46:11 +08:00
zjl ae954fceb8 调整“按日锄地摩拉统计”为“按日摩拉收益统计”,并增加统计突发事件委托收益。 2025-01-18 22:37:57 +08:00
29 changed files with 662 additions and 240 deletions

No files matched your search

@@ -10,7 +10,7 @@
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationIcon>Assets\Images\logo.ico</ApplicationIcon>
<AssemblyName>BetterGI</AssemblyName>
<AssemblyVersion>0.39.4</AssemblyVersion>
<AssemblyVersion>0.39.6</AssemblyVersion>
<Platforms>x64</Platforms>
<DebugType>embedded</DebugType>
</PropertyGroup>
+7 -3
View File
@@ -17,6 +17,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Text.Json.Serialization;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.AutoTrackPath;
namespace BetterGenshinImpact.Core.Config;
@@ -175,7 +176,11 @@ public partial class AllConfig : ObservableObject
/// 原神按键绑定配置
/// </summary>
public KeyBindingsConfig KeyBindingsConfig { get; set; } = new();
/// <summary>
/// 传送相关配置
/// </summary>
public TpConfig TpConfig { get; set; } = new();
[JsonIgnore]
public Action? OnAnyChangedAction { get; set; }
@@ -188,7 +193,6 @@ public partial class AllConfig : ObservableObject
NotificationConfig.PropertyChanged += OnAnyPropertyChanged;
NotificationConfig.PropertyChanged += OnNotificationPropertyChanged;
KeyBindingsConfig.PropertyChanged += OnAnyPropertyChanged;
AutoPickConfig.PropertyChanged += OnAnyPropertyChanged;
AutoSkipConfig.PropertyChanged += OnAnyPropertyChanged;
AutoFishingConfig.PropertyChanged += OnAnyPropertyChanged;
@@ -200,7 +204,7 @@ public partial class AllConfig : ObservableObject
AutoFightConfig.PropertyChanged += OnAnyPropertyChanged;
AutoDomainConfig.PropertyChanged += OnAnyPropertyChanged;
AutoMusicGameConfig.PropertyChanged += OnAnyPropertyChanged;
TpConfig.PropertyChanged += OnAnyPropertyChanged;
ScriptConfig.PropertyChanged += OnAnyPropertyChanged;
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
}
@@ -436,6 +436,7 @@ public class AutoDomainTask : ISoloTask
finally
{
Logger.LogInformation("自动战斗线程结束");
combatScenes.AfterTask();
}
}, cts.Token);
@@ -25,6 +25,13 @@ public partial class AutoFightConfig : ObservableObject
/// </summary>
[ObservableProperty]
private bool _fightFinishDetectEnabled = true;
/// <summary>
/// 根据技能CD优化出招人员
/// 根据填入人或人和cd,来决定当此人元素战技cd未结束时,跳过此人出招,来优化战斗流程,可填入人名或人名数字(用逗号分隔),
/// 多种用分号分隔,例如:白术;钟离,12;,如果人名,则用内置cd检查,如果是人名和数字,则把数字当做出招cd(秒)。
/// </summary>
[ObservableProperty] private string _actionSchedulerByCd = "";
[Serializable]
public partial class FightFinishDetectConfig : ObservableObject
{
@@ -26,6 +26,7 @@ public class AutoFightParam : BaseTaskParam
FightFinishDetectEnabled = autoFightConfig.FightFinishDetectEnabled;
PickDropsAfterFightEnabled = autoFightConfig.PickDropsAfterFightEnabled;
KazuhaPickupEnabled = autoFightConfig.KazuhaPickupEnabled;
ActionSchedulerByCd = autoFightConfig.ActionSchedulerByCd;
FinishDetectConfig.FastCheckEnabled = autoFightConfig.FinishDetectConfig.FastCheckEnabled;
FinishDetectConfig.FastCheckParams = autoFightConfig.FinishDetectConfig.FastCheckParams;
@@ -47,6 +48,7 @@ public class AutoFightParam : BaseTaskParam
public int Timeout { get; set; } = 120;
public bool KazuhaPickupEnabled = true;
public string ActionSchedulerByCd = "";
}
@@ -202,6 +202,7 @@ public class AutoFightTask : ISoloTask
throw new Exception("识别队伍角色失败");
}
var actionSchedulerByCd = ParseStringToDictionary(_taskParam.ActionSchedulerByCd);
var combatCommands = _combatScriptBag.FindCombatScript(combatScenes.Avatars);
// 新的取消token
@@ -221,7 +222,8 @@ public class AutoFightTask : ISoloTask
return;
}*/
var fightEndFlag = false;
string lastFighttName = "";
string lastFightName = "";
string skipFightName = "";
//统计切换人打架次数
var countFight = 0;
// 战斗操作
@@ -242,6 +244,30 @@ public class AutoFightTask : ISoloTask
break;
}
//根据元素技能冷却事件优化出招流程,只有当人物切换后才会触发检查
double skillCd;
if (lastFightName != command.Name && actionSchedulerByCd.TryGetValue(command.Name,out skillCd))
{
var avatar = combatScenes.Avatars.FirstOrDefault(a => a.Name == command.Name);
if (skillCd < 0)
{
skillCd = FindMax([avatar.SkillCd,avatar.SkillHoldCd]);
}
var dif=(DateTime.UtcNow - avatar.LastSkillTime);
//当技能未冷却时,跳过此次出招
if ((DateTime.UtcNow -avatar.LastSkillTime).TotalSeconds < skillCd)
{
if (skipFightName != command.Name)
{
Logger.LogInformation($"{command.Name}cd冷却为{skillCd}秒,剩余{skillCd-dif.TotalSeconds}秒,跳过此次行动");
}
skipFightName = command.Name;
continue;
}
}
command.Execute(combatScenes);
//统计战斗人次
if (i == combatCommands.Count - 1 || command.Name != combatCommands[i + 1].Name)
@@ -249,7 +275,7 @@ public class AutoFightTask : ISoloTask
countFight++;
}
lastFighttName = command.Name;
lastFightName = command.Name;
if (!fightEndFlag && _taskParam is { FightFinishDetectEnabled: true })
{
//处于最后一个位置,或者当前执行人和下一个人名字不一样的情况,满足一定条件(开启快速检查,并且检查时间大于0或人名存在配置)检查战斗
@@ -341,7 +367,7 @@ public class AutoFightTask : ISoloTask
{
var time = DateTime.UtcNow - kazuha.LastSkillTime;
//当万叶cd大于3时或战斗人次少于2时(通常无怪物情况下),此时不再触发万叶拾取,
if (!(countFight < 2 || lastFighttName == "枫原万叶" && time.TotalSeconds > 3))
if (!(countFight < 2 || lastFightName == "枫原万叶" && time.TotalSeconds > 3))
{
Logger.LogInformation("使用枫原万叶长E拾取掉落物");
await Delay(300, ct);
@@ -470,6 +496,53 @@ public class AutoFightTask : ISoloTask
(g >= 240 && g <= 255) &&
(b >= 240 && b <= 255);
}
static double FindMax(double[] numbers)
{
if (numbers == null || numbers.Length == 0)
{
throw new ArgumentException("The array is empty or null.");
}
double max = numbers[0]>10000 ? 0 : numbers[0];
foreach (var num in numbers)
{
var cpnum = numbers[0]>10000 ? 0 : num;
max = Math.Max(max, num);
}
return max;
}
private static Dictionary<string, double> ParseStringToDictionary(string input,double defaultValue=-1)
{
var dictionary = new Dictionary<string, double>();
if (string.IsNullOrEmpty(input))
{
return dictionary; // 返回空字典
}
string[] pairs = input.Split(';', StringSplitOptions.RemoveEmptyEntries);
foreach (var pair in pairs)
{
var parts = pair.Split(',', StringSplitOptions.TrimEntries);
if (parts.Length > 0)
{
string name = parts[0];
double value = defaultValue;
if (parts.Length > 1 && double.TryParse(parts[1], out var parsedValue))
{
value = parsedValue;
}
dictionary[name] = value;
}
}
return dictionary;
}
private bool HasFightFlagByYolo(ImageRegion imageRegion)
{
@@ -31,7 +31,7 @@ public class CombatScenes : IDisposable
/// <summary>
/// 当前配队
/// </summary>
public Avatar[] Avatars { get; set; } = Array.Empty<Avatar>();
public Avatar[] Avatars { get; set; } = [];
public Dictionary<string, Avatar> AvatarMap { get; set; } = [];
@@ -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();
}
}
}
@@ -1,5 +1,7 @@
using System.Threading;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.Common;
using Microsoft.Extensions.Logging;
namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation;
@@ -9,9 +11,17 @@ public class AutoGeniusInvokationTask(GeniusInvokationTaskParam taskParam) : ISo
public Task Start(CancellationToken ct)
{
// 读取策略信息
var duel = ScriptParser.Parse(taskParam.StrategyContent);
duel.Run(ct);
try
{
// 读取策略信息
var duel = ScriptParser.Parse(taskParam.StrategyContent);
duel.Run(ct);
}
catch (System.Exception e)
{
TaskControl.Logger.LogDebug(e, "执行自动七圣召唤任务异常");
TaskControl.Logger.LogError("执行自动七圣召唤任务异常:{Exception}", e.Message);
}
return Task.CompletedTask;
}
}
}
@@ -117,7 +117,7 @@ public class ScriptParser
var characterAndSkill = line.Split('{');
var parts = characterAndSkill[0].Split('=');
character.Index = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(parts[0], ""));
character.Index = int.Parse(RegexHelper.ExcludeNumberRegex().Replace(parts[0].Trim(), ""));
MyAssert(character.Index >= 1 && character.Index <= 3, "角色序号必须在1-3之间");
if (parts[1].Contains('|'))
@@ -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", "跳跃");
@@ -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) //冷却一会
{
@@ -0,0 +1,55 @@
using CommunityToolkit.Mvvm.ComponentModel;
using System;
namespace BetterGenshinImpact.GameTask.AutoTrackPath;
public partial class TpConfig : ObservableObject
{
[ObservableProperty]
private bool _mapZoomEnabled = true; // 地图缩放开关
[ObservableProperty]
private int _mapZoomOutDistance = 2000; // 地图缩小的最小距离,单位:像素
[ObservableProperty]
private int _mapZoomInDistance = 400; // 地图放大的最大距离,单位:像素
[ObservableProperty]
private int _stepIntervalMilliseconds = 20; // 鼠标移动时间间隔,单位:ms
[ObservableProperty]
private double _maxZoomLevel = 5.0; // 最大缩放等级
[ObservableProperty]
private double _minZoomLevel = 1.7; // 最小缩放等级
[ObservableProperty]
private double _reviveStatueOfTheSevenPointX = 2296.4; // 七天神像点位X坐标
[ObservableProperty]
private double _reviveStatueOfTheSevenPointY = -824.4; // 七天神像点位Y坐标
[ObservableProperty]
private int _zoomOutButtonY = 654; // y-coordinate for zoom-out button
[ObservableProperty]
private int _zoomInButtonY = 428; // y-coordinate for zoom-in button
[ObservableProperty]
private int _zoomButtonX = 49; // x-coordinate for zoom button
[ObservableProperty]
private int _zoomStartY = 453; // y-coordinate for zoom start
[ObservableProperty]
private int _zoomEndY = 628; // y-coordinate for zoom end
[ObservableProperty]
private double _tolerance = 200; // 允许的移动误差
[ObservableProperty]
private int _maxIterations = 30; // 移动最大次数
[ObservableProperty]
private int _maxMouseMove = 300; // 单次移动最大距离
}
@@ -1,28 +1,26 @@
using BetterGenshinImpact.Core.Recognition;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BetterGenshinImpact.Core.Recognition;
using BetterGenshinImpact.Core.Recognition.OpenCv;
using BetterGenshinImpact.Core.Script.Dependence;
using BetterGenshinImpact.Core.Simulator;
using BetterGenshinImpact.Core.Simulator.Extensions;
using BetterGenshinImpact.GameTask.AutoGeniusInvokation.Exception;
using BetterGenshinImpact.GameTask.Common;
using BetterGenshinImpact.GameTask.Common.BgiVision;
using BetterGenshinImpact.GameTask.Common.Element.Assets;
using BetterGenshinImpact.GameTask.Common.Exceptions;
using BetterGenshinImpact.GameTask.Common.Map;
using BetterGenshinImpact.GameTask.Model.Area;
using BetterGenshinImpact.GameTask.QuickTeleport.Assets;
using BetterGenshinImpact.Helpers.Extensions;
using Microsoft.Extensions.Logging;
using OpenCvSharp;
using System;
using System.Diagnostics;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using BetterGenshinImpact.GameTask.Common.Exceptions;
using Vanara.PInvoke;
using static BetterGenshinImpact.GameTask.Common.TaskControl;
using BetterGenshinImpact.Core.Simulator.Extensions;
using BetterGenshinImpact.GameTask.Common.Job;
using BetterGenshinImpact.Core.Script.Dependence;
using Microsoft.Diagnostics.Utilities;
namespace BetterGenshinImpact.GameTask.AutoTrackPath;
@@ -34,89 +32,17 @@ public class TpTask(CancellationToken ct)
private readonly QuickTeleportAssets _assets = QuickTeleportAssets.Instance;
private readonly Rect _captureRect = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect;
private readonly double _zoomOutMax1080PRatio = TaskContext.Instance().SystemInfo.ZoomOutMax1080PRatio;
private static double ReviveStatueOfTheSevenPointX = 2296.4;
private static double ReviveStatueOfTheSevenPointY = -824.4;
private static int zoomOutButtonY = 654; // y-coordinate for zoom-out button
private static int zoomInButtonY = 428; // y-coordinate for zoom-in button
private static int zoomButtonX = 49; // x-coordinate for zoom button
private static int zoomStartY = 453; // y-coordinate for zoom start
private static int zoomEndY = 628; // y-coordinate for zoom end
private static bool _mapZoomEnabled = true;
private static int _mapZoomOutDistance = 1000;
private static int _mapZoomInDistance = 400;
private static int _stepIntervalMilliseconds = 20;
public static bool MapZoomEnabled
{
get => _mapZoomEnabled;
set
{
_mapZoomEnabled = value;
if(!value)
{
Logger.LogInformation("禁用了缩放功能,请自行调整合适的缩放,部分脚本可能会因为禁用缩放功能无法使用");
}
}
}
public static int MapZoomOutDistance
{
get => _mapZoomOutDistance;
set
{
if (value < 500 || value > 5000) // 自动设置合理范围
{
_mapZoomOutDistance = 1000;
}
if (value <= _mapZoomInDistance)
{
_mapZoomOutDistance = _mapZoomInDistance * 2;
}
_mapZoomOutDistance = value;
}
}
public static int MapZoomInDistance
{
get => _mapZoomInDistance;
set
{
if (value < 200 || value > 1000) // 自动设置合理范围
{
_mapZoomInDistance = 400;
}
if (value >= _mapZoomOutDistance)
{
_mapZoomInDistance = _mapZoomOutDistance / 2;
}
_mapZoomInDistance = value;
}
}
public static int StepIntervalMilliseconds
{
get => _stepIntervalMilliseconds;
set
{
if (value < 5 || value > 100)
{
_stepIntervalMilliseconds = 20;
}
_stepIntervalMilliseconds = value;
}
}
private readonly TpConfig _tpConfig = TaskContext.Instance().Config.TpConfig;
/// <summary>
/// 传送到须弥七天神像
/// </summary>
public async Task TpToStatueOfTheSeven()
{
await CheckInBigMapUi();
if (_mapZoomEnabled)
if (_tpConfig.MapZoomEnabled)
{
double currentZoomLevel = GetBigMapZoomLevel(CaptureToRectArea());
bool tempMapZoomEnable = _mapZoomEnabled;
_mapZoomEnabled = false; // 临时禁用缩放功能
if (currentZoomLevel > 4.5)
{
await AdjustMapZoomLevel(currentZoomLevel, 4.5);
@@ -125,13 +51,8 @@ public class TpTask(CancellationToken ct)
{
await AdjustMapZoomLevel(currentZoomLevel, 3);
}
await Tp(ReviveStatueOfTheSevenPointX, ReviveStatueOfTheSevenPointY);
_mapZoomEnabled = tempMapZoomEnable;
}
else
{
await Tp(ReviveStatueOfTheSevenPointX, ReviveStatueOfTheSevenPointY);
}
await Tp(_tpConfig.ReviveStatueOfTheSevenPointX, _tpConfig.ReviveStatueOfTheSevenPointY);
}
/// <summary>
/// 通过大地图传送到指定坐标最近的传送点,然后移动到指定坐标
@@ -139,9 +60,10 @@ public class TpTask(CancellationToken ct)
/// <param name="tpX"></param>
/// <param name="tpY"></param>
/// <param name="force">强制以当前的tpX,tpY坐标进行自动传送</param>
public async Task<(double, double)> TpOnce(double tpX, double tpY, bool force = false)
private async Task<(double, double)> TpOnce(double tpX, double tpY, bool force = false)
{
var (x, y) = (tpX, tpY);
string? country = null;
if (!force)
{
@@ -152,25 +74,23 @@ public class TpTask(CancellationToken ct)
// 计算传送点位置离哪个地图切换后的中心点最近,切换到该地图
await SwitchRecentlyCountryMap(x, y, country);
// 计算坐标后点击
var bigMapInAllMapRect = GetBigMapRect();
if (_mapZoomEnabled)
if (_tpConfig.MapZoomEnabled)
{
double zoomLevel = GetBigMapZoomLevel(CaptureToRectArea());
if (zoomLevel > 4.5)
{
// 显示传送锚点和秘境的缩放等级
await AdjustMapZoomLevel(zoomLevel, 4.5);
Logger.LogInformation("当前缩放等级过大,调整为 {zoomLevel:0.000}", 4.5);
Logger.LogInformation("当前缩放等级过大,调整为 {zoomLevel:0.00}", 4.5);
}
}
var bigMapInAllMapRect = GetBigMapRect();
while (!IsPointInBigMapWindow(bigMapInAllMapRect, x, y)) // 左上角 350x400也属于禁止点击区域
{
Debug.WriteLine($"({x},{y}) 不在 {bigMapInAllMapRect} 内,继续移动");
Logger.LogInformation("传送点不在当前大地图范围内,继续移动");
await MoveMapTo(x, y, maxMouseMove: 400);
await MoveMapTo(x, y);
await Delay(300, ct); // 等待地图移动完成
bigMapInAllMapRect = GetBigMapRect();
}
@@ -318,10 +238,8 @@ public class TpTask(CancellationToken ct)
/// </summary>
/// <param name="x">目标x坐标</param>
/// <param name="y">目标y坐标</param>
/// <param name="tolerance">允许误差,默认200</param>
/// <param name="maxIterations">最大尝试次数,默认30</param>
/// <param name="maxMouseMove">单次移动最大距离,默认250</param>
public async Task MoveMapTo(double x, double y, double tolerance = 200, int maxIterations = 30, int maxMouseMove = 250)
private async Task MoveMapTo(double x, double y)
{
// 获取当前地图中心点并计算到目标传送点的初始偏移
// await AdjustMapZoomLevel(mapZoomLevel);
@@ -333,7 +251,7 @@ public class TpTask(CancellationToken ct)
int moveSteps = 10;
double totalMoveMouseX = Double.MaxValue;
double totalMoveMouseY = Double.MaxValue;
for (int iteration = 0; iteration < maxIterations; iteration++)
for (int iteration = 0; iteration < _tpConfig.MaxIterations; iteration++)
{
// 尝试移动鼠标
await MouseMoveMap(moveMouseX, moveMouseY, moveSteps);
@@ -363,20 +281,22 @@ public class TpTask(CancellationToken ct)
totalMoveMouseY = Math.Abs(moveMouseY * yOffset / diffMapY);
double mouseDistance = Math.Sqrt(totalMoveMouseX * totalMoveMouseX + totalMoveMouseY * totalMoveMouseY);
if (_mapZoomEnabled)
if (_tpConfig.MapZoomEnabled)
{
// 调整地图缩放
// mapZoomLevel<5 才显示传送锚点和秘境; mapZoomLevel>1.7 可以避免点错传送锚点
double currentZoomLevel = GetBigMapZoomLevel(CaptureToRectArea());
double oldZoomLevel = currentZoomLevel;
while (mouseDistance > MapZoomOutDistance || mouseDistance < MapZoomInDistance)
while (mouseDistance > _tpConfig.MapZoomOutDistance || mouseDistance < _tpConfig.MapZoomInDistance)
{
bool zoomOut = mouseDistance > MapZoomOutDistance;
bool zoomIn = mouseDistance < MapZoomInDistance;
if (zoomOut && currentZoomLevel < 4.0 || zoomIn && currentZoomLevel > 2.7)
bool zoomOut = mouseDistance > _tpConfig.MapZoomOutDistance;
bool zoomIn = mouseDistance < _tpConfig.MapZoomInDistance;
if (zoomOut && currentZoomLevel < _tpConfig.MaxZoomLevel - 1.0
|| zoomIn && currentZoomLevel > _tpConfig.MinZoomLevel + 1.0)
{
await AdjustMapZoomLevel(zoomIn);
await Delay(50, ct);
currentZoomLevel = GetBigMapZoomLevel(CaptureToRectArea());
totalMoveMouseX *= oldZoomLevel / currentZoomLevel;
totalMoveMouseY *= oldZoomLevel / currentZoomLevel;
@@ -385,9 +305,9 @@ public class TpTask(CancellationToken ct)
}
else
{
double targetZoom = zoomIn ? 1.7 : 5.0;
double targetZoom = zoomIn ? _tpConfig.MinZoomLevel : _tpConfig.MaxZoomLevel;
// 考虑调整和识别误差,所以相差0.05就不再调整。
if (currentZoomLevel > 4.95 || currentZoomLevel < 1.75)
if (currentZoomLevel > _tpConfig.MaxZoomLevel - 0.05 || currentZoomLevel < _tpConfig.MinZoomLevel + 0.05)
{
break;
}
@@ -398,21 +318,20 @@ public class TpTask(CancellationToken ct)
}
// 非常接近目标点,不再进一步调整
if (mouseDistance < tolerance)
if (mouseDistance < _tpConfig.Tolerance)
{
Logger.LogInformation("移动 {I} 次鼠标后,已经接近目标点,不再移动地图。", iteration + 1);
break;
}
// 单次移动最大距离为 maxMouseMove
moveMouseX = (int)Math.Min(totalMoveMouseX, maxMouseMove * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset);
moveMouseY = (int)Math.Min(totalMoveMouseY, maxMouseMove * totalMoveMouseY / mouseDistance) * Math.Sign(yOffset);
moveMouseX = (int)Math.Min(totalMoveMouseX, _tpConfig.MaxMouseMove * totalMoveMouseX / mouseDistance) * Math.Sign(xOffset);
moveMouseY = (int)Math.Min(totalMoveMouseY, _tpConfig.MaxMouseMove * totalMoveMouseY / mouseDistance) * Math.Sign(yOffset);
double moveMouseLength = Math.Sqrt(moveMouseX * moveMouseX + moveMouseY * moveMouseY);
moveSteps = Math.Max((int)moveMouseLength / 10, 3); // 每次移动的步数最小为3,避免除0错误
}
else
{
Logger.LogDebug($"第 {iteration} 次移动鼠标失败,可能是点击了传送点或者其他交互对象。");
Logger.LogDebug($"第 {iteration + 1} 次移动鼠标失败,可能是点击了传送点或者其他交互对象。");
}
}
}
@@ -440,25 +359,26 @@ public class TpTask(CancellationToken ct)
/// 调整地图缩放级别以加速移动
/// </summary>
/// <param name="zoomIn">是否放大地图</param>
public async Task AdjustMapZoomLevel(bool zoomIn)
private async Task AdjustMapZoomLevel(bool zoomIn)
{
if (zoomIn)
{
GameCaptureRegion.GameRegionClick((rect, scale) => (zoomButtonX * scale, zoomInButtonY * scale));
GameCaptureRegion.GameRegionClick((rect, scale) => (_tpConfig.ZoomButtonX * scale, _tpConfig.ZoomInButtonY * scale));
}
else
{
GameCaptureRegion.GameRegionClick((rect, scale) => (zoomButtonX * scale, zoomOutButtonY * scale));
GameCaptureRegion.GameRegionClick((rect, scale) => (_tpConfig.ZoomButtonX * scale, _tpConfig.ZoomOutButtonY * scale));
}
await Delay(50, ct);
}
[Obsolete]
/// <summary>
/// 调整地图的缩放等级(整数缩放级别)。
/// </summary>
/// <param name="zoomLevel">目标等级:1-6。整数。随着数字变大地图越小,细节越少。</param>
[Obsolete]
public async Task AdjustMapZoomLevel(int zoomLevel)
{
for (int i = 0; i < 5; i++)
@@ -478,15 +398,15 @@ public class TpTask(CancellationToken ct)
/// </summary>
/// <param name="zoomLevel">当前缩放等级:1.0-6.0,浮点数。</param>
/// <param name="targetZoomLevel">目标缩放等级:1.0-6.0,浮点数。</param>
public async Task AdjustMapZoomLevel(double zoomLevel, double targetZoomLevel)
private async Task AdjustMapZoomLevel(double zoomLevel, double targetZoomLevel)
{
// Logger.LogInformation("调整地图缩放等级:{zoomLevel:0.000} -> {targetZoomLevel:0.000}", zoomLevel, targetZoomLevel);
int initialY = (int)(zoomStartY + (zoomEndY - zoomStartY) * (zoomLevel - 1) / 5d);
int targetY = (int)(zoomStartY + (zoomEndY - zoomStartY) * (targetZoomLevel - 1) / 5d);
await MouseClickAndMove(zoomButtonX, initialY, zoomButtonX, targetY);
int initialY = (int)(_tpConfig.ZoomStartY + (_tpConfig.ZoomEndY - _tpConfig.ZoomStartY) * (zoomLevel - 1) / 5d);
int targetY = (int)(_tpConfig.ZoomStartY + (_tpConfig.ZoomEndY - _tpConfig.ZoomStartY) * (targetZoomLevel - 1) / 5d);
await MouseClickAndMove(_tpConfig.ZoomButtonX, initialY, _tpConfig.ZoomButtonX, targetY);
}
public async Task MouseMoveMap(int pixelDeltaX, int pixelDeltaY, int steps = 10)
private async Task MouseMoveMap(int pixelDeltaX, int pixelDeltaY, int steps = 10)
{
// 确保不影响总移动距离
int totalX = 0;
@@ -506,8 +426,8 @@ public class TpTask(CancellationToken ct)
}
// 均匀分配多余的部分到前半段
int remainingX = (int)(pixelDeltaX - totalX);
int remainingY = (int)(pixelDeltaY - totalY);
int remainingX = (pixelDeltaX - totalX);
int remainingY = (pixelDeltaY - totalY);
for (int i = 0; i < steps / 2 + 1; i++)
{
stepX[i] += remainingX / (steps / 2 + 1) + ((remainingX % (steps / 2 + 1) > i) ? 0 : 1);
@@ -523,7 +443,7 @@ public class TpTask(CancellationToken ct)
for (var i = 0; i < steps; i++)
{
GlobalMethod.MoveMouseBy(stepX[i], stepY[i]);
await Delay(StepIntervalMilliseconds, ct);
await Delay(_tpConfig.StepIntervalMilliseconds, ct);
}
GlobalMethod.LeftButtonUp();
}
@@ -604,7 +524,7 @@ public class TpTask(CancellationToken ct)
}
/// <summary>
/// 获取最近的传送点位置
/// 获取最近的传送点位置和所处区域
/// </summary>
/// <param name="x"></param>
/// <param name="y"></param>
@@ -820,4 +740,4 @@ public class TpTask(CancellationToken ct)
// 1~6 的缩放等级
return (-5 * s) + 6;
}
}
}
@@ -325,7 +325,8 @@ namespace LogParse
(name: "最后小怪日期", value: ms => ms.LastSmallTime),
(name: "精英", value: ms => ms.EliteGameStatistics.ToString()),
(name: "精英详细", value: ms => ms.EliteDetails), (name: "最后精英日期", value: ms => ms.LastEliteTime),
(name: "总计锄地摩拉", value: ms => ms.TotalMoraKillingMonstersMora.ToString())
(name: "总计锄地摩拉", value: ms => ms.TotalMoraKillingMonstersMora.ToString()),
(name: "突发事件获取摩拉", value: ms => ms.EmergencyBonus)
];
//锄地部分新曾字段
(string name, Func<MoraStatistics, string> value)[] col2Configs=[..msColConfigs.ToList().Where(item=>item.name!="日期" && item.name!="最后小怪日期" && item.name!="最后精英日期"),
@@ -386,7 +387,7 @@ namespace LogParse
.OrderBy(group => group.Key)
.Reverse().ToList();
html.AppendLine($"<h2>按日锄地摩拉统计</h2>");
html.AppendLine($"<h2>按日摩拉收益统计</h2>");
html.AppendLine("<table>");
html.AppendLine(" <tr>");
@@ -25,6 +25,16 @@ namespace LogParse
public List<ActionItem> SmallMonsterActionItems =>
this.MonsterActionItems.Except(EliteMonsterActionItems).ToList();
public string EmergencyBonus
{
get
{
var ls = this.ActionItems.Where(item => item.ActionId == 28).ToList();
var count = ls.Count();
return ls.Sum(item=>item.Num)+((count==0 || count>=10)?"":$"({count}/10)");
}
}
public string LastEliteTime => EliteMonsterActionItems.MaxBy(item => item?.Time)?.Time ?? null;
public string LastSmallTime => SmallMonsterActionItems.MaxBy(item => item?.Time)?.Time ?? null;
@@ -50,8 +50,8 @@ public class TravelsDiaryDetailManager
var _temp = JsonSerializer.Deserialize<ApiResponse<ActionItem>>(File.ReadAllText(tddfile));
if (_temp != null)
{
//只统计杀怪的
actionItems.AddRange(_temp.Data.List.Where(item => item.ActionId == 37));
//统计杀怪或突发事件奖励
actionItems.AddRange(_temp.Data.List.Where(item => item.ActionId == 37 || item.ActionId == 28));
}
}
}
@@ -33,6 +33,15 @@ public class DirectoryHelper
private static void DeleteDirectory(DirectoryInfo directoryInfo)
{
//通过软链接生成的目录,直接删除该链接目录,而不涉及其文件本体
var attributes = directoryInfo.Attributes;
if ((attributes & FileAttributes.ReparsePoint) == FileAttributes.ReparsePoint)
{
directoryInfo.Delete();
return;
}
// 递归处理子目录
foreach (var subDirectory in directoryInfo.GetDirectories())
{
@@ -100,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);
}
}
}
+24 -22
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,31 +9,32 @@ 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 (OsVersionHelper.IsWindows11_OrGreater)
{
if (TaskContext.Instance().Config.CommonConfig.CurrentBackdropType == WindowBackdropType.Acrylic)
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))
{
window.Background = new SolidColorBrush(Colors.Transparent);
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Mica);
}
else if (WindowBackdrop.IsSupported(WindowBackdropType.Acrylic))
{
window.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0));
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Acrylic);
}
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))
{
WindowBackdrop.ApplyBackdrop(window, WindowBackdropType.Acrylic);
}
}
}
+2 -2
View File
@@ -93,14 +93,14 @@ public class UpdateService : IUpdateService
case CheckUpdateWindow.CheckUpdateWindowButton.Update:
{
// 唤起更新程序
string updaterExePath = Global.Absolute("updater.exe");
string updaterExePath = Global.Absolute("BetterGI.update.exe");
if (!File.Exists(updaterExePath))
{
await MessageBox.ErrorAsync("更新程序不存在,请选择其他更新方式!");
return;
}
// 启动
Process.Start(updaterExePath);
Process.Start(updaterExePath, "-I");
// 退出程序
Application.Current.Shutdown();
@@ -18,9 +18,9 @@
FontFamily="{StaticResource TextThemeFontFamily}"
Foreground="{DynamicResource TextFillColorPrimaryBrush}"
mc:Ignorable="d">
<Grid Margin="22,16,22,12">
<Grid Margin="22,16,8,12">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*" MaxWidth="300" />
<ColumnDefinition Width="2*" />
</Grid.ColumnDefinitions>
@@ -156,10 +156,9 @@
</ContentControl>-->
<!-- 右侧配置 -->
<DockPanel Grid.Column="1" Margin="20,0,0,0">
<DockPanel Grid.Column="1" Margin="16,0,0,0">
<StackPanel Margin="0,0,0,10" DockPanel.Dock="Top">
<Grid>
<Grid Margin="0,0,9,0">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
@@ -199,7 +198,7 @@
</StackPanel>
<ScrollViewer>
<StackPanel>
<StackPanel Margin="0,0,18,0">
<!-- 合成树脂 -->
<TextBlock Margin="4,0,0,4"
FontSize="14"
@@ -267,7 +266,7 @@
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
Margin="0,0,20,0"
IsChecked="{Binding SelectedConfig.WeeklyDomainEnabled, Converter={StaticResource InverseBooleanConverter}, Mode=TwoWay}" />
</Grid>
</ui:CardExpander.Header>
@@ -361,7 +360,7 @@
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
Margin="0,0,20,0"
IsChecked="{Binding SelectedConfig.WeeklyDomainEnabled, Mode=TwoWay}" />
</Grid>
</ui:CardExpander.Header>
@@ -472,6 +471,41 @@
</StackPanel>
</ui:CardExpander>
<ui:CardControl Margin="0,0,0,12">
<ui:CardControl.Icon>
<ui:FontIcon Glyph="&#xf14e;" Style="{StaticResource FaFontIconStyle}" />
</ui:CardControl.Icon>
<ui:CardControl.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="结束后自动分解圣遗物"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="需要分解圣遗物的最高星级"
TextWrapping="Wrap" />
</Grid>
</ui:CardControl.Header>
<StackPanel Orientation="Horizontal">
<ComboBox
Width="80"
Margin="0,0,10,0"
ItemsSource="{Binding Source={x:Static pages:TaskSettingsPageViewModel.ArtifactSalvageStarList}}"
SelectedItem="{Binding Config.AutoDomainConfig.MaxArtifactStar, Mode=TwoWay}">
</ComboBox>
<ui:ToggleSwitch
Margin="0,0,36,0"
IsChecked="{Binding Config.AutoDomainConfig.AutoArtifactSalvage, Mode=TwoWay}" />
</StackPanel>
</ui:CardControl>
<!-- 领取奖励 -->
<TextBlock Margin="4,0,0,4"
FontSize="14"
@@ -504,7 +538,7 @@
SelectedItem="{Binding SelectedConfig.AdventurersGuildCountry, Mode=TwoWay}"
ItemsSource="{Binding AdventurersGuildCountry}" />
</ui:CardControl>
<ui:CardControl Margin="0,0,0,12">
<ui:CardControl.Icon>
<ui:FontIcon Glyph="&#xf14e;" Style="{StaticResource FaFontIconStyle}" />
@@ -527,13 +561,13 @@
TextWrapping="Wrap" />
</Grid>
</ui:CardControl.Header>
<ui:TextBox
MinWidth="150"
MaxWidth="800"
Margin="0,0,28,0"
Text="{Binding SelectedConfig.DailyRewardPartyName, Mode=TwoWay}"
PlaceholderText="填写好感队名称"
TextWrapping="Wrap" />
<ui:TextBox
MinWidth="150"
MaxWidth="800"
Margin="0,0,28,0"
Text="{Binding SelectedConfig.DailyRewardPartyName, Mode=TwoWay}"
PlaceholderText="填写好感队名称"
TextWrapping="Wrap" />
</ui:CardControl>
<!-- 可以继续添加其他设置项 -->
@@ -428,7 +428,34 @@
</b:Interaction.Triggers>
</ComboBox>
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="根据技能CD优化出招人员"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="根据填入人或人和cd,来决定当此人元素战技cd未结束时,跳过此人出招,来优化战斗流程,可填入人名或人名数字(用逗号分隔),多种用分号分隔,例如:白术;钟离,12;,如果人名,则用内置cd检查(或填入数字也小于0),如果是人名和数字,则把数字当做出招cd(秒)。"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="180"
MaxWidth="800"
Margin="0,0,36,0"
Text="{Binding Config.AutoFightConfig.ActionSchedulerByCd, Mode=TwoWay}"
TextWrapping="Wrap" />
</Grid>
<!--内嵌的设置-->
<Separator Margin="-18,0" BorderThickness="0,1,0,0" />
<Grid Margin="16,10,52,0">
@@ -1011,14 +1038,14 @@
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="可以选择要分解到圣遗物的最高星级"
Text="需要分解圣遗物的最高星级"
TextWrapping="Wrap" />
<ComboBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Width="80"
Margin="0,0,10,0"
ItemsSource="{Binding ArtifactSalvageStarList, Mode=TwoWay}"
ItemsSource="{Binding Source={x:Static pages:TaskSettingsPageViewModel.ArtifactSalvageStarList}}"
SelectedItem="{Binding Config.AutoDomainConfig.MaxArtifactStar, Mode=TwoWay}">
</ComboBox>
<ui:ToggleSwitch Grid.Row="0"
@@ -778,7 +778,166 @@
</Grid>
</StackPanel>
</ui:CardExpander>
<!-- 快速传送 -->
<ui:CardExpander Margin="0,0,0,12" ContentPadding="0">
<ui:CardExpander.Icon>
<ui:FontIcon Glyph="&#xf3c5;" Style="{StaticResource FaFontIconStyle}" />
</ui:CardExpander.Icon>
<ui:CardExpander.Header>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="地图移动"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="传送点不在当前地图中时,传送过程中移动地图"
TextWrapping="Wrap" />
</Grid>
</ui:CardExpander.Header>
<StackPanel>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="地图移动过程中是否缩放地图"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="建议开启,关闭该设置可能在运行部分脚本时发生错误"
TextWrapping="Wrap" />
<ui:ToggleSwitch Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
Margin="0,0,36,0"
IsChecked="{Binding Config.TpConfig.MapZoomEnabled, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="单次鼠标移动的最大距离"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="过大可能会导致鼠标移动出窗口,单位:像素"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="90"
Margin="0,0,36,0"
Text="{Binding Config.TpConfig.MaxMouseMove, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="地图缩小的距离"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="大于这个距离会缩小地图以加快传送,单位:像素"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="90"
Margin="0,0,36,0"
Text="{Binding Config.TpConfig.MapZoomOutDistance, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="地图放大的距离"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="小于这个距离会放大地图以提高移动的精度,单位:像素"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="90"
Margin="0,0,36,0"
Text="{Binding Config.TpConfig.MapZoomInDistance, Mode=TwoWay}" />
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="鼠标移动的时间间隔"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="数字越小移动鼠标的速度越快,如果移动地图时产生卡顿,请提高这个数值,单位:毫秒"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="90"
Margin="0,0,36,0"
Text="{Binding Config.TpConfig.StepIntervalMilliseconds, Mode=TwoWay}" />
</Grid>
</StackPanel>
</ui:CardExpander>
<!-- 自动烹饪 -->
<ui:CardControl Margin="0,0,0,12">
<ui:CardControl.Icon>
@@ -370,6 +370,34 @@
</b:Interaction.Triggers>
</ComboBox>
</Grid>
<Grid Margin="16">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<ui:TextBlock Grid.Row="0"
Grid.Column="0"
FontTypography="Body"
Text="根据技能CD优化出招人员"
TextWrapping="Wrap" />
<ui:TextBlock Grid.Row="1"
Grid.Column="0"
Foreground="{ui:ThemeResource TextFillColorTertiaryBrush}"
Text="根据填入人或人和cd,来决定当此人元素战技cd未结束时,跳过此人出招,来优化战斗流程,可填入人名或人名数字(用逗号分隔),多种用分号分隔,例如:白术;钟离,12;,如果人名,则用内置cd检查(或填入数字也小于0),如果是人名和数字,则把数字当做出招cd(秒)。"
TextWrapping="Wrap" />
<ui:TextBox Grid.Row="0"
Grid.RowSpan="2"
Grid.Column="1"
MinWidth="180"
MaxWidth="800"
Margin="0,0,36,0"
Text="{Binding PathingConfig.AutoFightConfig.ActionSchedulerByCd, Mode=TwoWay}"
TextWrapping="Wrap" />
</Grid>
<Grid Margin="16">
<ui:CardExpander Margin="0,0,0,12"
@@ -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);
}
}
@@ -97,14 +100,25 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
[RelayCommand]
private async Task OnLoaded()
{
// 自动处理目录配置
await Patch1();
// 预热OCR
await OcrPreheating();
// 首次运行自动初始化绑定
InitKeyBinding();
if (Environment.GetCommandLineArgs().Length > 1)
{
return;
}
// 自动处理目录配置
await Patch1();
// 首次运行
if (Config.CommonConfig.IsFirstRun)
{
// 自动初始化键位绑定
InitKeyBinding();
Config.AutoFightConfig.TeamNames = ""; // 此配置以后无用
Config.CommonConfig.IsFirstRun = false;
}
// 检查更新
await App.GetService<IUpdateService>()!.CheckUpdateAsync(new UpdateOption());
@@ -119,28 +133,24 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
ScriptRepoUpdater.Instance.AutoUpdate();
}
private void InitKeyBinding()
{
if (Config.CommonConfig.IsFirstRun)
try
{
try
var kbVm = App.GetService<KeyBindingsSettingsPageViewModel>();
if (kbVm != null)
{
var kbVm = App.GetService<KeyBindingsSettingsPageViewModel>();
if (kbVm != null)
{
kbVm.FetchFromRegistryCommand.Execute(null);
}
kbVm.FetchFromRegistryCommand.Execute(null);
}
catch (Exception e)
{
_logger.LogError("首次运行自动初始化按键绑定异常:" + e.Source + "\r\n--" + Environment.NewLine + e.StackTrace + "\r\n---" + Environment.NewLine + e.Message);
MessageBox.Error("读取原神键位并设置键位绑定数据时发生异常:" + e.Message + ",后续可以手动设置");
}
}
}
catch (Exception e)
{
_logger.LogError("首次运行自动初始化按键绑定异常:" + e.Source + "\r\n--" + Environment.NewLine + e.StackTrace + "\r\n---" + Environment.NewLine + e.Message);
MessageBox.Error("读取原神键位并设置键位绑定数据时发生异常:" + e.Message + ",后续可以手动设置");
}
}
/**
* 不同的安装目录处理
@@ -148,21 +158,20 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
*/
private async Task Patch1()
{
if (Directory.Exists(Global.Absolute("BetterGI"))
if (Directory.Exists(Global.Absolute("BetterGI"))
// && File.Exists(Global.Absolute("BetterGI/BetterGI.exe"))
&& 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"));
}
}
}
@@ -94,21 +94,26 @@ public partial class HomePageViewModel : ObservableObject, INavigationAware, IVi
}
}
});
var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
if (args[1].Contains("start"))
{
_ = OnStartTriggerAsync();
}
}
}
[RelayCommand]
private void OnLoaded()
{
// OnTest();
var args = Environment.GetCommandLineArgs();
if (args.Length > 1)
{
if (args[1].Equals("start"))
{
_ = OnStartTriggerAsync();
}
else if (args[1].Equals("startOneDragon"))
{
var odVm = App.GetService<OneDragonFlowViewModel>();
odVm?.OneKeyExecuteCommand.Execute(null);
}
}
}
private void OnClosed()
@@ -62,6 +62,8 @@ public partial class OneDragonFlowViewModel : ObservableObject, INavigationAware
[ObservableProperty]
private List<string> _domainNameList = ["", ..MapLazyAssets.Instance.DomainNameList];
public AllConfig Config { get; set; } = TaskContext.Instance().Config;
public OneDragonFlowViewModel()
{
@@ -83,6 +85,7 @@ public partial class OneDragonFlowViewModel : ObservableObject, INavigationAware
}
}
};
InitConfigList();
}
public void OnNavigatedTo()
@@ -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)))
@@ -98,9 +98,8 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
[ObservableProperty]
private List<string> _domainNameList;
[ObservableProperty]
private List<string> _artifactSalvageStarList = ["4", "3", "2", "1"];
public static List<string> ArtifactSalvageStarList = ["4", "3", "2", "1"];
[ObservableProperty]
private List<string> _autoMusicLevelList = ["传说", "大师", "困难", "普通", "所有"];