From 2260999735331acffa54c534ca8bf9106525b8c9 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sun, 26 Nov 2023 11:27:29 -0500 Subject: [PATCH 01/25] remove early return from tag check --- project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs index a2f2afa..b4c2d1e 100644 --- a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs +++ b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs @@ -34,7 +34,6 @@ namespace Aki.Launcher.Models.Aki AkiVersion = versionInfo[0]; Tag = versionInfo[1]; - return; } string[] splitVersion = AkiVersion.Split('.'); From 51a7e159d0dcf826b2f66216a7df00a24e9f5ade Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Tue, 5 Dec 2023 10:00:37 -0500 Subject: [PATCH 02/25] return bool when loading server --- .../Aki.Launcher.Base/Controllers/ServerManager.cs | 14 ++++++-------- .../ViewModels/ConnectServerViewModel.cs | 10 ++++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/project/Aki.Launcher.Base/Controllers/ServerManager.cs b/project/Aki.Launcher.Base/Controllers/ServerManager.cs index ab76001..d424d26 100644 --- a/project/Aki.Launcher.Base/Controllers/ServerManager.cs +++ b/project/Aki.Launcher.Base/Controllers/ServerManager.cs @@ -92,7 +92,7 @@ namespace Aki.Launcher } } - public static void LoadServer(string backendUrl) + public static bool LoadServer(string backendUrl) { string json = ""; @@ -100,22 +100,20 @@ namespace Aki.Launcher { RequestHandler.ChangeBackendUrl(backendUrl); json = RequestHandler.RequestConnect(); + SelectedServer = Json.Deserialize(json); } catch { SelectedServer = null; - return; + return false; } - SelectedServer = Json.Deserialize(json); + return true; } - public static async Task LoadDefaultServerAsync(string server) + public static async Task LoadDefaultServerAsync(string server) { - await Task.Run(() => - { - LoadServer(server); - }); + return await Task.Run(() => LoadServer(server)); } } } diff --git a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs index 6b739f1..017ed5c 100644 --- a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs @@ -32,8 +32,14 @@ namespace Aki.Launcher.ViewModels public async Task ConnectServer() { - await ServerManager.LoadDefaultServerAsync(LauncherSettingsProvider.Instance.Server.Url); - + if (!await ServerManager.LoadDefaultServerAsync(LauncherSettingsProvider.Instance.Server.Url)) + { + connectModel.ConnectionFailed = true; + connectModel.InfoText = string.Format(LocalizationProvider.Instance.server_unavailable_format_1, + LauncherSettingsProvider.Instance.Server.Name); + return; + } + bool connected = ServerManager.PingServer(); connectModel.ConnectionFailed = !connected; From 2443ab4a24a914ce6d2c4dacdd8459ee637f4779 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sat, 9 Dec 2023 17:21:16 -0500 Subject: [PATCH 03/25] update locales to have ieft tags --- .../Aki_Data/Launcher/Locales/Chinese (Simplified).json | 1 + .../Aki_Data/Launcher/Locales/Chinese (Traditional).json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/English.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/French.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/German.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Italian.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Japanese.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Korean.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Polish.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Russian.json | 1 + project/Aki.Launcher/Aki_Data/Launcher/Locales/Spanish.json | 1 + 11 files changed, 11 insertions(+) diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Simplified).json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Simplified).json index 1a245a0..9ddeb28 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Simplified).json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Simplified).json @@ -1,4 +1,5 @@ { + "ietf_tag": "zh-hans", "native_name": "简体中文", "retry": "重试", "server_connecting": "连接中", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Traditional).json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Traditional).json index 8b922ed..59cad68 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Traditional).json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Chinese (Traditional).json @@ -1,4 +1,5 @@ { + "ietf_tag": "zh-hant", "native_name": "繁體中文", "retry": "重試", "server_connecting": "正在連接伺服器", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/English.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/English.json index 5378f74..f84bd3f 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/English.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/English.json @@ -1,4 +1,5 @@ { + "ietf_tag": "en", "native_name": "English", "retry": "Retry", "server_connecting": "Connecting", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/French.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/French.json index 1fc0d81..acda7fb 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/French.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/French.json @@ -1,4 +1,5 @@ { + "ietf_tag": "fr", "native_name": "Français", "retry": "Réessayer", "server_connecting": "Connexion", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/German.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/German.json index 47f7c33..26108c2 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/German.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/German.json @@ -1,4 +1,5 @@ { + "ietf_tag": "de", "native_name": "Deutsch", "retry": "Erneut versuchen", "server_connecting": "Verbinden", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Italian.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Italian.json index e387087..6b838c9 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Italian.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Italian.json @@ -1,4 +1,5 @@ { + "ietf_tag": "it", "native_name": "Italiano", "retry": "Riprova", "server_connecting": "Connessione in corso", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Japanese.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Japanese.json index 79b1152..4cd3b99 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Japanese.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Japanese.json @@ -1,4 +1,5 @@ { + "ietf_tag": "ja", "native_name": "日本語", "retry": "リトライ", "server_connecting": "接続中", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Korean.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Korean.json index 55f9a1d..f7af75b 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Korean.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Korean.json @@ -1,4 +1,5 @@ { + "ietf_tag": "ko", "native_name": "한국어", "retry": "재시도", "server_connecting": "연결 중", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Polish.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Polish.json index 4bf8bfd..9c2d2dc 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Polish.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Polish.json @@ -1,4 +1,5 @@ { + "ietf_tag": "pl", "native_name": "Polski", "retry": "Ponów", "server_connecting": "Łączenie", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Russian.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Russian.json index 9fac85a..5bd6d44 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Russian.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Russian.json @@ -1,4 +1,5 @@ { + "ietf_tag": "ru", "native_name": "Русский", "retry": "Повторить", "server_connecting": "Соединение", diff --git a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Spanish.json b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Spanish.json index 868ea38..1423db8 100644 --- a/project/Aki.Launcher/Aki_Data/Launcher/Locales/Spanish.json +++ b/project/Aki.Launcher/Aki_Data/Launcher/Locales/Spanish.json @@ -1,4 +1,5 @@ { + "ietf_tag": "es", "native_name": "Español", "retry": "Reintentar", "server_connecting": "Conectando", From 6489ef479346e4b07fef3d0fd7e562e32ef66b28 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sat, 9 Dec 2023 17:23:13 -0500 Subject: [PATCH 04/25] update dictionary extensions and locale provider --- .../Extensions/DictionaryExtensions.cs | 29 ++++++-- .../Helpers/LocalizationProvider.cs | 70 ++++++++++++------- 2 files changed, 66 insertions(+), 33 deletions(-) diff --git a/project/Aki.Launcher.Base/Extensions/DictionaryExtensions.cs b/project/Aki.Launcher.Base/Extensions/DictionaryExtensions.cs index d6d82db..bb6fb8f 100644 --- a/project/Aki.Launcher.Base/Extensions/DictionaryExtensions.cs +++ b/project/Aki.Launcher.Base/Extensions/DictionaryExtensions.cs @@ -14,24 +14,39 @@ namespace Aki.Launcher.Extensions { public static class DictionaryExtensions { - public static TKey GetKeyByValue(this Dictionary Dic, TValue value) + public static TKey GetKeyByValue(this Dictionary dic, TValue value) { - List Keys = Dic.Keys.ToList(); + List keys = dic.Keys.ToList(); - for (int x = 0; x < Keys.Count(); x++) + for (var x = 0; x < keys.Count; x++) { - TValue tempValue; - - if (Dic.TryGetValue(Keys[x], out tempValue)) + if (dic.TryGetValue(keys[x], out var tempValue)) { if (tempValue != null && tempValue.Equals(value)) { - return Keys[x]; + return keys[x]; } } } return default; } + + public static TKey GetKeyByInput(this Dictionary dic, + string input) + { + var keys = dic.Keys.ToList(); + var values = dic.Values.ToList(); + + for (var x = 0; x < dic.Count; x++) + { + if (values[x] is string s && (input.ToLower() == s.ToLower() || input.ToLower().StartsWith(s.ToLower()))) + { + return keys[x]; + } + } + + return default; + } } } diff --git a/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs b/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs index 16aab96..afd78b6 100644 --- a/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs +++ b/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs @@ -24,11 +24,11 @@ namespace Aki.Launcher.Helpers { public static string DefaultLocaleFolderPath = Path.Join(Environment.CurrentDirectory, "Aki_Data", "Launcher", "Locales"); - public static Dictionary LocaleNameDictionary = GetLocaleDictionary(); + public static Dictionary LocaleNameDictionary = GetLocaleDictionary("native_name"); public static event EventHandler LocaleChanged = delegate { }; - public static void LoadLocaleFromFile(string localeName) + public static void LoadLocalByName(string localeName) { string localeRomanName = LocaleNameDictionary.GetKeyByValue(localeName); @@ -36,7 +36,12 @@ namespace Aki.Launcher.Helpers { localeRomanName = localeName; } + + LoadLocaleFromFile(localeRomanName); + } + public static void LoadLocaleFromFile(string localeRomanName) + { LocaleData newLocale = Json.LoadClassWithoutSaving(Path.Join(DefaultLocaleFolderPath, $"{localeRomanName}.json")); if (newLocale != null) @@ -55,30 +60,24 @@ namespace Aki.Launcher.Helpers //could possibly raise an event here to say why the local wasn't changed. } - private static string GetSystemLocale() - { - string UIlocaleName = CultureInfo.CurrentUICulture.DisplayName; - - var regexMatch = Regex.Match(UIlocaleName, @"^(\w+)"); - - if (regexMatch.Groups.Count == 2) - { - string localRomanName = LocaleNameDictionary.GetValueOrDefault(regexMatch.Groups[1].Value, ""); - - bool localExists = GetAvailableLocales().Where(x => x == localRomanName).Count() > 0; - - if (localExists) - { - return localRomanName; - } - } - - return "English"; - } - public static void TryAutoSetLocale() { - LoadLocaleFromFile(GetSystemLocale()); + // get local dictionary based on ietf_tag property in locale files. like: ("English", "en") + // "English" being the file name + var localeTagDictionary = GetLocaleDictionary("ietf_tag"); + + // get system locale. Like: "en-US" + var tag = CultureInfo.CurrentUICulture.IetfLanguageTag; + + // get the locale file name from the dictionary based on the input tag. If it matches, or starts with the value + var localeRomanName = localeTagDictionary.GetKeyByInput(tag); + + if (String.IsNullOrEmpty(localeRomanName)) + { + localeRomanName = "English"; + } + + LoadLocaleFromFile(localeRomanName); } public static LocaleData GenerateEnglishLocale() @@ -88,6 +87,7 @@ namespace Aki.Launcher.Helpers LocaleData englishLocale = new LocaleData(); #region Set All English Defaults + englishLocale.ietf_tag = "en"; englishLocale.native_name = "English"; englishLocale.retry = "Retry"; englishLocale.server_connecting = "Connecting"; @@ -189,14 +189,14 @@ namespace Aki.Launcher.Helpers return englishLocale; } - public static Dictionary GetLocaleDictionary() + public static Dictionary GetLocaleDictionary(string property) { List localeFiles = new List(Directory.GetFiles(DefaultLocaleFolderPath).Select(x => new FileInfo(x)).ToList()); Dictionary localeDictionary = new Dictionary(); foreach (FileInfo file in localeFiles) { - localeDictionary.Add(file.Name.Replace(".json", ""), Json.GetPropertyByName(file.FullName, "native_name")); + localeDictionary.Add(file.Name.Replace(".json", ""), Json.GetPropertyByName(file.FullName, property)); } return localeDictionary; @@ -215,6 +215,24 @@ namespace Aki.Launcher.Helpers #region All Properties + #region ietf_tag + + private string _ietf_tag; + + public string ietf_tag + { + get => _ietf_tag; + set + { + if (_ietf_tag != value) + { + _ietf_tag = value; + RaisePropertyChanged(nameof(ietf_tag)); + } + } + } + #endregion + #region native_name private string _native_name; public string native_name From 26d1813f3e9139aa21266cf644b91b691af5f5f9 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sat, 9 Dec 2023 17:23:28 -0500 Subject: [PATCH 05/25] move first run checks to main viewmodel --- .../ViewModels/MainWindowViewModel.cs | 30 ++++++++++++++++++ .../ViewModels/ProfileViewModel.cs | 31 ------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs index 1825700..c3306b9 100644 --- a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs +++ b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs @@ -7,6 +7,10 @@ using System.IO; using Splat; using Aki.Launcher.Models.Aki; using Aki.Launcher.Helpers; +using Aki.Launcher.ViewModels.Dialogs; +using Avalonia.Threading; +using dialogHost = DialogHost.DialogHost; + namespace Aki.Launcher.ViewModels { @@ -29,6 +33,32 @@ namespace Aki.Launcher.ViewModels LauncherSettingsProvider.Instance.AllowSettings = true; + if (LauncherSettingsProvider.Instance.FirstRun) + { + Dispatcher.UIThread.InvokeAsync(async () => + { + LauncherSettingsProvider.Instance.FirstRun = false; + + LocalizationProvider.TryAutoSetLocale(); + + var viewModel = new ConfirmationDialogViewModel(this, + LocalizationProvider.Instance.copy_live_settings_question, + LocalizationProvider.Instance.yes, + LocalizationProvider.Instance.no); + + var confirmCopySettings = await dialogHost.Show(viewModel); + + if (confirmCopySettings is bool and true) + { + var settingsVm = new SettingsViewModel(this); + + await settingsVm.ResetGameSettingsCommand(); + } + + LauncherSettingsProvider.Instance.SaveSettings(); + }); + } + this.WhenActivated((CompositeDisposable disposables) => { Router.Navigate.Execute(new ConnectServerViewModel(this)); diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 699545c..03d1cbe 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -8,7 +8,6 @@ using System.Threading.Tasks; using Aki.Launcher.Attributes; using Aki.Launcher.ViewModels.Dialogs; using Avalonia.Threading; -using System.Reactive.Disposables; using System.Diagnostics; using System.IO; using Aki.Launcher.Models.Aki; @@ -62,36 +61,6 @@ namespace Aki.Launcher.ViewModels public ProfileViewModel(IScreen Host) : base(Host) { - this.WhenActivated((CompositeDisposable disposables) => - { - Task.Run(async () => - { - await GameVersionCheck(); - - await Dispatcher.UIThread.InvokeAsync(async () => - { - if (LauncherSettingsProvider.Instance.FirstRun) - { - LauncherSettingsProvider.Instance.FirstRun = false; - - LauncherSettingsProvider.Instance.SaveSettings(); - - var confirmCopySettings = await ShowDialog(new ConfirmationDialogViewModel(Host, - LocalizationProvider.Instance.copy_live_settings_question, - LocalizationProvider.Instance.yes, - LocalizationProvider.Instance.no)); - - if (confirmCopySettings != null && confirmCopySettings is bool confirmed && confirmed) - { - var settingsVM = new SettingsViewModel(Host); - - await settingsVM.ResetGameSettingsCommand(); - } - } - }); - }); - }); - // cache and load side image if profile has a side if(AccountManager.SelectedProfileInfo != null && AccountManager.SelectedProfileInfo.Side != null) { From fdd692f5fed3903a24be290d475c82a1f0c4a772 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sat, 9 Dec 2023 17:26:07 -0500 Subject: [PATCH 06/25] remove uneeded using --- project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs b/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs index afd78b6..39a5df3 100644 --- a/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs +++ b/project/Aki.Launcher.Base/Helpers/LocalizationProvider.cs @@ -16,7 +16,6 @@ using System.ComponentModel; using System.Globalization; using System.IO; using System.Linq; -using System.Text.RegularExpressions; namespace Aki.Launcher.Helpers { From f19ad0a8f812faa6f30191cc53e7c345be3c144e Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Tue, 19 Dec 2023 14:00:26 -0500 Subject: [PATCH 07/25] update game check --- .../Helpers/ValidationUtil.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs b/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs index 2e894c2..2f3d1ac 100644 --- a/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs +++ b/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs @@ -12,24 +12,24 @@ namespace Aki.Launcher.Helpers try { - var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("UninstallString"); + var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation"); var v2 = (v1 != null) ? v1.ToString() : string.Empty; - var v3 = new FileInfo(v2); - var v4 = new FileInfo[] + var v3 = new DirectoryInfo(v2); + var v4 = new FileSystemInfo[] { v3, - new FileInfo(v2.Replace(v3.Name, @"BattlEye\BEClient_x64.dll")), - new FileInfo(v2.Replace(v3.Name, @"BattlEye\BEService_x64.dll")), - new FileInfo(v2.Replace(v3.Name, @"ConsistencyInfo")), - new FileInfo(v2.Replace(v3.Name, @"Uninstall.exe")), - new FileInfo(v2.Replace(v3.Name, @"UnityCrashHandler64.exe")) + new FileInfo(Path.Join(v2, @"BattlEye\BEClient_x64.dll")), + new FileInfo(Path.Join(v2, @"BattlEye\BEService_x64.dll")), + new FileInfo(Path.Join(v2, "ConsistencyInfo")), + new FileInfo(Path.Join(v2, "Uninstall.exe")), + new FileInfo(Path.Join(v2, "UnityCrashHandler64.exe")) }; v0 = v4.Length - 1; foreach (var value in v4) { - if (File.Exists(value.FullName)) + if (value.Exists) { --v0; } From 7eaff0da3711b4c19abed8a951335e2a3b7ce40c Mon Sep 17 00:00:00 2001 From: chomp Date: Wed, 20 Dec 2023 16:59:14 +0000 Subject: [PATCH 08/25] batFix (!35) Co-authored-by: IsWaffle Co-authored-by: Dev Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Launcher/pulls/35 --- .../Controllers/GameStarter.cs | 8 +++---- .../Aki.Launcher.Base/Helpers/FilePatcher.cs | 23 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/project/Aki.Launcher.Base/Controllers/GameStarter.cs b/project/Aki.Launcher.Base/Controllers/GameStarter.cs index 1f29bcc..4131ac3 100644 --- a/project/Aki.Launcher.Base/Controllers/GameStarter.cs +++ b/project/Aki.Launcher.Base/Controllers/GameStarter.cs @@ -49,10 +49,10 @@ namespace Aki.Launcher if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return null; - var uninstallStringValue = Registry.LocalMachine.OpenSubKey(registryInstall, false) - ?.GetValue("UninstallString"); - var info = (uninstallStringValue is string key) ? new FileInfo(key) : null; - return info?.DirectoryName; + var installLocation = Registry.LocalMachine.OpenSubKey(registryInstall, false) + ?.GetValue("InstallLocation"); + var info = (installLocation is string key) ? new DirectoryInfo(key) : null; + return info?.FullName; } public async Task LaunchGame(ServerInfo server, AccountInfo account, string gamePath) diff --git a/project/Aki.Launcher.Base/Helpers/FilePatcher.cs b/project/Aki.Launcher.Base/Helpers/FilePatcher.cs index 05e3917..34650c9 100644 --- a/project/Aki.Launcher.Base/Helpers/FilePatcher.cs +++ b/project/Aki.Launcher.Base/Helpers/FilePatcher.cs @@ -9,8 +9,8 @@ using System; using System.IO; -using System.Reflection.Metadata.Ecma335; using Aki.ByteBanger; +using Aki.Launcher.Controllers; using Aki.Launcher.MiniCommon; using Aki.Launcher.Models.Launcher; @@ -115,14 +115,21 @@ namespace Aki.Launcher.Helpers var target = Path.ChangeExtension(file.FullName, null); // remove patched file - var patched = new FileInfo(target); - patched.IsReadOnly = false; - patched.Delete(); + try + { + var patched = new FileInfo(target); + patched.IsReadOnly = false; + patched.Delete(); - // restore from backup - File.Copy(file.FullName, target); - file.IsReadOnly = false; - file.Delete(); + // Restore from backup + File.Copy(file.FullName, target); + file.IsReadOnly = false; + file.Delete(); + } + catch (Exception ex) + { + LogManager.Instance.Exception(ex); + } } } } From 7edc7d4673a184450b9fd33abfe182a735682b80 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Fri, 26 Jan 2024 09:30:32 -0500 Subject: [PATCH 09/25] fix path geo formating --- project/Aki.Launcher/App.axaml | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/project/Aki.Launcher/App.axaml b/project/Aki.Launcher/App.axaml index ec353f3..356068f 100644 --- a/project/Aki.Launcher/App.axaml +++ b/project/Aki.Launcher/App.axaml @@ -31,33 +31,36 @@ - + - - - - - - - + + - - + + From 5468843f489759331ef915d5ecf0aea5f381dd5a Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Fri, 26 Jan 2024 09:40:44 -0500 Subject: [PATCH 10/25] fix wrong method on property changed --- project/Aki.Launcher.Base/Models/Launcher/LocaleCollection.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/Aki.Launcher.Base/Models/Launcher/LocaleCollection.cs b/project/Aki.Launcher.Base/Models/Launcher/LocaleCollection.cs index 586554b..9a670bd 100644 --- a/project/Aki.Launcher.Base/Models/Launcher/LocaleCollection.cs +++ b/project/Aki.Launcher.Base/Models/Launcher/LocaleCollection.cs @@ -26,7 +26,7 @@ namespace Aki.Launcher.Models.Launcher { _SelectedLocale = value; RaisePropertyChanged(nameof(SelectedLocale)); - LocalizationProvider.LoadLocaleFromFile(value); + LocalizationProvider.LoadLocalByName(value); } } } From fa8284da526c8cd1e7de64be1a30e4a7c4be80e5 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Fri, 26 Jan 2024 12:35:57 -0500 Subject: [PATCH 11/25] add mod info page --- .../CustomControls/ModInfoCard.axaml | 6 +- .../ViewModels/ModInfoViewModel.cs | 10 + .../ViewModels/ProfileViewModel.cs | 3 +- project/Aki.Launcher/Views/ModInfoView.axaml | 14 + .../Aki.Launcher/Views/ModInfoView.axaml.cs | 20 ++ project/Aki.Launcher/Views/ProfileView.axaml | 317 +++++++++--------- 6 files changed, 199 insertions(+), 171 deletions(-) create mode 100644 project/Aki.Launcher/ViewModels/ModInfoViewModel.cs create mode 100644 project/Aki.Launcher/Views/ModInfoView.axaml create mode 100644 project/Aki.Launcher/Views/ModInfoView.axaml.cs diff --git a/project/Aki.Launcher/CustomControls/ModInfoCard.axaml b/project/Aki.Launcher/CustomControls/ModInfoCard.axaml index 8982a1d..b045c5b 100644 --- a/project/Aki.Launcher/CustomControls/ModInfoCard.axaml +++ b/project/Aki.Launcher/CustomControls/ModInfoCard.axaml @@ -14,9 +14,9 @@ > + VerticalAlignment="Center" + Orientation="Horizontal" Spacing="5" + > diff --git a/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs b/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs new file mode 100644 index 0000000..aa2177c --- /dev/null +++ b/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs @@ -0,0 +1,10 @@ +using ReactiveUI; + +namespace Aki.Launcher.ViewModels; + +public class ModInfoViewModel : ViewModelBase +{ + public ModInfoViewModel(IScreen Host) : base(Host) + { + } +} \ No newline at end of file diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 03d1cbe..87bc112 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -104,7 +104,8 @@ namespace Aki.Launcher.ViewModels } } - public void ToggleModsListCommand() => ModsListIsVisible = !ModsListIsVisible; + public void OpenModsInfoCommand() => + NavigateTo(new ModInfoViewModel(HostScreen)); public void LogoutCommand() { diff --git a/project/Aki.Launcher/Views/ModInfoView.axaml b/project/Aki.Launcher/Views/ModInfoView.axaml new file mode 100644 index 0000000..1a08ff4 --- /dev/null +++ b/project/Aki.Launcher/Views/ModInfoView.axaml @@ -0,0 +1,14 @@ + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - - Date: Sun, 26 Nov 2023 11:27:29 -0500 Subject: [PATCH 16/25] remove early return from tag check --- project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs index a2f2afa..b4c2d1e 100644 --- a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs +++ b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs @@ -34,7 +34,6 @@ namespace Aki.Launcher.Models.Aki AkiVersion = versionInfo[0]; Tag = versionInfo[1]; - return; } string[] splitVersion = AkiVersion.Split('.'); From b965db2211e8baaf869aa30d09bdbdeb94fb07ca Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Tue, 5 Dec 2023 10:00:37 -0500 Subject: [PATCH 17/25] return bool when loading server --- .../Aki.Launcher.Base/Controllers/ServerManager.cs | 14 ++++++-------- .../ViewModels/ConnectServerViewModel.cs | 10 ++++++++-- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/project/Aki.Launcher.Base/Controllers/ServerManager.cs b/project/Aki.Launcher.Base/Controllers/ServerManager.cs index ab76001..d424d26 100644 --- a/project/Aki.Launcher.Base/Controllers/ServerManager.cs +++ b/project/Aki.Launcher.Base/Controllers/ServerManager.cs @@ -92,7 +92,7 @@ namespace Aki.Launcher } } - public static void LoadServer(string backendUrl) + public static bool LoadServer(string backendUrl) { string json = ""; @@ -100,22 +100,20 @@ namespace Aki.Launcher { RequestHandler.ChangeBackendUrl(backendUrl); json = RequestHandler.RequestConnect(); + SelectedServer = Json.Deserialize(json); } catch { SelectedServer = null; - return; + return false; } - SelectedServer = Json.Deserialize(json); + return true; } - public static async Task LoadDefaultServerAsync(string server) + public static async Task LoadDefaultServerAsync(string server) { - await Task.Run(() => - { - LoadServer(server); - }); + return await Task.Run(() => LoadServer(server)); } } } diff --git a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs index 6b739f1..017ed5c 100644 --- a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs @@ -32,8 +32,14 @@ namespace Aki.Launcher.ViewModels public async Task ConnectServer() { - await ServerManager.LoadDefaultServerAsync(LauncherSettingsProvider.Instance.Server.Url); - + if (!await ServerManager.LoadDefaultServerAsync(LauncherSettingsProvider.Instance.Server.Url)) + { + connectModel.ConnectionFailed = true; + connectModel.InfoText = string.Format(LocalizationProvider.Instance.server_unavailable_format_1, + LauncherSettingsProvider.Instance.Server.Name); + return; + } + bool connected = ServerManager.PingServer(); connectModel.ConnectionFailed = !connected; From 16dbb75a84d71b1875467316ab8e901b8757d280 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Tue, 19 Dec 2023 14:00:26 -0500 Subject: [PATCH 18/25] update game check --- .../Helpers/ValidationUtil.cs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs b/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs index 2e894c2..2f3d1ac 100644 --- a/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs +++ b/project/Aki.Launcher.Base/Helpers/ValidationUtil.cs @@ -12,24 +12,24 @@ namespace Aki.Launcher.Helpers try { - var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("UninstallString"); + var v1 = Registry.LocalMachine.OpenSubKey(c0, false).GetValue("InstallLocation"); var v2 = (v1 != null) ? v1.ToString() : string.Empty; - var v3 = new FileInfo(v2); - var v4 = new FileInfo[] + var v3 = new DirectoryInfo(v2); + var v4 = new FileSystemInfo[] { v3, - new FileInfo(v2.Replace(v3.Name, @"BattlEye\BEClient_x64.dll")), - new FileInfo(v2.Replace(v3.Name, @"BattlEye\BEService_x64.dll")), - new FileInfo(v2.Replace(v3.Name, @"ConsistencyInfo")), - new FileInfo(v2.Replace(v3.Name, @"Uninstall.exe")), - new FileInfo(v2.Replace(v3.Name, @"UnityCrashHandler64.exe")) + new FileInfo(Path.Join(v2, @"BattlEye\BEClient_x64.dll")), + new FileInfo(Path.Join(v2, @"BattlEye\BEService_x64.dll")), + new FileInfo(Path.Join(v2, "ConsistencyInfo")), + new FileInfo(Path.Join(v2, "Uninstall.exe")), + new FileInfo(Path.Join(v2, "UnityCrashHandler64.exe")) }; v0 = v4.Length - 1; foreach (var value in v4) { - if (File.Exists(value.FullName)) + if (value.Exists) { --v0; } From 8e6ff47a639f1720c08c3291c4a17ffe80d71510 Mon Sep 17 00:00:00 2001 From: chomp Date: Wed, 20 Dec 2023 16:59:14 +0000 Subject: [PATCH 19/25] batFix (!35) Co-authored-by: IsWaffle Co-authored-by: Dev Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Launcher/pulls/35 --- .../Controllers/GameStarter.cs | 8 +++---- .../Aki.Launcher.Base/Helpers/FilePatcher.cs | 23 ++++++++++++------- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/project/Aki.Launcher.Base/Controllers/GameStarter.cs b/project/Aki.Launcher.Base/Controllers/GameStarter.cs index 1f29bcc..4131ac3 100644 --- a/project/Aki.Launcher.Base/Controllers/GameStarter.cs +++ b/project/Aki.Launcher.Base/Controllers/GameStarter.cs @@ -49,10 +49,10 @@ namespace Aki.Launcher if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) return null; - var uninstallStringValue = Registry.LocalMachine.OpenSubKey(registryInstall, false) - ?.GetValue("UninstallString"); - var info = (uninstallStringValue is string key) ? new FileInfo(key) : null; - return info?.DirectoryName; + var installLocation = Registry.LocalMachine.OpenSubKey(registryInstall, false) + ?.GetValue("InstallLocation"); + var info = (installLocation is string key) ? new DirectoryInfo(key) : null; + return info?.FullName; } public async Task LaunchGame(ServerInfo server, AccountInfo account, string gamePath) diff --git a/project/Aki.Launcher.Base/Helpers/FilePatcher.cs b/project/Aki.Launcher.Base/Helpers/FilePatcher.cs index 05e3917..34650c9 100644 --- a/project/Aki.Launcher.Base/Helpers/FilePatcher.cs +++ b/project/Aki.Launcher.Base/Helpers/FilePatcher.cs @@ -9,8 +9,8 @@ using System; using System.IO; -using System.Reflection.Metadata.Ecma335; using Aki.ByteBanger; +using Aki.Launcher.Controllers; using Aki.Launcher.MiniCommon; using Aki.Launcher.Models.Launcher; @@ -115,14 +115,21 @@ namespace Aki.Launcher.Helpers var target = Path.ChangeExtension(file.FullName, null); // remove patched file - var patched = new FileInfo(target); - patched.IsReadOnly = false; - patched.Delete(); + try + { + var patched = new FileInfo(target); + patched.IsReadOnly = false; + patched.Delete(); - // restore from backup - File.Copy(file.FullName, target); - file.IsReadOnly = false; - file.Delete(); + // Restore from backup + File.Copy(file.FullName, target); + file.IsReadOnly = false; + file.Delete(); + } + catch (Exception ex) + { + LogManager.Instance.Exception(ex); + } } } } From 81758d3529f316657280a0201642852ce1f0e629 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Fri, 26 Jan 2024 09:30:32 -0500 Subject: [PATCH 20/25] fix path geo formating --- project/Aki.Launcher/App.axaml | 39 ++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/project/Aki.Launcher/App.axaml b/project/Aki.Launcher/App.axaml index ec353f3..356068f 100644 --- a/project/Aki.Launcher/App.axaml +++ b/project/Aki.Launcher/App.axaml @@ -31,33 +31,36 @@ - + - - - - - - - + + - - + + From 596d33de227855047b615a2128ba95f2760ec571 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Fri, 26 Jan 2024 12:35:57 -0500 Subject: [PATCH 21/25] add mod info page --- .../CustomControls/ModInfoCard.axaml | 6 +- .../ViewModels/ModInfoViewModel.cs | 10 + .../ViewModels/ProfileViewModel.cs | 3 +- project/Aki.Launcher/Views/ModInfoView.axaml | 14 + .../Aki.Launcher/Views/ModInfoView.axaml.cs | 20 ++ project/Aki.Launcher/Views/ProfileView.axaml | 317 +++++++++--------- 6 files changed, 199 insertions(+), 171 deletions(-) create mode 100644 project/Aki.Launcher/ViewModels/ModInfoViewModel.cs create mode 100644 project/Aki.Launcher/Views/ModInfoView.axaml create mode 100644 project/Aki.Launcher/Views/ModInfoView.axaml.cs diff --git a/project/Aki.Launcher/CustomControls/ModInfoCard.axaml b/project/Aki.Launcher/CustomControls/ModInfoCard.axaml index 8982a1d..b045c5b 100644 --- a/project/Aki.Launcher/CustomControls/ModInfoCard.axaml +++ b/project/Aki.Launcher/CustomControls/ModInfoCard.axaml @@ -14,9 +14,9 @@ > + VerticalAlignment="Center" + Orientation="Horizontal" Spacing="5" + > diff --git a/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs b/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs new file mode 100644 index 0000000..aa2177c --- /dev/null +++ b/project/Aki.Launcher/ViewModels/ModInfoViewModel.cs @@ -0,0 +1,10 @@ +using ReactiveUI; + +namespace Aki.Launcher.ViewModels; + +public class ModInfoViewModel : ViewModelBase +{ + public ModInfoViewModel(IScreen Host) : base(Host) + { + } +} \ No newline at end of file diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 03d1cbe..87bc112 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -104,7 +104,8 @@ namespace Aki.Launcher.ViewModels } } - public void ToggleModsListCommand() => ModsListIsVisible = !ModsListIsVisible; + public void OpenModsInfoCommand() => + NavigateTo(new ModInfoViewModel(HostScreen)); public void LogoutCommand() { diff --git a/project/Aki.Launcher/Views/ModInfoView.axaml b/project/Aki.Launcher/Views/ModInfoView.axaml new file mode 100644 index 0000000..1a08ff4 --- /dev/null +++ b/project/Aki.Launcher/Views/ModInfoView.axaml @@ -0,0 +1,14 @@ + + + + + + - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - - - - - - - - - - - - - - -