From bb3c501e1ac5f21a0e8739b007e7dd32d5ead812 Mon Sep 17 00:00:00 2001 From: Scighost Date: Sun, 1 Dec 2024 00:09:38 +0800 Subject: [PATCH] game auth login --- src/Starward/AppConfig.cs | 63 ++--- src/Starward/Pages/GameLauncherPage.xaml | 65 +++++ src/Starward/Pages/GameLauncherPage.xaml.cs | 47 +++- src/Starward/Services/GameRecordService.cs | 4 +- .../Services/Launcher/GameLauncherService.cs | 247 +++++++++++++++++- 5 files changed, 390 insertions(+), 36 deletions(-) diff --git a/src/Starward/AppConfig.cs b/src/Starward/AppConfig.cs index 09ee0604b..5d4672186 100644 --- a/src/Starward/AppConfig.cs +++ b/src/Starward/AppConfig.cs @@ -26,6 +26,7 @@ using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; +using System.Text; using System.Text.Encodings.Web; using System.Text.Json; @@ -79,36 +80,17 @@ static AppConfig() #region Ini Config - private static int windowSizeMode; - public static int WindowSizeMode - { - get => windowSizeMode; - set - { - windowSizeMode = value; - } - } + public static int WindowSizeMode { get; set; } - private static string? language; - public static string? Language - { - get => language; - set - { - language = value; - } - } + public static string? Language { get; set; } - private static string userDataFolder; - public static string UserDataFolder - { - get => userDataFolder; - set - { - userDataFolder = value; - } - } + public static string UserDataFolder { get; set; } + + public static bool? EnableLoginAuthTicket { get; set; } + + public static string? stoken { get; set; } + public static string? mid { get; set; } @@ -139,8 +121,11 @@ private static void Initialize() } Configuration = builder.Build(); - windowSizeMode = Configuration.GetValue(nameof(WindowSizeMode)); - language = Configuration.GetValue(nameof(Language)); + WindowSizeMode = Configuration.GetValue(nameof(WindowSizeMode)); + Language = Configuration.GetValue(nameof(Language)); + EnableLoginAuthTicket = Configuration.GetValue(nameof(EnableLoginAuthTicket)); + stoken = Configuration.GetValue(nameof(stoken)); + mid = Configuration.GetValue(nameof(mid)); string? dir = Configuration.GetValue(nameof(UserDataFolder)); if (!string.IsNullOrWhiteSpace(dir)) { @@ -155,7 +140,7 @@ private static void Initialize() } if (Directory.Exists(folder)) { - userDataFolder = Path.GetFullPath(folder); + UserDataFolder = Path.GetFullPath(folder); } } } @@ -185,11 +170,25 @@ public static void SaveConfiguration() { dataFolder = Path.GetRelativePath(baseDir, dataFolder); } - File.WriteAllText(Path.Combine(baseDir, "config.ini"), $""" + var sb = new StringBuilder(); + sb.AppendLine($""" {nameof(WindowSizeMode)}={WindowSizeMode} {nameof(Language)}={Language} {nameof(UserDataFolder)}={dataFolder} """); + if (EnableLoginAuthTicket.HasValue) + { + sb.AppendLine($"{nameof(EnableLoginAuthTicket)}={EnableLoginAuthTicket}"); + } + if (!string.IsNullOrWhiteSpace(stoken)) + { + sb.AppendLine($"{nameof(stoken)}={stoken}"); + } + if (!string.IsNullOrWhiteSpace(mid)) + { + sb.AppendLine($"{nameof(mid)}={mid}"); + } + File.WriteAllText(Path.Combine(baseDir, "config.ini"), sb.ToString()); } catch { } } @@ -773,6 +772,8 @@ public static void DeleteAllSettings() public static bool LauncherPageFirstLoaded { get; set; } + public static string? HyperionAid { get; set; } + #endregion diff --git a/src/Starward/Pages/GameLauncherPage.xaml b/src/Starward/Pages/GameLauncherPage.xaml index a6fc21cc0..1cecb1420 100644 --- a/src/Starward/Pages/GameLauncherPage.xaml +++ b/src/Starward/Pages/GameLauncherPage.xaml @@ -432,6 +432,71 @@ Glyph="" IsTextScaleFactorEnabled="False" /> + +