mirror of
https://github.com/babalae/better-genshin-impact
synced 2025-01-09 04:19:47 +08:00
add submit one goods in auto skip
This commit is contained in:
parent
b9ea59cc04
commit
9cc647196c
BIN
BetterGenshinImpact/Assets/keqin.jpg
Normal file
BIN
BetterGenshinImpact/Assets/keqin.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 117 KiB |
@ -24,6 +24,10 @@
|
||||
<Content Include="Assets\*.ico" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Remove="Assets\keqin.jpg" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.2" />
|
||||
<PackageReference Include="H.InputSimulator" Version="1.4.1" />
|
||||
@ -335,6 +339,9 @@
|
||||
<None Update="GameTask\AutoSkip\Assets\1920x1080\stop_auto.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\AutoSkip\Assets\1920x1080\submit_goods.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\AutoSkip\Assets\1920x1080\submit_icon_exclamation.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
@ -356,6 +363,54 @@
|
||||
<None Update="GameTask\AutoWood\Assets\1920x1080\TheBoonOfTheElderTree.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\btn_black_confirm.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\btn_white_cancel.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\btn_white_confirm.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\collect.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\comfirm_btn1.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\comfirm_btn2.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\icon_daily_reward.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\icon_exclamation.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\icon_explore.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\icon_option.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\menu.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\page_close.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\primogem.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\re.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\stop_auto.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\Common\Element\Assets\1920x1080\submit_icon_exclamation.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
<None Update="GameTask\QuickTeleport\Assets\1920x1080\Domain.png">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</None>
|
||||
|
Binary file not shown.
After Width: | Height: | Size: 482 B |
@ -24,6 +24,9 @@ public class AutoSkipAssets
|
||||
|
||||
public RecognitionObject PrimogemRo;
|
||||
|
||||
public RecognitionObject SubmitExclamationIconRo;
|
||||
public RecognitionObject SubmitGoodsRo;
|
||||
|
||||
//public Mat BinaryStopAutoButtonMat;
|
||||
|
||||
public AutoSkipAssets()
|
||||
@ -142,5 +145,23 @@ public class AutoSkipAssets
|
||||
RegionOfInterest = new Rect(0, info.CaptureAreaRect.Height / 3, info.CaptureAreaRect.Width, info.CaptureAreaRect.Height / 3),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
// 提交物品
|
||||
SubmitExclamationIconRo = new RecognitionObject
|
||||
{
|
||||
Name = "SubmitExclamationIconRo",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoSkip", "submit_icon_exclamation.png"),
|
||||
RegionOfInterest = new Rect(0, 0, info.CaptureAreaRect.Width, info.CaptureAreaRect.Height / 4),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
SubmitGoodsRo = new RecognitionObject
|
||||
{
|
||||
Name = "SubmitGoods",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage("AutoSkip", "submit_goods.png"),
|
||||
RegionOfInterest = new Rect(0, 0, info.CaptureAreaRect.Width/2, info.CaptureAreaRect.Height / 3),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
}
|
||||
}
|
@ -17,6 +17,8 @@ using System.Linq;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using BetterGenshinImpact.GameTask.Common;
|
||||
using BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
using Vanara.PInvoke;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
||||
@ -159,14 +161,17 @@ public class AutoSkipTrigger : ITaskTrigger
|
||||
if (!isPlaying)
|
||||
{
|
||||
// 关闭弹出页
|
||||
content.CaptureRectArea.Find(_autoSkipAssets.PageCloseRo, pageCloseRoRa =>
|
||||
{
|
||||
pageCloseRoRa.ClickCenter();
|
||||
ClosePopupPage(content);
|
||||
|
||||
AutoSkipLog("关闭弹出页");
|
||||
isPlaying = true;
|
||||
pageCloseRoRa.Dispose();
|
||||
});
|
||||
// 自动剧情点击3s内判断
|
||||
if ((DateTime.Now - _prevClickTime).TotalMilliseconds < 3000)
|
||||
{
|
||||
// 提交物品
|
||||
if (SubmitGoods(content))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -282,6 +287,7 @@ public class AutoSkipTrigger : ITaskTrigger
|
||||
/// <param name="foundIconRectArea"></param>
|
||||
/// <param name="chatOptionTextWidth"></param>
|
||||
/// <returns></returns>
|
||||
[Obsolete]
|
||||
private string GetOrangeOptionText(Mat captureMat, RectArea foundIconRectArea, int chatOptionTextWidth)
|
||||
{
|
||||
var textRect = new Rect(foundIconRectArea.X + foundIconRectArea.Width, foundIconRectArea.Y, chatOptionTextWidth, foundIconRectArea.Height);
|
||||
@ -418,6 +424,7 @@ public class AutoSkipTrigger : ITaskTrigger
|
||||
}
|
||||
else if (item.Text.Contains("探索派遣"))
|
||||
{
|
||||
ClickOcrRegion(clickOffset, item);
|
||||
Thread.Sleep(800); // 等待探索派遣界面打开
|
||||
new OneKeyExpeditionTask().Run(_autoSkipAssets);
|
||||
}
|
||||
@ -482,4 +489,58 @@ public class AutoSkipTrigger : ITaskTrigger
|
||||
|
||||
_prevClickTime = DateTime.Now;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 关闭弹出页
|
||||
/// </summary>
|
||||
/// <param name="content"></param>
|
||||
private void ClosePopupPage(CaptureContent content)
|
||||
{
|
||||
content.CaptureRectArea.Find(_autoSkipAssets.PageCloseRo, pageCloseRoRa =>
|
||||
{
|
||||
pageCloseRoRa.ClickCenter();
|
||||
|
||||
AutoSkipLog("关闭弹出页");
|
||||
pageCloseRoRa.Dispose();
|
||||
});
|
||||
}
|
||||
|
||||
private bool SubmitGoods(CaptureContent content)
|
||||
{
|
||||
var exclamationRa = content.CaptureRectArea.Find(_autoSkipAssets.SubmitExclamationIconRo);
|
||||
if (!exclamationRa.IsEmpty())
|
||||
{
|
||||
// 最多3个物品 现在就支持一个
|
||||
var goods = content.CaptureRectArea.Find(_autoSkipAssets.SubmitGoodsRo);
|
||||
if (!goods.IsEmpty())
|
||||
{
|
||||
goods.ClickCenter();
|
||||
_logger.LogInformation("提交物品:{Text}", "1. 选择物品");
|
||||
|
||||
TaskControl.Sleep(800);
|
||||
content = TaskControl.CaptureToContent();
|
||||
|
||||
var btnBlackConfirmRa = content.CaptureRectArea.Find(ElementAssets.Instance().BtnBlackConfirm);
|
||||
if (!btnBlackConfirmRa.IsEmpty())
|
||||
{
|
||||
btnBlackConfirmRa.ClickCenter();
|
||||
_logger.LogInformation("提交物品:{Text}", "2. 放入");
|
||||
|
||||
TaskControl.Sleep(800);
|
||||
content = TaskControl.CaptureToContent();
|
||||
|
||||
var btnWhiteConfirmRa = content.CaptureRectArea.Find(ElementAssets.Instance().BtnWhiteConfirm);
|
||||
if (!btnWhiteConfirmRa.IsEmpty())
|
||||
{
|
||||
btnWhiteConfirmRa.ClickCenter();
|
||||
_logger.LogInformation("提交物品:{Text}", "3. 交付");
|
||||
|
||||
VisionContext.Instance().DrawContent.ClearAll();
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
Binary file not shown.
After Width: | Height: | Size: 1.7 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.4 KiB |
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,57 @@
|
||||
using System.Collections.Generic;
|
||||
using BetterGenshinImpact.Core.Recognition;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.Common.Element.Assets;
|
||||
|
||||
public class ElementAssets
|
||||
{
|
||||
public RecognitionObject BtnWhiteConfirm;
|
||||
public RecognitionObject BtnWhiteCancel;
|
||||
public RecognitionObject BtnBlackConfirm;
|
||||
|
||||
private ElementAssets()
|
||||
{
|
||||
var info = TaskContext.Instance().SystemInfo;
|
||||
|
||||
// 按钮
|
||||
BtnWhiteConfirm = new RecognitionObject
|
||||
{
|
||||
Name = "BtnWhiteConfirm",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "btn_white_confirm.png"),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
BtnWhiteCancel = new RecognitionObject
|
||||
{
|
||||
Name = "BtnWhiteCancel",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "btn_white_cancel.png"),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
BtnBlackConfirm = new RecognitionObject
|
||||
{
|
||||
Name = "BtnBlackConfirm",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"Common\Element", "btn_black_confirm.png"),
|
||||
DrawOnWindow = false
|
||||
}.InitTemplate();
|
||||
|
||||
}
|
||||
|
||||
|
||||
private static ElementAssets? _uniqueInstance;
|
||||
private static readonly object Locker = new();
|
||||
|
||||
public static ElementAssets Instance()
|
||||
{
|
||||
if (_uniqueInstance == null)
|
||||
{
|
||||
lock (Locker)
|
||||
{
|
||||
_uniqueInstance ??= new ElementAssets();
|
||||
}
|
||||
}
|
||||
return _uniqueInstance;
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
<Grid>
|
||||
<Border ClipToBounds="True" CornerRadius="8">
|
||||
<Border.Background>
|
||||
<ImageBrush ImageSource="pack://application:,,,/Assets/mona.jpg"
|
||||
<ImageBrush ImageSource="pack://application:,,,/Assets/keqin.jpg"
|
||||
RenderOptions.BitmapScalingMode="HighQuality"
|
||||
Stretch="UniformToFill" />
|
||||
</Border.Background>
|
||||
|
Loading…
Reference in New Issue
Block a user