From 4dd1a3c50a0771045bdc5a278067a23977cbac7b Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Sun, 13 Aug 2023 11:00:10 -0400 Subject: [PATCH 1/3] add server endpoints and classes --- .../Controllers/RequestHandler.cs | 10 +++++ .../Controllers/ServerManager.cs | 31 +++++++++++++ .../Models/Aki/AkiProfileModInfo.cs | 20 +++++++++ .../Models/Aki/AkiServerModInfo.cs | 45 +++++++++++++++++++ .../Models/Aki/DevDependencies.cs | 37 +++++++++++++++ project/Aki.Launcher/Assets/Styles.axaml | 14 +++++- .../ViewModels/ProfileViewModel.cs | 8 ++++ project/Aki.Launcher/Views/ProfileView.axaml | 28 ++++++++++++ 8 files changed, 192 insertions(+), 1 deletion(-) create mode 100644 project/Aki.Launcher.Base/Models/Aki/AkiProfileModInfo.cs create mode 100644 project/Aki.Launcher.Base/Models/Aki/AkiServerModInfo.cs create mode 100644 project/Aki.Launcher.Base/Models/Aki/DevDependencies.cs diff --git a/project/Aki.Launcher.Base/Controllers/RequestHandler.cs b/project/Aki.Launcher.Base/Controllers/RequestHandler.cs index 52e9447..3aef72d 100644 --- a/project/Aki.Launcher.Base/Controllers/RequestHandler.cs +++ b/project/Aki.Launcher.Base/Controllers/RequestHandler.cs @@ -94,5 +94,15 @@ namespace Aki.Launcher { return request.GetJson("/launcher/profile/compatibleTarkovVersion"); } + + public static string RequestLoadedServerMods() + { + return request.GetJson("/launcher/server/loadedServerMods"); + } + + public static string RequestProfileMods() + { + return request.GetJson("/launcher/server/serverModsUsedByProfile"); + } } } diff --git a/project/Aki.Launcher.Base/Controllers/ServerManager.cs b/project/Aki.Launcher.Base/Controllers/ServerManager.cs index d047cc3..bf192d4 100644 --- a/project/Aki.Launcher.Base/Controllers/ServerManager.cs +++ b/project/Aki.Launcher.Base/Controllers/ServerManager.cs @@ -7,7 +7,10 @@ */ +using Aki.Launch.Models.Aki; using Aki.Launcher.MiniCommon; +using System.Collections.Generic; +using System.Linq; using System.Threading.Tasks; namespace Aki.Launcher @@ -62,6 +65,34 @@ namespace Aki.Launcher } } + public static Dictionary GetLoadedServerMods() + { + try + { + string json = RequestHandler.RequestLoadedServerMods(); + + return Json.Deserialize>(json); + } + catch + { + return new Dictionary(); + } + } + + public static AkiProfileModInfo[] GetProfileMods() + { + try + { + string json = RequestHandler.RequestProfileMods(); + + return Json.Deserialize(json); + } + catch + { + return new AkiProfileModInfo[] { }; + } + } + public static void LoadServer(string backendUrl) { string json = ""; diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiProfileModInfo.cs b/project/Aki.Launcher.Base/Models/Aki/AkiProfileModInfo.cs new file mode 100644 index 0000000..e6eec09 --- /dev/null +++ b/project/Aki.Launcher.Base/Models/Aki/AkiProfileModInfo.cs @@ -0,0 +1,20 @@ +using System; + +namespace Aki.Launch.Models.Aki +{ + public class AkiProfileModInfo + { + public string Author { get; set; } + public string Name { get; set; } + public DateTime DateAdded { get; set; } + public string Version { get; set; } + } +} + + +/* + "author": "Boop", + "dateAdded": 1687150604114, + "name": "Boop's Quest Zone API", + "version": "1.0.0" +*/ \ No newline at end of file diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiServerModInfo.cs b/project/Aki.Launcher.Base/Models/Aki/AkiServerModInfo.cs new file mode 100644 index 0000000..8cd1dbc --- /dev/null +++ b/project/Aki.Launcher.Base/Models/Aki/AkiServerModInfo.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; + +namespace Aki.Launch.Models.Aki +{ + public class AkiServerModInfo + { + public string Name { get; set; } + public string Version { get; set; } + public string Main { get; set; } + public string License { get; set; } + public string Author { get; set; } + public string AkiVersion { get; set; } + public Dictionary Scripts { get; set; } + public DevDependencies DevDependencies { get; set; } + } +} + +/* +{ + "wafflelord-ZeroToHeroPlus-1.0.0": { + "name": "ZeroToHeroPlus", + "version": "1.0.0", + "main": "src/mod.ts", + "license": "MIT", + "author": "waffle.lord", + "akiVersion": "~3.6", + "scripts": { + "setup": "npm i", + "build": "node ./packageBuild.ts" + }, + "devDependencies": { + "@types/node": "16.18.10", + "@typescript-eslint/eslint-plugin": "5.46.1", + "@typescript-eslint/parser": "5.46.1", + "bestzip": "2.2.1", + "eslint": "8.30.0", + "fs-extra": "11.1.0", + "glob": "8.0.3", + "tsyringe": "4.7.0", + "typescript": "4.9.4" + } + } +} +*/ \ No newline at end of file diff --git a/project/Aki.Launcher.Base/Models/Aki/DevDependencies.cs b/project/Aki.Launcher.Base/Models/Aki/DevDependencies.cs new file mode 100644 index 0000000..980c139 --- /dev/null +++ b/project/Aki.Launcher.Base/Models/Aki/DevDependencies.cs @@ -0,0 +1,37 @@ +using Newtonsoft.Json; + +namespace Aki.Launch.Models.Aki +{ + public class DevDependencies + { + [JsonProperty("@types/node")] + public string TypesNode { get; set; } + + [JsonProperty("@typescript-eslint/eslint-plugin")] + public string EslintPlugin { get; set; } + + [JsonProperty("@typescript-eslint/parser")] + public string EslintParser { get; set; } + public string BestZip { get; set; } + public string Eslint { get; set; } + + [JsonProperty("fs-extra")] + public string FsExtra { get; set; } + public string Glob { get; set; } + public string Tsyringe { get; set; } + public string Typescript { get; set; } + + } +} + +/* + "@types/node": "16.18.10", + "@typescript-eslint/eslint-plugin": "5.46.1", + "@typescript-eslint/parser": "5.46.1", + "bestzip": "2.2.1", + "eslint": "8.30.0", + "fs-extra": "11.1.0", + "glob": "8.0.3", + "tsyringe": "4.7.0", + "typescript": "4.9.4" +*/ \ No newline at end of file diff --git a/project/Aki.Launcher/Assets/Styles.axaml b/project/Aki.Launcher/Assets/Styles.axaml index 150ea41..b12d7d2 100644 --- a/project/Aki.Launcher/Assets/Styles.axaml +++ b/project/Aki.Launcher/Assets/Styles.axaml @@ -4,10 +4,13 @@ xmlns:rxui="using:Avalonia.ReactiveUI" > - + + + + + + + + + + + + - + - From 08dfba17f16553e807bd8ed5b8fef8066e94f9c2 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Mon, 14 Aug 2023 09:50:00 -0400 Subject: [PATCH 3/3] add mods info colleciton, some cleanup --- .../Models/Launcher/ModInfoCollection.cs | 106 ++++++++++++++++++ .../ViewModels/ProfileViewModel.cs | 50 +-------- project/Aki.Launcher/Views/ProfileView.axaml | 12 +- 3 files changed, 114 insertions(+), 54 deletions(-) create mode 100644 project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs diff --git a/project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs b/project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs new file mode 100644 index 0000000..7a80a7f --- /dev/null +++ b/project/Aki.Launcher.Base/Models/Launcher/ModInfoCollection.cs @@ -0,0 +1,106 @@ +using Aki.Launcher.Models.Aki; +using System.Collections.ObjectModel; +using System.ComponentModel; +using System.Linq; + +namespace Aki.Launcher.Models.Launcher +{ + public class ModInfoCollection : INotifyPropertyChanged + { + private int _serverModsCount; + public int ServerModsCount + { + get => _serverModsCount; + set + { + if (_serverModsCount != value) + { + _serverModsCount = value; + RaisePropertyChanged(nameof(ServerModsCount)); + } + } + } + + private int _profileModsCount; + public int ProfileModsCount + { + get => _profileModsCount; + set + { + if (_profileModsCount != value) + { + _profileModsCount = value; + RaisePropertyChanged(nameof(ProfileModsCount)); + } + } + } + + private bool _hasProfileOnlyMods; + public bool HasProfileOnlyMods + { + get => _hasProfileOnlyMods; + set + { + if (_hasProfileOnlyMods != value) + { + _hasProfileOnlyMods = value; + RaisePropertyChanged(nameof(HasProfileOnlyMods)); + } + } + } + + private bool _hasMods; + public bool HasMods + { + get => _hasMods; + set + { + if (_hasMods != value) + { + _hasMods = value; + RaisePropertyChanged(nameof(HasMods)); + } + } + } + + public ObservableCollection Mods { get; private set; } = new ObservableCollection(); + + public ModInfoCollection() + { + var serverMods = ServerManager.GetLoadedServerMods().Values.ToList(); + var profileMods = ServerManager.GetProfileMods().ToList(); + + ServerModsCount = serverMods?.Count() ?? 0; + ProfileModsCount = profileMods?.Count() ?? 0; + + foreach (var serverMod in serverMods) + { + serverMod.InServer = true; + Mods.Add(serverMod); + } + + foreach (var profileMod in profileMods) + { + var existingMod = Mods.Where(x => x.Name == profileMod.Name && x.Version == profileMod.Version && x.Author == profileMod.Author).FirstOrDefault(); + + if (existingMod != null) + { + existingMod.InProfile = true; + continue; + } + + profileMod.InProfile = true; + Mods.Add(profileMod); + } + + HasMods = Mods.Count() > 0; + HasProfileOnlyMods = Mods.Where(x => x.InProfile && !x.InServer).Count() > 0; + } + + public event PropertyChangedEventHandler PropertyChanged; + protected virtual void RaisePropertyChanged(string property) + { + PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(property)); + } + } +} diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 81e6ad7..5aa2f55 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -12,9 +12,6 @@ using System.Reactive.Disposables; using System.Diagnostics; using System.IO; using Aki.Launcher.Models.Aki; -using System.Collections.ObjectModel; -using System.Linq; -using Avalonia.Media; namespace Aki.Launcher.ViewModels { @@ -37,22 +34,13 @@ namespace Aki.Launcher.ViewModels set => this.RaiseAndSetIfChanged(ref _ModsListIsVisible, value); } - private PathGeometry _ModsListToggleButtonIcon; - public PathGeometry ModsListToggleButtonIcon - { - get => _ModsListToggleButtonIcon; - set => this.RaiseAndSetIfChanged(ref _ModsListToggleButtonIcon, value); - } - public string CurrentID { get; set; } public ProfileInfo ProfileInfo { get; set; } = AccountManager.SelectedProfileInfo; public ImageHelper SideImage { get; } = new ImageHelper(); - public ObservableCollection Mods { get; set; } = new ObservableCollection(); - public int ServerModsCount { get; set; } - public int ProfileModsCount { get; set; } + public ModInfoCollection ModInfoCollection { get; set; } = new ModInfoCollection(); private GameStarter gameStarter = new GameStarter(new GameStarterFrontend()); @@ -84,33 +72,7 @@ namespace Aki.Launcher.ViewModels CurrentID = AccountManager.SelectedAccount.id; - var serverMods = ServerManager.GetLoadedServerMods().Values.ToList(); - var profileMods = ServerManager.GetProfileMods().ToList(); - - ProfileModsCount = profileMods?.Count() ?? 0; - ServerModsCount = serverMods?.Count() ?? 0; - ModsListIsVisible = false; - - foreach (var serverMod in serverMods) - { - serverMod.InServer = true; - Mods.Add(serverMod); - } - - foreach (var profileMod in profileMods) - { - var existingMod = Mods.Where(x => x.Name == profileMod.Name && x.Version == profileMod.Version && x.Author == profileMod.Author).FirstOrDefault(); - - if (existingMod != null) - { - existingMod.InProfile = true; - continue; - } - - profileMod.InProfile = true; - Mods.Add(profileMod); - } } private async Task GameVersionCheck() @@ -137,15 +99,7 @@ namespace Aki.Launcher.ViewModels } } - public void ToggleModsListCommand() - { - - Dispatcher.UIThread.InvokeAsync(() => - { - ModsListIsVisible = !ModsListIsVisible; - //ModsListToggleButtonIcon = ModsListIsVisible ? "<" : ">"; - }); - } + public void ToggleModsListCommand() => ModsListIsVisible = !ModsListIsVisible; public void LogoutCommand() { diff --git a/project/Aki.Launcher/Views/ProfileView.axaml b/project/Aki.Launcher/Views/ProfileView.axaml index dd5b2b7..df67337 100644 --- a/project/Aki.Launcher/Views/ProfileView.axaml +++ b/project/Aki.Launcher/Views/ProfileView.axaml @@ -60,23 +60,23 @@