Merge remote-tracking branch 'origin/master'

This commit is contained in:
HolographicHat
2022-08-24 17:02:53 +08:00
3 changed files with 33 additions and 15 deletions

View File

@@ -8,7 +8,7 @@
- 支持导出所有类别的成就
- 支持官服,渠道服与国际服
- 支持导出至[椰羊](https://cocogoat.work/achievement)、[SnapGenshin](https://github.com/DGP-Studio/Snap.Genshin)、[Paimon.moe](https://paimon.moe/achievement/)、[Seelie.me](https://seelie.me/achievements)、[寻空](https://github.com/xunkong/xunkong)[^1]和表格文件(csv)
- 支持导出至[椰羊](https://cocogoat.work/achievement)、[SnapGenshin](https://github.com/DGP-Studio/Snap.Genshin)、[Paimon.moe](https://paimon.moe/achievement/)、[Seelie.me](https://seelie.me/achievements)、[寻空](https://github.com/xunkong/xunkong)和表格文件(csv)
- 没有窗口大小、游戏语言等要求
## 使用说明
@@ -28,5 +28,3 @@
1. Q: 原神启动时报错: 数据异常(31-4302)
A: 不要把软件和原神主程序放一起
[^1]: 由寻空开发者维护,仓库地址: [YaeAchievement](https://github.com/xunkong/YaeAchievement)

View File

@@ -5,6 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<LangVersion>preview</LangVersion>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<ApplicationManifest>res\app.manifest</ApplicationManifest>
<AssemblyVersion>2.0.0</AssemblyVersion>
@@ -13,8 +14,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="3.21.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta1" />
<PackageReference Include="Google.Protobuf" Version="3.21.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.2-beta1" />
</ItemGroup>
</Project>

View File

@@ -10,14 +10,17 @@ 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]
(0-4): ".Split("\n").Select(s => s.Trim()).JoinToString("\n") + " ");
Console.Write("""
:
[0] (https://cocogoat.work/achievement, 默认)
[1] SnapGenshin
[2] Paimon.moe
[3] Seelie.me
[4]
[5]
[6]
(0-6):
""");
if (!int.TryParse(Console.ReadLine(), out var num)) num = 0;
((Action<AchievementAllDataNotify>) (num switch {
1 => ToSnapGenshin,
@@ -25,6 +28,7 @@ public static class Export {
3 => ToSeelie,
4 => ToCSV,
5 => ToWxApp1,
6 => ToXunkong,
7 => ToRawJson,
_ => ToCocogoat
})).Invoke(data);
@@ -139,6 +143,17 @@ public static class Export {
Console.WriteLine($"成就数据已导出至 {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("在寻空中进行下一步操作");
} else {
Console.WriteLine("更新寻空至最新版本后重试");
Utils.ShellOpen("ms-windows-store://pdp/?productid=9N2SVG0JMT12");
}
}
private static void ToRawJson(AchievementAllDataNotify data) {
var path = Path.GetFullPath($"export-{DateTime.Now:yyyyMMddHHmmss}-raw.json");
File.WriteAllText(path, JsonConvert.SerializeObject(data, Formatting.Indented));
@@ -148,7 +163,7 @@ public static class Export {
// ReSharper disable once InconsistentNaming
private static Dictionary<string, object> ExportToUIAFApp(AchievementAllDataNotify data) {
var output = data.List
.Where(a => a.Status is Status.Finished or Status.RewardTaken)
.Where(a => (uint)a.Status > 1 || a.Current > 0)
.Select(ach => new Dictionary<string, uint> {
["id"] = ach.Id,
["status"] = (uint) ach.Status,
@@ -171,8 +186,12 @@ public static class Export {
private static bool CheckSnapScheme() {
return (string?)Registry.ClassesRoot.OpenSubKey("snapgenshin")?.GetValue("") == "URL:snapgenshin";
}
private static bool CheckXunkongScheme() {
return (string?)Registry.ClassesRoot.OpenSubKey("xunkong")?.GetValue("") == "URL:xunkong";
}
#pragma warning restore CA1416
private static string JoinToString(this IEnumerable<object> list, string separator) {
return string.Join(separator, list);
}