mirror of
https://github.com/babalae/better-genshin-impact.git
synced 2026-05-21 09:45:48 +08:00
Merge branch 'babalae:main' into main
This commit is contained in:
@@ -7,6 +7,7 @@ using BetterGenshinImpact.GameTask.AutoGeniusInvokation;
|
||||
using BetterGenshinImpact.GameTask.AutoPick;
|
||||
using BetterGenshinImpact.GameTask.AutoSkip;
|
||||
using BetterGenshinImpact.GameTask.AutoWood;
|
||||
using BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
using BetterGenshinImpact.GameTask.QuickTeleport;
|
||||
using BetterGenshinImpact.Service.Notification;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
@@ -132,6 +133,11 @@ public partial class AllConfig : ObservableObject
|
||||
/// 自动战斗配置
|
||||
/// </summary>
|
||||
public AutoFightConfig AutoFightConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动乐曲配置 - 千音雅集
|
||||
/// </summary>
|
||||
public AutoMusicGameConfig AutoMusicGameConfig { get; set; } = new();
|
||||
|
||||
/// <summary>
|
||||
/// 自动秘境配置
|
||||
@@ -193,6 +199,7 @@ public partial class AllConfig : ObservableObject
|
||||
AutoWoodConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoFightConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoDomainConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
AutoMusicGameConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
|
||||
ScriptConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
PathingConditionConfig.PropertyChanged += OnAnyPropertyChanged;
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 4.0 KiB |
@@ -11,6 +11,10 @@ public class AutoMusicAssets : BaseAssets<AutoMusicAssets>
|
||||
public RecognitionObject BtnPause;
|
||||
public RecognitionObject AlbumMusicComplate;
|
||||
public RecognitionObject BtnList;
|
||||
public RecognitionObject MusicCanorusLevel1;
|
||||
public RecognitionObject MusicCanorusLevel2;
|
||||
public RecognitionObject MusicCanorusLevel3;
|
||||
public RecognitionObject MusicCanorusLevel4;
|
||||
|
||||
private AutoMusicAssets()
|
||||
{
|
||||
@@ -42,5 +46,39 @@ public class AutoMusicAssets : BaseAssets<AutoMusicAssets>
|
||||
TemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "btn_list.png"),
|
||||
RegionOfInterest = CaptureRect.CutRightBottom(0.4, 0.2),
|
||||
}.InitTemplate();
|
||||
|
||||
var musicCanorusTemplateImageMat = GameTaskManager.LoadAssetImage(@"AutoMusicGame", "music_canorus.png");
|
||||
MusicCanorusLevel1 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel1",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(430 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel2 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel2",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(520 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel3 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel3",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(610 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
MusicCanorusLevel4 = new RecognitionObject
|
||||
{
|
||||
Name = "MusicCanorusLevel4",
|
||||
RecognitionType = RecognitionTypes.TemplateMatch,
|
||||
TemplateImageMat = musicCanorusTemplateImageMat,
|
||||
RegionOfInterest = new Rect((int)(450 * AssetScale), (int)(690 * AssetScale), (int)(200 * AssetScale),
|
||||
(int)(60 * AssetScale)),
|
||||
}.InitTemplate();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.AutoMusicGame.Assets;
|
||||
@@ -39,62 +40,95 @@ public class AutoAlbumTask(AutoMusicGameParam taskParam) : ISoloTask
|
||||
{
|
||||
throw new Exception("当前未处于专辑界面,请在专辑界面运行本任务");
|
||||
}
|
||||
|
||||
// 12个音乐
|
||||
for (int i = 0; i < 13; i++)
|
||||
|
||||
var musicLevel = TaskContext.Instance().Config.AutoMusicGameConfig.MusicLevel;
|
||||
if (string.IsNullOrEmpty(musicLevel))
|
||||
{
|
||||
musicLevel = "传说";
|
||||
}
|
||||
Logger.LogInformation("自动音游乐曲难度等级:{Text}", musicLevel);
|
||||
|
||||
// 遍历4个难度等级
|
||||
var defaultDifficultyLevels = new[]
|
||||
{
|
||||
("普通", 480, 600, AutoMusicAssets.Instance.MusicCanorusLevel1),
|
||||
("困难", 800, 600, AutoMusicAssets.Instance.MusicCanorusLevel2),
|
||||
("大师", 1150, 600, AutoMusicAssets.Instance.MusicCanorusLevel3),
|
||||
("传说", 1400, 600, AutoMusicAssets.Instance.MusicCanorusLevel4)
|
||||
};
|
||||
|
||||
var difficultyLevels = defaultDifficultyLevels;
|
||||
if (musicLevel != "所有")
|
||||
{
|
||||
difficultyLevels = [Array.Find(defaultDifficultyLevels, level => level.Item1 == musicLevel)];
|
||||
}
|
||||
|
||||
using var doneRa = CaptureToRectArea().Find(AutoMusicAssets.Instance.AlbumMusicComplate);
|
||||
if (doneRa.IsExist())
|
||||
foreach (var (difficultyName, xPos, yPos, canorusAsset) in difficultyLevels)
|
||||
{
|
||||
Logger.LogInformation("开始演奏{Difficulty}难度的乐曲", difficultyName);
|
||||
|
||||
// 每个难度12首曲子
|
||||
for (int i = 0; i < 13; i++)
|
||||
{
|
||||
Logger.LogInformation("当前乐曲{Num}所有奖励已领取,切换下一首", i + 1);
|
||||
using var canoraRa = CaptureToRectArea().Find(canorusAsset);
|
||||
if (canoraRa.IsExist())
|
||||
{
|
||||
Logger.LogInformation("乐曲{Num} - {Difficulty}级别:已完成【大音天籁】,切换下一首", i + 1, difficultyName);
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.LogInformation("第{Num}首{Difficulty}难度的乐曲:{Message}", i + 1, difficultyName, "没有完成【大音天籁】");
|
||||
|
||||
// 点击确认按钮
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(800, ct);
|
||||
|
||||
// 选择难度
|
||||
GameCaptureRegion.GameRegion1080PPosClick(xPos, yPos);
|
||||
await Delay(200, ct);
|
||||
|
||||
// 开始演奏
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(500, ct);
|
||||
|
||||
using var cts = new CancellationTokenSource();
|
||||
ct.Register(cts.Cancel);
|
||||
|
||||
// 演奏结束检查任务
|
||||
var checkTask = Task.Run(async () =>
|
||||
{
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
{
|
||||
await Delay(5000, ct); // 每5秒检查一次
|
||||
using var listRa = CaptureToRectArea().Find(AutoMusicAssets.Instance.BtnList);
|
||||
if (listRa.IsExist())
|
||||
{
|
||||
Logger.LogDebug("检测到返回列表按钮,演奏结束");
|
||||
listRa.Click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 演奏任务
|
||||
var musicTask = _autoMusicGameTask.StartWithOutInit(cts.Token);
|
||||
|
||||
// 等待任意一个任务完成
|
||||
await Task.WhenAny(checkTask, musicTask);
|
||||
await cts.CancelAsync();
|
||||
|
||||
Logger.LogInformation("第{Num}首{Difficulty}难度乐曲演奏完成", i + 1, difficultyName);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await Bv.WaitUntilFound(AutoMusicAssets.Instance.UiLeftTopAlbumIcon, ct);
|
||||
Logger.LogDebug("切换到下一首乐曲");
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
continue;
|
||||
}
|
||||
|
||||
Logger.LogInformation("当前乐曲{Num}存在未领取奖励,前往演奏", i + 1);
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(800, ct);
|
||||
// 点击传说
|
||||
GameCaptureRegion.GameRegion1080PPosClick(1400, 600);
|
||||
await Delay(200, ct);
|
||||
// 演奏
|
||||
Bv.ClickWhiteConfirmButton(CaptureToRectArea());
|
||||
await Delay(500, ct);
|
||||
|
||||
CancellationTokenSource cts = new();
|
||||
ct.Register(cts.Cancel);
|
||||
|
||||
// 演奏结束检查任务
|
||||
var checkTask = Task.Run(async () =>
|
||||
{
|
||||
while (!cts.Token.IsCancellationRequested)
|
||||
{
|
||||
await Delay(5000, ct); // n秒检查一次
|
||||
using var listRa = CaptureToRectArea().Find(AutoMusicAssets.Instance.BtnList);
|
||||
if (listRa.IsExist())
|
||||
{
|
||||
listRa.Click();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, cts.Token);
|
||||
|
||||
// 演奏任务
|
||||
var musicTask = _autoMusicGameTask.StartWithOutInit(cts.Token);
|
||||
|
||||
// 等待任意一个任务完成
|
||||
await Task.WhenAny(checkTask, musicTask);
|
||||
await cts.CancelAsync();
|
||||
Logger.LogInformation("当前乐曲{Num}演奏结束", i + 1);
|
||||
await Delay(2000, ct);
|
||||
|
||||
await Bv.WaitUntilFound(AutoMusicAssets.Instance.UiLeftTopAlbumIcon, ct);
|
||||
Logger.LogInformation("切换下一首");
|
||||
GameCaptureRegion.GameRegion1080PPosClick(310, 220);
|
||||
await Delay(800, ct);
|
||||
Logger.LogInformation("完成{Difficulty}难度所有乐曲的演奏", difficultyName);
|
||||
}
|
||||
|
||||
Logger.LogInformation("当前专辑所有乐曲演奏结束");
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace BetterGenshinImpact.GameTask.AutoMusicGame;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 千音雅集配置
|
||||
/// </summary>
|
||||
[Serializable]
|
||||
public partial class AutoMusicGameConfig : ObservableObject
|
||||
{
|
||||
// 乐曲级别
|
||||
[ObservableProperty]
|
||||
private string _musicLevel = "";
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public class GoToAdventurersGuildTask
|
||||
await new ReturnMainUiTask().Start(ct);
|
||||
|
||||
// 结束后重新打开
|
||||
await Delay(200, ct);
|
||||
await Delay(1000, ct);
|
||||
var ra = CaptureToRectArea();
|
||||
if (!Bv.FindFAndPress(ra, "凯瑟琳"))
|
||||
{
|
||||
|
||||
@@ -1155,16 +1155,20 @@
|
||||
</ui:CardControl>
|
||||
|
||||
<!-- 自动音游专辑 -->
|
||||
<ui:CardControl Margin="0,0,0,12">
|
||||
<ui:CardControl.Icon>
|
||||
<ui:CardExpander Margin="0,0,0,12">
|
||||
<ui:CardExpander.Icon>
|
||||
<ui:FontIcon Glyph="" Style="{StaticResource FaFontIconStyle}" />
|
||||
</ui:CardControl.Icon>
|
||||
<ui:CardControl.Header>
|
||||
</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"
|
||||
@@ -1180,15 +1184,49 @@
|
||||
点击查看使用教程
|
||||
</Hyperlink>
|
||||
</ui:TextBlock>
|
||||
<controls:TwoStateButton Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Margin="0,0,24,0"
|
||||
DisableCommand="{Binding StopSoloTaskCommand}"
|
||||
DisableContent="停止"
|
||||
EnableCommand="{Binding SwitchAutoAlbumCommand}"
|
||||
EnableContent="{Binding SwitchAutoAlbumButtonText}"
|
||||
IsChecked="{Binding SwitchAutoAlbumEnabled}" />
|
||||
</Grid>
|
||||
</ui:CardControl.Header>
|
||||
<controls:TwoStateButton Margin="0,0,36,0"
|
||||
DisableCommand="{Binding StopSoloTaskCommand}"
|
||||
DisableContent="停止"
|
||||
EnableCommand="{Binding SwitchAutoAlbumCommand}"
|
||||
EnableContent="{Binding SwitchAutoAlbumButtonText}"
|
||||
IsChecked="{Binding SwitchAutoAlbumEnabled}" />
|
||||
</ui:CardControl>
|
||||
</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" />
|
||||
<ComboBox Grid.Row="0"
|
||||
Grid.RowSpan="2"
|
||||
Grid.Column="1"
|
||||
Width="80"
|
||||
Margin="0,0,36,0"
|
||||
ItemsSource="{Binding AutoMusicLevelList}"
|
||||
SelectedItem="{Binding Config.AutoMusicGameConfig.MusicLevel, Mode=TwoWay}"
|
||||
SelectedIndex="0" />
|
||||
</Grid>
|
||||
</StackPanel>
|
||||
</ui:CardExpander>
|
||||
|
||||
|
||||
<!--<ui:CardExpander Margin="0,0,0,12" ContentPadding="0" Icon="{ui:SymbolIcon Accessibility24}">
|
||||
|
||||
@@ -30,6 +30,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using BetterGenshinImpact.GameTask.Model.Area;
|
||||
using BetterGenshinImpact.GameTask.QuickTeleport.Assets;
|
||||
using BetterGenshinImpact.View;
|
||||
using Vanara.PInvoke;
|
||||
using HotKeySettingModel = BetterGenshinImpact.Model.HotKeySettingModel;
|
||||
|
||||
@@ -567,9 +568,9 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
|
||||
// SwitchPartyTask switchPartyTask = new SwitchPartyTask();
|
||||
// Task.Run(async () => { await switchPartyTask.Start("三保一", new CancellationToken()); });
|
||||
|
||||
GoToAdventurersGuildTask goToAdventurersGuildTask = new GoToAdventurersGuildTask();
|
||||
Task.Run(async () => { await goToAdventurersGuildTask.Start("蒙德", new CancellationToken()); });
|
||||
//
|
||||
// GoToAdventurersGuildTask goToAdventurersGuildTask = new GoToAdventurersGuildTask();
|
||||
// Task.Run(async () => { await goToAdventurersGuildTask.Start("蒙德", new CancellationToken()); });
|
||||
|
||||
// ArtifactSalvageTask artifactSalvageTask = new ArtifactSalvageTask();
|
||||
// Task.Run(async () => { await artifactSalvageTask.Start(4, new CancellationToken()); });
|
||||
@@ -592,6 +593,11 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
// Simulation.SendInput.Keyboard.KeyUp(false, User32.VK.VK_LMENU);
|
||||
|
||||
// TaskControl.Logger.LogInformation("大地图界面缩放按钮位置:{Position}", Bv.GetBigMapScale( TaskControl.CaptureToRectArea()));
|
||||
|
||||
|
||||
TaskControl.Logger.LogInformation($"尝试显示遮罩窗口");
|
||||
var maskWindow = MaskWindow.Instance();
|
||||
maskWindow.Invoke(() => { maskWindow.Hide(); });
|
||||
}
|
||||
));
|
||||
debugDirectory.Children.Add(new HotKeySettingModel(
|
||||
@@ -601,8 +607,12 @@ public partial class HotKeyPageViewModel : ObservableObject, IViewModel
|
||||
Config.HotKeyConfig.Test2HotkeyType,
|
||||
(_, _) =>
|
||||
{
|
||||
GoToCraftingBenchTask goToCraftingBenchTask = new GoToCraftingBenchTask();
|
||||
Task.Run(async () => { await goToCraftingBenchTask.Start("稻妻", new CancellationToken()); });
|
||||
// GoToCraftingBenchTask goToCraftingBenchTask = new GoToCraftingBenchTask();
|
||||
// Task.Run(async () => { await goToCraftingBenchTask.Start("稻妻", new CancellationToken()); });
|
||||
|
||||
var pName = SystemControl.GetActiveProcessName();
|
||||
Debug.WriteLine($"当前处于前台的程序:{pName},原神是否位于前台:{SystemControl.IsGenshinImpactActive()}");
|
||||
TaskControl.Logger.LogInformation($"当前处于前台的程序:{pName}");
|
||||
}
|
||||
));
|
||||
|
||||
|
||||
@@ -102,6 +102,9 @@ public partial class TaskSettingsPageViewModel : ObservableObject, INavigationAw
|
||||
[ObservableProperty]
|
||||
private List<string> _artifactSalvageStarList = ["4", "3", "2", "1"];
|
||||
|
||||
[ObservableProperty]
|
||||
private List<string> _autoMusicLevelList = ["传说", "大师", "困难", "普通", "所有"];
|
||||
|
||||
[ObservableProperty]
|
||||
private AutoFightViewModel? _autoFightViewModel;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user