From bf08ffa89e6f30ec09caa318646edb1d9362e88c Mon Sep 17 00:00:00 2001 From: solacens Date: Tue, 3 Jan 2023 12:20:13 +1100 Subject: [PATCH] Missing changes --- .../GachaLogUrlWebCacheProvider.cs | 11 ++++- .../Game/Locator/UnityLogGameLocator.cs | 46 +++++++++++++------ 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/UrlProvider/GachaLogUrlWebCacheProvider.cs b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/UrlProvider/GachaLogUrlWebCacheProvider.cs index 1626fa4c..f7a02c5f 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/UrlProvider/GachaLogUrlWebCacheProvider.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/GachaLog/UrlProvider/GachaLogUrlWebCacheProvider.cs @@ -36,7 +36,16 @@ internal class GachaLogUrlWebCacheProvider : IGachaLogUrlProvider public static string GetCacheFile(string path) { string folder = Path.GetDirectoryName(path) ?? string.Empty; - return Path.Combine(folder, @"YuanShen_Data\webCaches\Cache\Cache_Data\data_2"); + var cacheDataPath = Path.Combine(folder, @"YuanShen_Data\webCaches\Cache\Cache_Data\data_2"); + var cacheDataPathIntl = Path.Combine(folder, @"GenshinImpact_Data\webCaches\Cache\Cache_Data\data_2"); + if (File.Exists(cacheDataPath)) + { + return cacheDataPath; + } + else + { + return cacheDataPathIntl; + } } /// diff --git a/src/Snap.Hutao/Snap.Hutao/Service/Game/Locator/UnityLogGameLocator.cs b/src/Snap.Hutao/Snap.Hutao/Service/Game/Locator/UnityLogGameLocator.cs index 5a61b6bf..c783ee2e 100644 --- a/src/Snap.Hutao/Snap.Hutao/Service/Game/Locator/UnityLogGameLocator.cs +++ b/src/Snap.Hutao/Snap.Hutao/Service/Game/Locator/UnityLogGameLocator.cs @@ -22,28 +22,48 @@ internal partial class UnityLogGameLocator : IGameLocator await ThreadHelper.SwitchToBackgroundAsync(); string appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); string logFilePath = Path.Combine(appDataPath, @"..\LocalLow\miHoYo\原神\output_log.txt"); + string logFilePathIntl = Path.Combine(appDataPath, @"..\LocalLow\miHoYo\Genshin Impact\output_log.txt"); - using (TemporaryFile? tempFile = TemporaryFile.CreateFromFileCopy(logFilePath)) + using (TemporaryFile? tempFile = TemporaryFile.CreateFromFileCopy(logFilePath), tempFileIntl = TemporaryFile.CreateFromFileCopy(logFilePathIntl)) { - if (tempFile == null) + if (tempFile != null) { - return new(false, $"找不到 Unity 日志文件:\n{logFilePath}"); + string content = File.ReadAllText(tempFile.Path); + + Match matchResult = WarmupFileLine().Match(content); + if (!matchResult.Success) + { + return new(false, $"在 Unity 日志文件中找不到游戏路径"); + } + + string entryName = matchResult.Groups[0].Value.Replace("_Data", ".exe"); + string fullPath = Path.GetFullPath(Path.Combine(matchResult.Value, "..", entryName)); + return new(true, fullPath); } - - string content = File.ReadAllText(tempFile.Path); - - Match matchResult = WarmupFileLine().Match(content); - if (!matchResult.Success) + else if (tempFileIntl != null) { - return new(false, $"在 Unity 日志文件中找不到游戏路径"); - } + string content = File.ReadAllText(tempFileIntl.Path); - string entryName = matchResult.Groups[0].Value.Replace("_Data", ".exe"); - string fullPath = Path.GetFullPath(Path.Combine(matchResult.Value, "..", entryName)); - return new(true, fullPath); + Match matchResult = WarmupFileLineIntl().Match(content); + if (!matchResult.Success) + { + return new(false, $"在 Unity 日志文件中找不到游戏路径"); + } + + string entryName = matchResult.Groups[0].Value.Replace("_Data", ".exe"); + string fullPath = Path.GetFullPath(Path.Combine(matchResult.Value, "..", entryName)); + return new(true, fullPath); + } + else + { + return new(false, $"找不到 Unity 日志文件:\n{logFilePath}\n{logFilePathIntl}"); + } } } [GeneratedRegex(@"(?m).:/.+YuanShen_Data")] private static partial Regex WarmupFileLine(); + + [GeneratedRegex(@"(?m).:/.+GenshinImpact_Data")] + private static partial Regex WarmupFileLineIntl(); } \ No newline at end of file