From c1679ff14199519d99e0c8a979b334fdc73085a4 Mon Sep 17 00:00:00 2001 From: "waffle.lord" Date: Wed, 15 Mar 2023 19:34:29 -0400 Subject: [PATCH] added edition tooltips, cleaned up some namespaces --- .../Models/Aki/AkiEdition.cs | 17 ++++++++++++++ .../Models/Aki/AkiVersion.cs | 2 +- .../Models/Aki/ServerInfo.cs | 4 ++++ .../Models/Launcher/EditionCollection.cs | 12 +++++++--- .../Models/Launcher/ProfileInfo.cs | 1 - .../ViewModels/ConnectServerViewModel.cs | 2 +- .../Aki.Launcher/ViewModels/LoginViewModel.cs | 4 ++-- .../ViewModels/MainWindowViewModel.cs | 2 +- .../ViewModels/ProfileViewModel.cs | 5 ++-- .../Dialogs/ChangeEditionDialogView.axaml | 16 +++++++++---- .../Views/Dialogs/RegisterDialogView.axaml | 23 ++++++++++++------- 11 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 project/Aki.Launcher.Base/Models/Aki/AkiEdition.cs diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiEdition.cs b/project/Aki.Launcher.Base/Models/Aki/AkiEdition.cs new file mode 100644 index 0000000..4a9662d --- /dev/null +++ b/project/Aki.Launcher.Base/Models/Aki/AkiEdition.cs @@ -0,0 +1,17 @@ +using Aki.Launcher; + +namespace Aki.Launcher.Models.Aki +{ + public class AkiEdition + { + public string Name { get; set; } + public string Description { get; set; } + + public AkiEdition(string name) + { + Name = name; + ServerManager.SelectedServer.profileDescriptions.TryGetValue(name, out string desc); + Description = desc; + } + } +} diff --git a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs index 255af0e..a2f2afa 100644 --- a/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs +++ b/project/Aki.Launcher.Base/Models/Aki/AkiVersion.cs @@ -1,6 +1,6 @@ using System.ComponentModel; -namespace Aki.Launch.Models.Aki +namespace Aki.Launcher.Models.Aki { public class AkiVersion : INotifyPropertyChanged { diff --git a/project/Aki.Launcher.Base/Models/Aki/ServerInfo.cs b/project/Aki.Launcher.Base/Models/Aki/ServerInfo.cs index 56ffb73..efe81ea 100644 --- a/project/Aki.Launcher.Base/Models/Aki/ServerInfo.cs +++ b/project/Aki.Launcher.Base/Models/Aki/ServerInfo.cs @@ -7,6 +7,8 @@ */ +using System.Collections.Generic; + namespace Aki.Launcher { public class ServerInfo @@ -14,12 +16,14 @@ namespace Aki.Launcher public string backendUrl; public string name; public string[] editions; + public Dictionary profileDescriptions; public ServerInfo() { backendUrl = "http://127.0.0.1:6969"; name = "Local SPT-AKI Server"; editions = new string[0]; + profileDescriptions = new Dictionary(); } } } diff --git a/project/Aki.Launcher.Base/Models/Launcher/EditionCollection.cs b/project/Aki.Launcher.Base/Models/Launcher/EditionCollection.cs index 22911c8..47ed619 100644 --- a/project/Aki.Launcher.Base/Models/Launcher/EditionCollection.cs +++ b/project/Aki.Launcher.Base/Models/Launcher/EditionCollection.cs @@ -7,6 +7,7 @@ */ +using Aki.Launcher.Models.Aki; using System.Collections.ObjectModel; using System.ComponentModel; @@ -41,8 +42,8 @@ namespace Aki.Launcher.Models.Launcher } } - private string _SelectedEdition; - public string SelectedEdition + private AkiEdition _SelectedEdition; + public AkiEdition SelectedEdition { get => _SelectedEdition; set @@ -55,11 +56,16 @@ namespace Aki.Launcher.Models.Launcher } } } - public ObservableCollection AvailableEditions { get; private set; } = new ObservableCollection(ServerManager.SelectedServer.editions); + public ObservableCollection AvailableEditions { get; private set; } = new ObservableCollection(); public EditionCollection() { SelectedEditionIndex = 0; + + foreach(var edition in ServerManager.SelectedServer.editions) + { + AvailableEditions.Add(new AkiEdition(edition)); + } } public event PropertyChangedEventHandler PropertyChanged; diff --git a/project/Aki.Launcher.Base/Models/Launcher/ProfileInfo.cs b/project/Aki.Launcher.Base/Models/Launcher/ProfileInfo.cs index 0503cbc..86de895 100644 --- a/project/Aki.Launcher.Base/Models/Launcher/ProfileInfo.cs +++ b/project/Aki.Launcher.Base/Models/Launcher/ProfileInfo.cs @@ -6,7 +6,6 @@ * waffle.lord */ -using Aki.Launch.Models.Aki; using Aki.Launcher.Helpers; using Aki.Launcher.MiniCommon; using Aki.Launcher.Models.Aki; diff --git a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs index 0245deb..6b739f1 100644 --- a/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ConnectServerViewModel.cs @@ -1,4 +1,4 @@ -using Aki.Launch.Models.Aki; +using Aki.Launcher.Models.Aki; using Aki.Launcher.Helpers; using Aki.Launcher.Models.Launcher; using ReactiveUI; diff --git a/project/Aki.Launcher/ViewModels/LoginViewModel.cs b/project/Aki.Launcher/ViewModels/LoginViewModel.cs index b3b1a5c..4f7160a 100644 --- a/project/Aki.Launcher/ViewModels/LoginViewModel.cs +++ b/project/Aki.Launcher/ViewModels/LoginViewModel.cs @@ -50,9 +50,9 @@ namespace Aki.Launcher.ViewModels { var result = await ShowDialog(new RegisterDialogViewModel(null, Login.Username)); - if (result != null && result is string edition) + if (result != null && result is AkiEdition edition) { - AccountStatus registerResult = await AccountManager.RegisterAsync(Login.Username, Login.Password, edition); + AccountStatus registerResult = await AccountManager.RegisterAsync(Login.Username, Login.Password, edition.Name); switch (registerResult) { diff --git a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs index 52b2e55..1825700 100644 --- a/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs +++ b/project/Aki.Launcher/ViewModels/MainWindowViewModel.cs @@ -5,7 +5,7 @@ using Aki.Launcher.Models; using Aki.Launcher.MiniCommon; using System.IO; using Splat; -using Aki.Launch.Models.Aki; +using Aki.Launcher.Models.Aki; using Aki.Launcher.Helpers; namespace Aki.Launcher.ViewModels diff --git a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs index 51b79ec..810ca39 100644 --- a/project/Aki.Launcher/ViewModels/ProfileViewModel.cs +++ b/project/Aki.Launcher/ViewModels/ProfileViewModel.cs @@ -11,6 +11,7 @@ using Avalonia.Threading; using System.Reactive.Disposables; using System.Diagnostics; using System.IO; +using Aki.Launcher.Models.Aki; namespace Aki.Launcher.ViewModels { @@ -161,9 +162,9 @@ namespace Aki.Launcher.ViewModels { var result = await ShowDialog(new ChangeEditionDialogViewModel(null)); - if(result != null && result is string edition) + if(result != null && result is AkiEdition edition) { - AccountStatus status = await AccountManager.WipeAsync(edition); + AccountStatus status = await AccountManager.WipeAsync(edition.Name); switch (status) { diff --git a/project/Aki.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml b/project/Aki.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml index 5334efb..1c228d9 100644 --- a/project/Aki.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml +++ b/project/Aki.Launcher/Views/Dialogs/ChangeEditionDialogView.axaml @@ -15,11 +15,17 @@ Content="{Binding Source={x:Static helpers:LocalizationProvider.Instance}, Path=wipe_warning}" Foreground="IndianRed" /> - + + + + + +