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:
@@ -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('|'))
|
||||
|
||||
@@ -9,31 +9,32 @@ public class WindowHelper
|
||||
{
|
||||
public static void TryApplySystemBackdrop(System.Windows.Window window)
|
||||
{
|
||||
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))
|
||||
{
|
||||
window.Background = new SolidColorBrush(Color.FromArgb(100, 0, 0, 0));
|
||||
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;
|
||||
}
|
||||
else
|
||||
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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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="" 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="" 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>
|
||||
|
||||
<!-- 可以继续添加其他设置项 -->
|
||||
|
||||
@@ -1038,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"
|
||||
|
||||
@@ -70,7 +70,7 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
|
||||
{
|
||||
return; // win10 不支持切换主题
|
||||
}
|
||||
|
||||
|
||||
CurrentBackdropType = CurrentBackdropType switch
|
||||
{
|
||||
WindowBackdropType.Mica => WindowBackdropType.Acrylic,
|
||||
@@ -100,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());
|
||||
@@ -122,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 + ",后续可以手动设置");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 不同的安装目录处理
|
||||
@@ -151,10 +158,10 @@ 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, MessageBoxImage.Question);
|
||||
if (res == System.Windows.MessageBoxResult.Yes)
|
||||
@@ -165,7 +172,6 @@ public partial class MainWindowViewModel : ObservableObject, IViewModel
|
||||
// 删除旧目录
|
||||
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()
|
||||
|
||||
@@ -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 = ["传说", "大师", "困难", "普通", "所有"];
|
||||
|
||||
Reference in New Issue
Block a user