Skip to content

Commit

Permalink
fix #2272
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Dec 9, 2024
1 parent 9f7646c commit fb0510e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 52 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Snap.Hutao.Core.Json;

[CollectionBuilder(typeof(JsonExtensionDataDictionary), nameof(InitialzieWithIgnoredKeys))]
[CollectionBuilder(typeof(JsonExtensionDataDictionary), nameof(InitializeWithIgnoredKeys))]
internal sealed partial class JsonExtensionDataDictionary : IDictionary<string, JsonElement>
{
private readonly Dictionary<string, JsonElement> inner = [];
Expand Down Expand Up @@ -45,9 +45,9 @@ public JsonElement this[string key]
set => inner[key] = value;
}

public static JsonExtensionDataDictionary InitialzieWithIgnoredKeys(ReadOnlySpan<string> keys)
public static JsonExtensionDataDictionary InitializeWithIgnoredKeys(ReadOnlySpan<string> keys)
{
return new JsonExtensionDataDictionary(keys);
return new(keys);
}

public void Add(string key, JsonElement value)
Expand Down
46 changes: 0 additions & 46 deletions src/Snap.Hutao/Snap.Hutao/Core/LifeCycle/AppInstanceExtension.cs

This file was deleted.

3 changes: 3 additions & 0 deletions src/Snap.Hutao/Snap.Hutao/Resource/Localization/SH.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1034,6 +1034,9 @@
<data name="ServiceGameLocatorPickerFilterText" xml:space="preserve">
<value>游戏本体</value>
</data>
<data name="ServiceGameLocatorUnityLogCannotOpenRead" xml:space="preserve">
<value>游戏运行中,无法读取 Unity 日志文件</value>
</data>
<data name="ServiceGameLocatorUnityLogFileNotFound" xml:space="preserve">
<value>找不到 Unity 日志文件</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,15 @@ public async ValueTask<ValueResult<bool, string>> LocateGamePathAsync()
return new(false, SH.ServiceGameLocatorUnityLogFileNotFound);
}

string content = await File.ReadAllTextAsync(logFilePath).ConfigureAwait(false);
string content;
try
{
content = await File.ReadAllTextAsync(logFilePath).ConfigureAwait(false);
}
catch (IOException)
{
return new(false, SH.ServiceGameLocatorUnityLogCannotOpenRead);
}

Match matchResult = WarmupFileLine.Match(content);
if (!matchResult.Success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ public async ValueTask<ValueResult<bool, string>> SilentGetGamePathAsync()
// Cannot find in setting
if (string.IsNullOrEmpty(launchOptions.GamePath))
{
// Try locate by unity log
// Try to locate by unity log
(bool isOk, string path) = await gameLocatorFactory.LocateAsync(GameLocationSource.UnityLog).ConfigureAwait(false);

if (!isOk)
{
// Try locate by registry
// Try to locate by registry
(isOk, path) = await gameLocatorFactory.LocateAsync(GameLocationSource.Registry).ConfigureAwait(false);
}

Expand Down

0 comments on commit fb0510e

Please sign in to comment.