diff --git a/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs b/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs index f10e2397..aa6c06e2 100644 --- a/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs +++ b/BetterGenshinImpact/Core/Config/MaskWindowConfig.cs @@ -34,7 +34,7 @@ public partial class MaskWindowConfig : ObservableObject /// /// 日志窗口位置与大小 /// - [ObservableProperty] private Rect _logBoxLocation = Rect.Empty; + [ObservableProperty] private RectConfig _logBoxLocation = new(); /// /// 控件是否锁定(拖拽移动等) @@ -50,7 +50,6 @@ public partial class MaskWindowConfig : ObservableObject /// /// 1080p下UID遮盖的位置与大小 /// - [JsonIgnore] - public Rect UidCoverRect = new(1695, 1052, 168, 22); + public RectConfig UidCoverRect { get; set; } = new(1695, 1052, 168, 22); } } \ No newline at end of file diff --git a/BetterGenshinImpact/Core/Config/RectConfig.cs b/BetterGenshinImpact/Core/Config/RectConfig.cs new file mode 100644 index 00000000..05443c74 --- /dev/null +++ b/BetterGenshinImpact/Core/Config/RectConfig.cs @@ -0,0 +1,28 @@ +using OpenCvSharp; + +namespace BetterGenshinImpact.Core.Config; + +public class RectConfig +{ + public int X { get; set; } + public int Y { get; set; } + public int Width { get; set; } + public int Height { get; set; } + + public RectConfig() + { + } + + public RectConfig(int x, int y, int width, int height) + { + X = x; + Y = y; + Width = width; + Height = height; + } + + public Rect ToRect() + { + return new Rect(X, Y, Width, Height); + } +} \ No newline at end of file diff --git a/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingConfig.cs b/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingConfig.cs index e5fd73cf..0b34ad69 100644 --- a/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingConfig.cs +++ b/BetterGenshinImpact/GameTask/AutoFishing/AutoFishingConfig.cs @@ -19,11 +19,11 @@ public partial class AutoFishingConfig : ObservableObject /// [ObservableProperty] private bool _enabled = false; - /// - /// 鱼儿上钩文字识别区域 - /// 暂时无用 - /// - [ObservableProperty] private Rect _fishHookedRecognitionArea = Rect.Empty; + ///// + ///// 鱼儿上钩文字识别区域 + ///// 暂时无用 + ///// + //[ObservableProperty] private Rect _fishHookedRecognitionArea = Rect.Empty; /// /// 自动抛竿是否启用 diff --git a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/AutoGeniusInvokationConfig.cs b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/AutoGeniusInvokationConfig.cs index 2c3df50b..36ca89f0 100644 --- a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/AutoGeniusInvokationConfig.cs +++ b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/AutoGeniusInvokationConfig.cs @@ -5,6 +5,7 @@ using System.Text; using System.Threading.Tasks; using OpenCvSharp; +using BetterGenshinImpact.Core.Config; namespace BetterGenshinImpact.GameTask.AutoGeniusInvokation; @@ -18,7 +19,7 @@ public partial class AutoGeniusInvokationConfig : ObservableObject [ObservableProperty] private int _sleepDelay = 0; - public List DefaultCharacterCardRects { get;} = new List() + public List DefaultCharacterCardRects { get; set; } = new() { new(667, 632, 165, 282), new(877, 632, 165, 282), @@ -29,25 +30,25 @@ public partial class AutoGeniusInvokationConfig : ObservableObject /// /// 骰子数量文字识别区域 /// - public Rect MyDiceCountRect { get; } = new(58, 632, 45, 47); // 42,47 + public RectConfig MyDiceCountRect { get; set; } = new(58, 632, 45, 47); // 42,47 - /// - /// 角色卡牌区域向左扩展距离,包含HP区域 - /// - public int CharacterCardLeftExtend { get; } = 20; + ///// + ///// 角色卡牌区域向左扩展距离,包含HP区域 + ///// + //public int CharacterCardLeftExtend { get; } = 20; - /// - /// 角色卡牌区域向右扩展距离,包含充能区域 - /// - public int CharacterCardRightExtend { get; } = 14; + ///// + ///// 角色卡牌区域向右扩展距离,包含充能区域 + ///// + //public int CharacterCardRightExtend { get; } = 14; /// /// 出战角色卡牌区域向上或者向下的距离差 /// - public int ActiveCharacterCardSpace { get; } = 41; + public int ActiveCharacterCardSpace { get; set; } = 41; /// /// HP区域 在 角色卡牌区域 的相对位置 /// - public Rect CharacterCardExtendHpRect { get; } = new(-20, 0, 60, 55); + public RectConfig CharacterCardExtendHpRect { get; } = new(-20, 0, 60, 55); } \ No newline at end of file diff --git a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs index 487a9f79..d3ddea4d 100644 --- a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs +++ b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/GeniusInvokationControl.cs @@ -1205,7 +1205,7 @@ private static void OutputImage(Duel duel, List rects, Mat bottomMat, int public int GetDiceCountByOcr() { var srcMat = CaptureGameGreyMat(); - var diceCountMap = new Mat(srcMat, _config.MyDiceCountRect); + var diceCountMap = new Mat(srcMat, _config.MyDiceCountRect.ToRect()); var text = OcrFactory.Paddle.Ocr(diceCountMap); text = text.Replace(" ", ""); _logger.LogInformation("通过OCR识别当前骰子数量: {Text}", text); diff --git a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/Model/Duel.cs b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/Model/Duel.cs index cf9ef3c8..42c7030d 100644 --- a/BetterGenshinImpact/GameTask/AutoGeniusInvokation/Model/Duel.cs +++ b/BetterGenshinImpact/GameTask/AutoGeniusInvokation/Model/Duel.cs @@ -89,7 +89,7 @@ public void Run(GeniusInvokationTaskParam taskParam) var assetScale = TaskContext.Instance().SystemInfo.AssetScale; for (var i = 0; i < defaultCharacterCardRects.Count; i++) { - CharacterCardRects.Add(defaultCharacterCardRects[i].Multiply(assetScale)); + CharacterCardRects.Add(defaultCharacterCardRects[i].ToRect().Multiply(assetScale)); } _logger.LogInformation("获取角色区域失败,使用默认区域"); diff --git a/BetterGenshinImpact/Service/ConfigService.cs b/BetterGenshinImpact/Service/ConfigService.cs index 7d957437..bbc05c18 100644 --- a/BetterGenshinImpact/Service/ConfigService.cs +++ b/BetterGenshinImpact/Service/ConfigService.cs @@ -17,7 +17,8 @@ public class ConfigService : IConfigService NumberHandling = System.Text.Json.Serialization.JsonNumberHandling.AllowNamedFloatingPointLiterals, Encoder = System.Text.Encodings.Web.JavaScriptEncoder.UnsafeRelaxedJsonEscaping, PropertyNamingPolicy = JsonNamingPolicy.CamelCase, - WriteIndented = true + WriteIndented = true, + AllowTrailingCommas = true }; ///