From 8eb3b0d60e9d8c44d27787daeb18e804fc10ae54 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Mon, 7 Feb 2022 10:51:23 +0100 Subject: [PATCH] UI overhaul, achievements are now listed in the GUI --- GoldbergGUI.Core/ViewModels/MainViewModel.cs | 27 +++-- GoldbergGUI.WPF/Views/MainView.xaml | 104 ++++++++++++------- GoldbergGUI.sln | 6 ++ README.md | 18 +++- 4 files changed, 108 insertions(+), 47 deletions(-) diff --git a/GoldbergGUI.Core/ViewModels/MainViewModel.cs b/GoldbergGUI.Core/ViewModels/MainViewModel.cs index 7eb9993..54580c7 100644 --- a/GoldbergGUI.Core/ViewModels/MainViewModel.cs +++ b/GoldbergGUI.Core/ViewModels/MainViewModel.cs @@ -30,7 +30,7 @@ namespace GoldbergGUI.Core.ViewModels private int _appId; //private SteamApp _currentGame; - private List achievements; + private ObservableCollection _achievements; private ObservableCollection _dlcs; private string _accountName; private long _steamId; @@ -143,6 +143,16 @@ namespace GoldbergGUI.Core.ViewModels } } + public ObservableCollection Achievements + { + get => _achievements; + set + { + _achievements = value; + RaisePropertyChanged(() => Achievements); + } + } + public string AccountName { get => _accountName; @@ -381,13 +391,14 @@ namespace GoldbergGUI.Core.ViewModels MainWindowEnabled = false; StatusText = "Trying to get list of achievements..."; - achievements = await _steam.GetListOfAchievements(new SteamApp { AppId = AppId, Name = GameName }); + var listOfAchievements = await _steam.GetListOfAchievements(new SteamApp { AppId = AppId, Name = GameName }); + Achievements = new MvxObservableCollection(listOfAchievements); MainWindowEnabled = true; - if (achievements.Count > 0) + if (Achievements.Count > 0) { - var empty = achievements.Count == 1 ? "" : "s"; - StatusText = $"Successfully got {achievements.Count} achievement{empty}! Ready."; + var empty = Achievements.Count == 1 ? "" : "s"; + StatusText = $"Successfully got {Achievements.Count} achievement{empty}! Ready."; } else { @@ -443,7 +454,7 @@ namespace GoldbergGUI.Core.ViewModels await _goldberg.Save(dirPath, new GoldbergConfiguration { AppId = AppId, - Achievements = achievements.ToList(), + Achievements = Achievements.ToList(), DlcList = DLCs.ToList(), Offline = Offline, DisableNetworking = DisableNetworking, @@ -554,7 +565,7 @@ namespace GoldbergGUI.Core.ViewModels DllPath = "Path to game's steam_api(64).dll..."; GameName = "Game name..."; AppId = -1; - achievements = new List(); + Achievements = new ObservableCollection(); DLCs = new ObservableCollection(); AccountName = "Account name..."; SteamId = -1; @@ -575,7 +586,7 @@ namespace GoldbergGUI.Core.ViewModels private void SetFormFromConfig(GoldbergConfiguration config) { AppId = config.AppId; - achievements = new List(config.Achievements); + Achievements = new ObservableCollection(config.Achievements); DLCs = new ObservableCollection(config.DlcList); Offline = config.Offline; DisableNetworking = config.DisableNetworking; diff --git a/GoldbergGUI.WPF/Views/MainView.xaml b/GoldbergGUI.WPF/Views/MainView.xaml index 13b5ccb..83b115d 100644 --- a/GoldbergGUI.WPF/Views/MainView.xaml +++ b/GoldbergGUI.WPF/Views/MainView.xaml @@ -32,7 +32,7 @@ - + @@ -42,41 +42,71 @@