Skip to content

Commit

Permalink
Merge pull request #2293 from DGP-Studio/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx authored Dec 15, 2024
2 parents 025176c + 9ac1651 commit 6725989
Show file tree
Hide file tree
Showing 19 changed files with 455 additions and 281 deletions.
1 change: 1 addition & 0 deletions src/Snap.Hutao/Snap.Hutao/Core/Setting/SettingKeys.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ internal static class SettingKeys
public const string StaticResourceImageQuality = "StaticResourceImageQuality";
public const string StaticResourceImageArchive = "StaticResourceImageArchive";
public const string HotKeyMouseClickRepeatForever = "HotKeyMouseClickRepeatForever";
public const string HotKeyKeyPressRepeatForever = "HotKeyKeyPressRepeatForever";
public const string IsAllocConsoleDebugModeEnabled = "IsAllocConsoleDebugModeEnabled2";
#endregion

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public unsafe ValueResult<bool, ValueFile> PickFile(string? title, string? defau
FILEOPENDIALOGOPTIONS.FOS_FORCEFILESYSTEM |
FILEOPENDIALOGOPTIONS.FOS_NOCHANGEDIR;

fileDialog.SetOptions(Options);
fileDialog.GetOptions(out FILEOPENDIALOGOPTIONS original);
fileDialog.SetOptions(original | Options);
SetDesktopAsStartupFolder(fileDialog);

if (!string.IsNullOrEmpty(defaultFileName))
Expand Down Expand Up @@ -94,7 +95,8 @@ public unsafe ValueResult<bool, ValueFile> SaveFile(string? title, string? defau
FILEOPENDIALOGOPTIONS.FOS_STRICTFILETYPES |
FILEOPENDIALOGOPTIONS.FOS_NOCHANGEDIR;

fileDialog.SetOptions(Options);
fileDialog.GetOptions(out FILEOPENDIALOGOPTIONS original);
fileDialog.SetOptions(original | Options);
SetDesktopAsStartupFolder(fileDialog);

if (!string.IsNullOrEmpty(defaultFileName))
Expand Down Expand Up @@ -154,7 +156,8 @@ public unsafe ValueResult<bool, string> PickFolder(string? title)
FILEOPENDIALOGOPTIONS.FOS_PICKFOLDERS |
FILEOPENDIALOGOPTIONS.FOS_NOCHANGEDIR;

fileDialog.SetOptions(Options);
fileDialog.GetOptions(out FILEOPENDIALOGOPTIONS original);
fileDialog.SetOptions(original | Options);
SetDesktopAsStartupFolder(fileDialog);

if (!string.IsNullOrEmpty(title))
Expand Down
19 changes: 17 additions & 2 deletions src/Snap.Hutao/Snap.Hutao/Model/ImmutableCollectionsNameValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ public static ImmutableArray<NameValue<TEnum>> FromEnum<TEnum>()
public static ImmutableArray<NameValue<TEnum>> FromEnum<TEnum>(Func<TEnum, bool> predicate)
where TEnum : struct, Enum
{
return From(Enum.GetValues<TEnum>(), predicate);
return From(Enum.GetValues<TEnum>().AsSpan(), predicate);
}

public static ImmutableArray<NameValue<TEnum>> FromEnum<TEnum>(Func<TEnum, string> nameSelector)
where TEnum : struct, Enum
{
return From(Enum.GetValues<TEnum>(), nameSelector);
return From(Enum.GetValues<TEnum>().AsSpan(), nameSelector);
}

public static ImmutableArray<NameValue<TSource>> From<TSource>(IEnumerable<TSource> sources)
Expand All @@ -41,6 +41,21 @@ public static ImmutableArray<NameValue<TSource>> From<TSource>(IEnumerable<TSour
return [.. sources.Select(x => new NameValue<TSource>(nameSelector(x), x))];
}

public static ImmutableArray<NameValue<TSource>> From<TSource>(ReadOnlySpan<TSource> sources)
{
return ImmutableArray.Create(sources).SelectAsArray(DefaultCreateNameValue);
}

public static ImmutableArray<NameValue<TSource>> From<TSource>(ReadOnlySpan<TSource> sources, Func<TSource, bool> predicate)
{
return [.. ImmutableArray.Create(sources).Where(predicate).Select(DefaultCreateNameValue)];
}

public static ImmutableArray<NameValue<TSource>> From<TSource>(ReadOnlySpan<TSource> sources, Func<TSource, string> nameSelector)
{
return [.. ImmutableArray.Create(sources).Select(x => new NameValue<TSource>(nameSelector(x), x))];
}

private static NameValue<TEnum> DefaultCreateNameValue<TEnum>(TEnum value)
{
string? name = value?.ToString();
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="60568DGPStudio.SnapHutao"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.12.7.0" />
Version="1.12.8.0" />

<Properties>
<DisplayName>Snap Hutao</DisplayName>
Expand Down
2 changes: 1 addition & 1 deletion src/Snap.Hutao/Snap.Hutao/Package.development.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<Identity
Name="60568DGPStudio.SnapHutaoDev"
Publisher="CN=35C8E923-85DF-49A7-9172-B39DC6312C52"
Version="1.12.7.0" />
Version="1.12.8.0" />

<Properties>
<DisplayName>Snap Hutao Dev</DisplayName>
Expand Down
13 changes: 11 additions & 2 deletions src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
Original file line number Diff line number Diff line change
Expand Up @@ -3270,10 +3270,16 @@
<value>高级功能</value>
</data>
<data name="ViewPageSettingKeyShortcutAutoClickingDescription" xml:space="preserve">
<value>更改自动连点功能的快捷键</value>
<value>更改鼠标左键自动连点功能的快捷键</value>
</data>
<data name="ViewPageSettingKeyShortcutAutoClickingHeader" xml:space="preserve">
<value>自动连点</value>
<value>鼠标左键自动连点</value>
</data>
<data name="ViewPageSettingKeyShortcutAutoPressingDescription" xml:space="preserve">
<value>更改键盘 F 键自动连按功能的快捷键</value>
</data>
<data name="ViewPageSettingKeyShortcutAutoPressingHeader" xml:space="preserve">
<value>键盘 F 键自动连按</value>
</data>
<data name="ViewPageSettingKeyShortcutHeader" xml:space="preserve">
<value>快捷键</value>
Expand Down Expand Up @@ -3593,6 +3599,9 @@
<data name="ViewTitleAutoClicking" xml:space="preserve">
<value>自动连点</value>
</data>
<data name="ViewTitleAutoPressing" xml:space="preserve">
<value>自动连按</value>
</data>
<data name="ViewTitleUpdatePackageInstallingContent" xml:space="preserve">
<value>正在安装更新</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ namespace Snap.Hutao.Service.Game.Locator;

internal enum GameLocationSourceKind
{
Registry,
UnityLog,
Manual,
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ internal sealed partial class UnityLogGameLocator : IGameLocator, IGameLocator2
{
private readonly ITaskContext taskContext;

[GeneratedRegex(@".:/.+(?:GenshinImpact|YuanShen)(?=_Data)")]
[GeneratedRegex(@".:/.+(?:GenshinImpact|YuanShen)(?=_Data)", RegexOptions.IgnoreCase)]
private static partial Regex WarmupFileLine { get; }

public async ValueTask<ValueResult<bool, string>> LocateSingleGamePathAsync()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ public async ValueTask<ValueResult<bool, string>> SilentGetGamePathAsync()
return new(true, launchOptions.GamePath);
}

// Try to locate by registry
if (await gameLocatorFactory.LocateSingleAsync(GameLocationSourceKind.Registry).ConfigureAwait(false) is (true, { } path2))
{
launchOptions.UpdateGamePath(path2);
return new(true, launchOptions.GamePath);
}

return new(false, SH.ServiceGamePathLocateFailed);
}

Expand All @@ -47,11 +40,6 @@ public async ValueTask SilentLocateAllGamePathAsync()
paths.Add(path);
}

foreach (string path in await gameLocatorFactory.LocateMultipleAsync(GameLocationSourceKind.Registry).ConfigureAwait(false))
{
paths.Add(path);
}

using (await launchOptions.GamePathLock.WriterLockAsync().ConfigureAwait(false))
{
foreach (GamePathEntry entry in launchOptions.GamePathEntries)
Expand Down
Loading

0 comments on commit 6725989

Please sign in to comment.