mirror of
https://github.com/HolographicHat/Yae.git
synced 2025-12-13 18:08:15 +08:00
add cmdline args
This commit is contained in:
@@ -7,7 +7,11 @@ public static class AppConfig {
|
|||||||
|
|
||||||
public static string GamePath { get; private set; } = null!;
|
public static string GamePath { get; private set; } = null!;
|
||||||
|
|
||||||
internal static void Load() {
|
internal static void Load(string argumentPath) {
|
||||||
|
if (argumentPath == "auto" && File.Exists(argumentPath)) {
|
||||||
|
GamePath = argumentPath;
|
||||||
|
return;
|
||||||
|
}
|
||||||
var pathCacheFile = new CacheFile("genshin_impact_game_path");
|
var pathCacheFile = new CacheFile("genshin_impact_game_path");
|
||||||
if (pathCacheFile.Exists()) {
|
if (pathCacheFile.Exists()) {
|
||||||
var path = pathCacheFile.Read().Content.ToStringUtf8();
|
var path = pathCacheFile.Read().Content.ToStringUtf8();
|
||||||
|
|||||||
@@ -10,13 +10,18 @@ namespace YaeAchievement;
|
|||||||
|
|
||||||
public static class Export {
|
public static class Export {
|
||||||
|
|
||||||
|
public static uint ExportTo { get; set; } = uint.MaxValue;
|
||||||
|
|
||||||
public static void Choose(AchievementAllDataNotify data) {
|
public static void Choose(AchievementAllDataNotify data) {
|
||||||
Console.Write(App.ExportChoose);
|
if (ExportTo == uint.MaxValue) {
|
||||||
while (Console.KeyAvailable) {
|
Console.Write(App.ExportChoose);
|
||||||
Console.ReadKey(false);
|
while (Console.KeyAvailable) {
|
||||||
|
Console.ReadKey(false);
|
||||||
|
}
|
||||||
|
if (!uint.TryParse(Console.ReadLine(), out var num)) num = 0;
|
||||||
|
ExportTo = num;
|
||||||
}
|
}
|
||||||
if (!int.TryParse(Console.ReadLine(), out var num)) num = 0;
|
((Action<AchievementAllDataNotify>) (ExportTo switch {
|
||||||
((Action<AchievementAllDataNotify>) (num switch {
|
|
||||||
1 => ToHuTao,
|
1 => ToHuTao,
|
||||||
2 => ToPaimon,
|
2 => ToPaimon,
|
||||||
3 => ToSeelie,
|
3 => ToSeelie,
|
||||||
|
|||||||
@@ -17,8 +17,10 @@ Console.WriteLine(App.AppBanner, GlobalVars.AppVersionName);
|
|||||||
Console.WriteLine(@"https://github.com/HolographicHat/YaeAchievement");
|
Console.WriteLine(@"https://github.com/HolographicHat/YaeAchievement");
|
||||||
Console.WriteLine(@"----------------------------------------------------");
|
Console.WriteLine(@"----------------------------------------------------");
|
||||||
|
|
||||||
AppConfig.Load();
|
AppConfig.Load(args.GetOrNull(0) ?? "auto");
|
||||||
CheckUpdate();
|
Export.ExportTo = ToUIntOrNull(args.GetOrNull(1)) ?? uint.MaxValue;
|
||||||
|
|
||||||
|
CheckUpdate(ToBooleanOrFalse(args.GetOrNull(2)));
|
||||||
AppCenter.Init();
|
AppCenter.Init();
|
||||||
new EventLog("AppInit") {
|
new EventLog("AppInit") {
|
||||||
Properties = {
|
Properties = {
|
||||||
|
|||||||
18
src/Utils.cs
18
src/Utils.cs
@@ -56,6 +56,18 @@ public static class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static T? GetOrNull<T>(this T[] array, uint index) where T : class {
|
||||||
|
return array.Length > index ? array[index] : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static uint? ToUIntOrNull(string? value) {
|
||||||
|
return value != null ? uint.TryParse(value, out var result) ? result : null : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool ToBooleanOrFalse(string? value) {
|
||||||
|
return value != null && bool.TryParse(value, out var result) && result;
|
||||||
|
}
|
||||||
|
|
||||||
public static void CopyToClipboard(string text) {
|
public static void CopyToClipboard(string text) {
|
||||||
if (Native.OpenClipboard(IntPtr.Zero)) {
|
if (Native.OpenClipboard(IntPtr.Zero)) {
|
||||||
Native.EmptyClipboard();
|
Native.EmptyClipboard();
|
||||||
@@ -71,7 +83,7 @@ public static class Utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void CheckUpdate() {
|
public static void CheckUpdate(bool useLocalLib) {
|
||||||
var info = UpdateInfo.Parser.ParseFrom(GetBucketFileAsByteArray("schicksal/version"))!;
|
var info = UpdateInfo.Parser.ParseFrom(GetBucketFileAsByteArray("schicksal/version"))!;
|
||||||
if (GlobalVars.AppVersionCode != info.VersionCode) {
|
if (GlobalVars.AppVersionCode != info.VersionCode) {
|
||||||
Console.WriteLine(App.UpdateNewVersion, GlobalVars.AppVersionName, info.VersionName);
|
Console.WriteLine(App.UpdateNewVersion, GlobalVars.AppVersionName, info.VersionName);
|
||||||
@@ -89,7 +101,9 @@ public static class Utils {
|
|||||||
Environment.Exit(0);
|
Environment.Exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (info.EnableLibDownload) {
|
if (useLocalLib) {
|
||||||
|
File.Copy(GlobalVars.LibPath, Path.Combine(GlobalVars.AppPath, "YaeLib.dll"));
|
||||||
|
} else if (info.EnableLibDownload) {
|
||||||
File.WriteAllBytes(GlobalVars.LibPath, GetBucketFileAsByteArray("schicksal/lib.dll"));
|
File.WriteAllBytes(GlobalVars.LibPath, GetBucketFileAsByteArray("schicksal/lib.dll"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user