-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a801bb2
commit a84c94c
Showing
13 changed files
with
237 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using OpenCvSharp; | ||
|
||
namespace BetterGenshinImpact.Test.Simple; | ||
|
||
internal class AutoCookTest | ||
{ | ||
public static void Test() | ||
{ | ||
var img = new Mat(@"E:\HuiTask\更好的原神\自动烹饪\2.png"); | ||
Cv2.CvtColor(img, img, ColorConversionCodes.BGR2RGB); | ||
var img2 = new Mat(); | ||
// Cv2.InRange(img, new Scalar(255, 192, 64), new Scalar(255, 192, 64), img2); | ||
Cv2.InRange(img, new Scalar(255, 255, 192), new Scalar(255, 255, 192), img2); | ||
|
||
Cv2.ImShow("img", img2); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using BetterGenshinImpact.Core.Recognition.OpenCv; | ||
using BetterGenshinImpact.GameTask.Common.Element.Assets; | ||
using Microsoft.Extensions.Logging; | ||
using OpenCvSharp; | ||
using System.Linq; | ||
|
||
namespace BetterGenshinImpact.GameTask.AutoCook; | ||
|
||
public class AutoCookTrigger : ITaskTrigger | ||
{ | ||
private readonly ILogger<AutoCookTrigger> _logger = App.GetLogger<AutoCookTrigger>(); | ||
|
||
public string Name => "自动烹饪"; | ||
public bool IsEnabled { get; set; } | ||
public int Priority => 50; | ||
public bool IsExclusive { get; set; } | ||
|
||
public void Init() | ||
{ | ||
IsEnabled = TaskContext.Instance().Config.AutoCookConfig.Enabled; | ||
IsExclusive = false; | ||
} | ||
|
||
public void OnCapture(CaptureContent content) | ||
{ | ||
// 判断是否处于烹饪界面 | ||
IsExclusive = false; | ||
content.CaptureRectArea.Find(ElementAssets.Instance.UiLeftTopCookIcon, foundRectArea => | ||
{ | ||
IsExclusive = true; | ||
var captureRect = TaskContext.Instance().SystemInfo.ScaleMax1080PCaptureRect; | ||
using var region = content.CaptureRectArea.DeriveCrop(0, captureRect.Height / 2, captureRect.Width, captureRect.Height / 2); | ||
var perfectBarRects = ContoursHelper.FindSpecifyColorRects(region.SrcMat, new Scalar(255, 192, 64), 0, 8); | ||
if (perfectBarRects.Count >= 2) | ||
{ | ||
// 点击烹饪按钮 | ||
var btnList = ContoursHelper.FindSpecifyColorRects(region.SrcMat, new Scalar(255, 255, 192), 12, 12); | ||
if (btnList.Count >= 1) | ||
{ | ||
if (btnList.Count > 1) | ||
{ | ||
_logger.LogWarning("自动烹饪:{Text}", "识别到多个结束烹饪按钮"); | ||
btnList = [.. btnList.OrderByDescending(r => r.Width)]; | ||
} | ||
var btn = btnList[0]; | ||
var x = btn.X + btn.Width / 2; | ||
var y = btn.Y + btn.Height / 2; | ||
region.ClickTo(x, y); | ||
_logger.LogInformation("自动烹饪:{Text}", "点击结束按钮"); | ||
} | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using CommunityToolkit.Mvvm.ComponentModel; | ||
using System; | ||
|
||
namespace BetterGenshinImpact.GameTask.AutoCook; | ||
|
||
/// <summary> | ||
///自动烹饪配置 | ||
/// </summary> | ||
[Serializable] | ||
public partial class AutoCookConfig : ObservableObject | ||
{ | ||
/// <summary> | ||
/// 触发器是否启用 | ||
/// </summary> | ||
[ObservableProperty] | ||
private bool _enabled = false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+2.05 KB
...enshinImpact/GameTask/Common/Element/Assets/1920x1080/ui_left_top_cook_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.