mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-14 18:38:13 +08:00
Add en lang
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Newtonsoft.Json;
|
||||
using YaeAchievement.res;
|
||||
|
||||
namespace YaeAchievement;
|
||||
|
||||
@@ -21,8 +22,8 @@ public class AppConfig {
|
||||
if (_instance?.Location == null || !Utils.CheckGamePathValid(_instance.Location)) {
|
||||
var gameInstallPath = Utils.FindGamePathFromRegistry();
|
||||
if (!string.IsNullOrEmpty(gameInstallPath)) {
|
||||
Console.WriteLine($"自动读取到游戏路径: {gameInstallPath}");
|
||||
Console.WriteLine($"如果确认路径无误,请按 Y ;若有误或需要自行选择,请按 N ");
|
||||
Console.WriteLine(App.ConfigInitGotPath, gameInstallPath);
|
||||
Console.WriteLine(App.ConfigInitPathConfirm);
|
||||
var key = Console.ReadKey().Key;
|
||||
gameInstallPath = key == ConsoleKey.Y ? gameInstallPath : Utils.SelectGameExecutable();
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
|
||||
using System.Net;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using Microsoft.Win32;
|
||||
using Newtonsoft.Json;
|
||||
using YaeAchievement.res;
|
||||
using static AchievementAllDataNotify.Types.Achievement.Types;
|
||||
|
||||
namespace YaeAchievement;
|
||||
@@ -10,25 +10,15 @@ namespace YaeAchievement;
|
||||
public static class Export {
|
||||
|
||||
public static void Choose(AchievementAllDataNotify data) {
|
||||
Console.Write("""
|
||||
导出至:
|
||||
[0] 椰羊 (https://cocogoat.work/achievement, 默认)
|
||||
[1] SnapGenshin
|
||||
[2] Paimon.moe
|
||||
[3] Seelie.me
|
||||
[4] 表格文件
|
||||
[5] 原魔工具箱
|
||||
[6] 寻空
|
||||
输入一个数字(0-6):
|
||||
""");
|
||||
Console.Write(App.ExportChoose);
|
||||
if (!int.TryParse(Console.ReadLine(), out var num)) num = 0;
|
||||
((Action<AchievementAllDataNotify>) (num switch {
|
||||
1 => ToSnapGenshin,
|
||||
2 => ToPaimon,
|
||||
3 => ToSeelie,
|
||||
4 => ToCSV,
|
||||
5 => ToWxApp1,
|
||||
6 => ToXunkong,
|
||||
5 => ToXunkong,
|
||||
6 => ToWxApp1,
|
||||
7 => ToRawJson,
|
||||
_ => ToCocogoat
|
||||
})).Invoke(data);
|
||||
@@ -38,17 +28,17 @@ public static class Export {
|
||||
var result = JsonConvert.SerializeObject(ExportToUIAFApp(data));
|
||||
using var request = new HttpRequestMessage {
|
||||
Method = HttpMethod.Post,
|
||||
RequestUri = new Uri("https://77.cocogoat.work/v1/memo?source=全部成就"),
|
||||
RequestUri = new Uri($"https://77.cocogoat.work/v1/memo?source={App.AllAchievement}"),
|
||||
Content = new StringContent(result, Encoding.UTF8, "application/json")
|
||||
};
|
||||
using var response = Utils.CHttpClient.Value.Send(request);
|
||||
if (response.StatusCode != HttpStatusCode.Created) {
|
||||
Console.WriteLine("导出失败, 请联系开发者以获取帮助");
|
||||
Console.WriteLine(App.ExportToCocogoatFail);
|
||||
return;
|
||||
}
|
||||
dynamic memo = JsonConvert.DeserializeObject(response.Content.ReadAsStringAsync().Result)!;
|
||||
Console.WriteLine(Utils.ShellOpen($"https://cocogoat.work/achievement?memo={memo.key}")
|
||||
? "在浏览器内进行下一步操作"
|
||||
? App.ExportToCocogoatSuccess
|
||||
: $"https://cocogoat.work/achievement?memo={memo.key}");
|
||||
}
|
||||
|
||||
@@ -64,16 +54,16 @@ public static class Export {
|
||||
Content = new StringContent(result, Encoding.UTF8, "application/json")
|
||||
};
|
||||
using var response = Utils.CHttpClient.Value.Send(request);
|
||||
Console.WriteLine($"在小程序导入页面输入以下代码: {id}");
|
||||
Console.WriteLine(App.ExportToWxApp1Success, id);
|
||||
}
|
||||
|
||||
private static void ToSnapGenshin(AchievementAllDataNotify data) {
|
||||
if (CheckSnapScheme()) {
|
||||
Utils.CopyToClipboard(JsonConvert.SerializeObject(ExportToUIAFApp(data)));
|
||||
Utils.ShellOpen("snapgenshin://achievement/import/uiaf");
|
||||
Console.WriteLine("在 SnapGenshin 进行下一步操作");
|
||||
Console.WriteLine(App.ExportToSnapGenshinSuccess);
|
||||
} else {
|
||||
Console.WriteLine("更新 SnapGenshin 至最新版本后重试");
|
||||
Console.WriteLine(App.ExportToSnapGenshinNeedUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +72,7 @@ public static class Export {
|
||||
var output = new Dictionary<uint, Dictionary<uint, bool>>();
|
||||
foreach (var ach in data.List.Where(a => a.Status is Status.Finished or Status.RewardTaken)) {
|
||||
if (!info.Items.TryGetValue(ach.Id, out var achInfo) || achInfo == null) {
|
||||
Console.WriteLine($"Unable to find {ach.Id} in metadata.");
|
||||
Console.WriteLine($@"Unable to find {ach.Id} in metadata.");
|
||||
continue;
|
||||
}
|
||||
var map = output.GetValueOrDefault(achInfo.Group, new Dictionary<uint, bool>());
|
||||
@@ -94,7 +84,7 @@ public static class Export {
|
||||
};
|
||||
var path = Path.GetFullPath($"export-{DateTime.Now:yyyyMMddHHmmss}-paimon.json");
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(final));
|
||||
Console.WriteLine($"成就数据已导出至 {path}");
|
||||
Console.WriteLine(App.ExportToFileSuccess, path);
|
||||
}
|
||||
|
||||
private static void ToSeelie(AchievementAllDataNotify data) {
|
||||
@@ -109,7 +99,7 @@ public static class Export {
|
||||
};
|
||||
var path = Path.GetFullPath($"export-{DateTime.Now:yyyyMMddHHmmss}-seelie.json");
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(final));
|
||||
Console.WriteLine($"成就数据已导出至 {path}");
|
||||
Console.WriteLine(App.ExportToFileSuccess, path);
|
||||
}
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
@@ -119,7 +109,7 @@ public static class Export {
|
||||
foreach (var ach in data.List.OrderBy(a => a.Id)) {
|
||||
if (UnusedAchievement.Contains(ach.Id)) continue;
|
||||
if (!info.Items.TryGetValue(ach.Id, out var achInfo) || achInfo == null) {
|
||||
Console.WriteLine($"Unable to find {ach.Id} in metadata.");
|
||||
Console.WriteLine($@"Unable to find {ach.Id} in metadata.");
|
||||
continue;
|
||||
}
|
||||
var finishAt = "";
|
||||
@@ -140,16 +130,16 @@ public static class Export {
|
||||
}));
|
||||
var path = Path.GetFullPath($"achievement-{DateTime.Now:yyyyMMddHHmmss}.csv");
|
||||
File.WriteAllText(path, $"\uFEFF{string.Join("\n", output)}");
|
||||
Console.WriteLine($"成就数据已导出至 {path}");
|
||||
Console.WriteLine(App.ExportToFileSuccess, path);
|
||||
}
|
||||
|
||||
private static void ToXunkong(AchievementAllDataNotify data) {
|
||||
if (CheckXunkongScheme()) {
|
||||
Utils.CopyToClipboard(JsonConvert.SerializeObject(ExportToUIAFApp(data)));
|
||||
Utils.ShellOpen("xunkong://import-achievement?caller=YaeAchievement&from=clipboard");
|
||||
Console.WriteLine("在寻空中进行下一步操作");
|
||||
Console.WriteLine(App.ExportToXunkongSuccess);
|
||||
} else {
|
||||
Console.WriteLine("更新寻空至最新版本后重试");
|
||||
Console.WriteLine(App.ExportToXunkongNeedUpdate);
|
||||
Utils.ShellOpen("ms-windows-store://pdp/?productid=9N2SVG0JMT12");
|
||||
}
|
||||
}
|
||||
@@ -157,7 +147,7 @@ public static class Export {
|
||||
private static void ToRawJson(AchievementAllDataNotify data) {
|
||||
var path = Path.GetFullPath($"export-{DateTime.Now:yyyyMMddHHmmss}-raw.json");
|
||||
File.WriteAllText(path, JsonConvert.SerializeObject(data, Formatting.Indented));
|
||||
Console.WriteLine($"成就数据已导出至 {path}");
|
||||
Console.WriteLine(App.ExportToFileSuccess, path);
|
||||
}
|
||||
|
||||
// ReSharper disable once InconsistentNaming
|
||||
@@ -200,10 +190,10 @@ public static class Export {
|
||||
|
||||
private static string ToDesc(this Status status) {
|
||||
return status switch {
|
||||
Status.Invalid => "未知",
|
||||
Status.Finished => "已完成但未领取奖励",
|
||||
Status.Unfinished => "未完成",
|
||||
Status.RewardTaken => "已完成",
|
||||
Status.Invalid => App.StatusInvalid,
|
||||
Status.Finished => App.StatusFinished,
|
||||
Status.Unfinished => App.StatusUnfinished,
|
||||
Status.RewardTaken => App.StatusRewardTaken,
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
using YaeAchievement;
|
||||
using YaeAchievement.AppCenterSDK;
|
||||
using YaeAchievement.AppCenterSDK.Models;
|
||||
using YaeAchievement.res;
|
||||
using static YaeAchievement.Utils;
|
||||
|
||||
InstallExitHook();
|
||||
|
||||
CheckVcRuntime();
|
||||
CheckIsTempDir();
|
||||
CheckSelfIsRunning();
|
||||
TryDisableQuickEdit();
|
||||
InstallExceptionHook();
|
||||
CheckGenshinIsRunning();
|
||||
|
||||
Console.WriteLine("----------------------------------------------------");
|
||||
Console.WriteLine($"YaeAchievement - 原神成就导出工具 ({GlobalVars.AppVersionName})");
|
||||
Console.WriteLine("https://github.com/HolographicHat/YaeAchievement");
|
||||
Console.WriteLine("----------------------------------------------------");
|
||||
Console.WriteLine(@"----------------------------------------------------");
|
||||
Console.WriteLine(App.AppBanner, GlobalVars.AppVersionName);
|
||||
Console.WriteLine(@"https://github.com/HolographicHat/YaeAchievement");
|
||||
Console.WriteLine(@"----------------------------------------------------");
|
||||
|
||||
AppConfig.Load();
|
||||
CheckUpdate();
|
||||
@@ -28,8 +28,8 @@ new EventLog("AppInit") {
|
||||
}.Enqueue();
|
||||
var historyCache = new CacheFile("ExportData");
|
||||
if (historyCache.LastWriteTime.AddMinutes(10) > DateTime.UtcNow) {
|
||||
Console.WriteLine("使用上一次获取到的成就数据");
|
||||
Console.WriteLine("要重新获取数据,手动删除 cache\\d1a8ef40a67a5929.miko 后重新启动 YaeAchievement");
|
||||
Console.WriteLine(App.UsePreviousData);
|
||||
Console.WriteLine(App.RefreshData);
|
||||
Export.Choose(AchievementAllDataNotify.Parser.ParseFrom(historyCache.Read().Content));
|
||||
} else {
|
||||
StartAndWaitResult(AppConfig.GamePath, str => {
|
||||
|
||||
48
src/Utils.cs
48
src/Utils.cs
@@ -6,6 +6,7 @@ using System.Net.Http.Headers;
|
||||
using System.Runtime.InteropServices;
|
||||
using Microsoft.Win32;
|
||||
using YaeAchievement.AppCenterSDK;
|
||||
using YaeAchievement.res;
|
||||
using YaeAchievement.Win32;
|
||||
using static YaeAchievement.Win32.OpenFileFlags;
|
||||
|
||||
@@ -67,17 +68,17 @@ public static class Utils {
|
||||
public static void CheckUpdate() {
|
||||
var info = UpdateInfo.Parser.ParseFrom(GetBucketFileAsByteArray("schicksal/version"))!;
|
||||
if (GlobalVars.AppVersionCode != info.VersionCode) {
|
||||
Console.WriteLine($"有可用更新: {GlobalVars.AppVersionName} => {info.VersionName}");
|
||||
Console.WriteLine($"更新内容: \n{info.Description}");
|
||||
Console.WriteLine(App.UpdateNewVersion, GlobalVars.AppVersionName, info.VersionName);
|
||||
Console.WriteLine(App.UpdateDescription, info.Description);
|
||||
if (info.EnableAutoDownload) {
|
||||
Console.WriteLine("正在下载更新包...");
|
||||
Console.WriteLine(App.UpdateDownloading);
|
||||
var fullPath = Path.GetFullPath($"update.{Path.GetExtension(info.PackageLink)}");
|
||||
File.WriteAllBytes(fullPath, GetBucketFileAsByteArray(info.PackageLink));
|
||||
Console.WriteLine("关闭程序后, 将压缩包解压至当前目录即可完成更新.");
|
||||
Console.WriteLine(App.UpdateDownloadFinish);
|
||||
ShellOpen(fullPath);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
Console.WriteLine($"下载地址: {info.PackageLink}");
|
||||
Console.WriteLine(App.DownloadLink, info.PackageLink);
|
||||
if (info.ForceUpdate) {
|
||||
Environment.Exit(0);
|
||||
}
|
||||
@@ -92,20 +93,13 @@ public static class Utils {
|
||||
var cur = Process.GetCurrentProcess();
|
||||
foreach (var process in Process.GetProcesses().Where(process => process.Id != cur.Id)) {
|
||||
if (process.ProcessName == cur.ProcessName) {
|
||||
Console.WriteLine("另一个实例正在运行,请关闭后重试");
|
||||
Console.WriteLine(App.AnotherInstance);
|
||||
Environment.Exit(302);
|
||||
}
|
||||
}
|
||||
Process.LeaveDebugMode();
|
||||
}
|
||||
|
||||
public static void CheckIsTempDir() {
|
||||
if (GlobalVars.AppPath.Contains(Path.GetTempPath())) {
|
||||
Console.WriteLine("请将程序完整解压后再运行");
|
||||
Environment.Exit(303);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static bool ShellOpen(string path) {
|
||||
return new Process {
|
||||
StartInfo = {
|
||||
@@ -129,14 +123,14 @@ public static class Utils {
|
||||
size = Marshal.SizeOf<OpenFileName>(),
|
||||
owner = Native.GetConsoleWindow(),
|
||||
flags = Explorer | NoNetworkButton | FileMustExist | NoChangeDir,
|
||||
title = "选择主程序",
|
||||
filter = "国服/国际服主程序 (YuanShen/GenshinImpact.exe)\0YuanShen.exe;GenshinImpact.exe\0",
|
||||
title = App.SelectTitle,
|
||||
filter = $"{App.SelectFilterName} (YuanShen/GenshinImpact.exe)\0YuanShen.exe;GenshinImpact.exe\0",
|
||||
maxFile = 32768
|
||||
};
|
||||
new Thread(() => {
|
||||
var handle = Native.FindWindow("#32770", "选择主程序");
|
||||
var handle = Native.FindWindow("#32770", App.SelectTitle);
|
||||
while (handle == IntPtr.Zero) {
|
||||
handle = Native.FindWindow("#32770", "选择主程序");
|
||||
handle = Native.FindWindow("#32770", App.SelectTitle);
|
||||
Thread.Sleep(1);
|
||||
}
|
||||
var currentThreadId = Native.GetCurrentThreadId();
|
||||
@@ -151,7 +145,7 @@ public static class Utils {
|
||||
if (err != 0) {
|
||||
throw new SystemException($"Dialog error: {err}");
|
||||
}
|
||||
Console.WriteLine("操作被取消");
|
||||
Console.WriteLine(App.SelectCanceled);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
var path = Marshal.PtrToStringAuto(fnPtr)!;
|
||||
@@ -169,7 +163,7 @@ public static class Utils {
|
||||
Process.EnterDebugMode();
|
||||
foreach (var process in Process.GetProcesses()) {
|
||||
if (process.ProcessName is "GenshinImpact" or "YuanShen" && !process.HasExited) {
|
||||
Console.WriteLine($"原神正在运行,请关闭后重试 ({process.Id})");
|
||||
Console.WriteLine(App.GenshinIsRunning, process.Id);
|
||||
Environment.Exit(301);
|
||||
}
|
||||
}
|
||||
@@ -182,7 +176,7 @@ public static class Utils {
|
||||
public static void InstallExitHook() {
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => {
|
||||
proc?.Kill();
|
||||
Console.WriteLine("按任意键退出");
|
||||
Console.WriteLine(App.PressKeyToExit);
|
||||
Console.ReadKey();
|
||||
};
|
||||
}
|
||||
@@ -190,7 +184,7 @@ public static class Utils {
|
||||
public static void InstallExceptionHook() {
|
||||
AppDomain.CurrentDomain.UnhandledException += (_, e) => {
|
||||
Console.WriteLine(e.ExceptionObject.ToString());
|
||||
Console.WriteLine("正在上报错误信息...");
|
||||
Console.WriteLine(App.UploadError);
|
||||
AppCenter.TrackCrash((Exception) e.ExceptionObject);
|
||||
AppCenter.Upload();
|
||||
Environment.Exit(-1);
|
||||
@@ -212,13 +206,13 @@ public static class Utils {
|
||||
Environment.Exit(new Win32Exception().PrintMsgAndReturnErrCode("TerminateProcess fail"));
|
||||
}
|
||||
}
|
||||
Console.WriteLine($"原神正在启动 ({pid})");
|
||||
Console.WriteLine(App.GameLoading, pid);
|
||||
proc = Process.GetProcessById(Convert.ToInt32(pid));
|
||||
proc.EnableRaisingEvents = true;
|
||||
proc.Exited += (_, _) => {
|
||||
if (GlobalVars.UnexpectedExit) {
|
||||
proc = null;
|
||||
Console.WriteLine("游戏进程异常退出");
|
||||
Console.WriteLine(App.GameProcessExit);
|
||||
Environment.Exit(114514);
|
||||
}
|
||||
};
|
||||
@@ -287,9 +281,9 @@ public static class Utils {
|
||||
.Any(name => name.Contains("Microsoft Visual C++ 2022 X64 "));
|
||||
if (!installed) {
|
||||
const string vcDownloadUrl = "https://aka.ms/vs/17/release/vc_redist.x64.exe";
|
||||
Console.WriteLine("未安装 VcRuntime");
|
||||
Console.WriteLine($"下载地址: {vcDownloadUrl}");
|
||||
Console.WriteLine("安装完成后,重新打开 YaeAchievement");
|
||||
Console.WriteLine(App.VcRuntimeNotInstalled);
|
||||
Console.WriteLine(App.DownloadLink, vcDownloadUrl);
|
||||
Console.WriteLine(App.VcRuntimeAfterInstall);
|
||||
ShellOpen(vcDownloadUrl);
|
||||
Environment.Exit(303);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user