Missing changes

This commit is contained in:
solacens
2023-01-03 12:20:13 +11:00
parent af4180bdeb
commit bf08ffa89e
2 changed files with 43 additions and 14 deletions

View File

@@ -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;
}
}
/// <inheritdoc/>

View File

@@ -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();
}