From e17b0a18caebf3f43820ed881125439b514d9901 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Wed, 28 Apr 2021 13:33:04 +0200 Subject: [PATCH] Changed how DLCs are referred as. Optional DLC settings can now be shown (loading and saving is not implemented yet) --- GoldbergGUI.Core/Models/GoldbergModel.cs | 29 +++++--------------- GoldbergGUI.Core/Services/GoldbergService.cs | 4 +-- GoldbergGUI.Core/Services/SteamService.cs | 12 ++++---- GoldbergGUI.Core/ViewModels/MainViewModel.cs | 14 +++++----- GoldbergGUI.WPF/Views/MainView.xaml | 10 +++++-- 5 files changed, 30 insertions(+), 39 deletions(-) diff --git a/GoldbergGUI.Core/Models/GoldbergModel.cs b/GoldbergGUI.Core/Models/GoldbergModel.cs index 58e0f89..40972bc 100644 --- a/GoldbergGUI.Core/Models/GoldbergModel.cs +++ b/GoldbergGUI.Core/Models/GoldbergModel.cs @@ -32,13 +32,13 @@ namespace GoldbergGUI.Core.Models /// /// List of DLC /// - public List DlcList { get; set; } + public List DlcList { get; set; } - public List Depots { get; set; } + //public List Depots { get; set; } public List SubscribedGroups { get; set; } - public List AppPaths { get; set; } + //public List AppPaths { get; set; } public List Achievements { get; set; } @@ -65,20 +65,11 @@ namespace GoldbergGUI.Core.Models public GoldbergGlobalConfiguration OverwrittenGlobalConfiguration { get; set; } } - public class Depot + public class DlcApp : SteamApp { - /// - /// ID of Depot. - /// - public int DepotId { get; set; } - /// - /// Name of Depot. - /// - public string Name { get; set; } - /// - /// Associated DLC App ID, can be null (e.g. if Depot is for base game). - /// - public int DlcAppId { get; set; } + public int? DepotId { get; set; } + public string DepotName { get; set; } + public string AppPath { get; set; } } public class Group @@ -97,12 +88,6 @@ namespace GoldbergGUI.Core.Models public int AppId { get; set; } } - public class AppPath - { - public int AppId { get; set; } - public string Path { get; set; } - } - public class Achievement { /// diff --git a/GoldbergGUI.Core/Services/GoldbergService.cs b/GoldbergGUI.Core/Services/GoldbergService.cs index aae4872..2d84f36 100644 --- a/GoldbergGUI.Core/Services/GoldbergService.cs +++ b/GoldbergGUI.Core/Services/GoldbergService.cs @@ -207,7 +207,7 @@ namespace GoldbergGUI.Core.Services { _log.Info("Reading configuration..."); var appId = -1; - var dlcList = new List(); + var dlcList = new List(); var steamAppidTxt = Path.Combine(path, "steam_appid.txt"); if (File.Exists(steamAppidTxt)) { @@ -235,7 +235,7 @@ namespace GoldbergGUI.Core.Services { AppId = Convert.ToInt32(match.Groups["id"].Value), Name = match.Groups["name"].Value - }); + } as DlcApp); } } else diff --git a/GoldbergGUI.Core/Services/SteamService.cs b/GoldbergGUI.Core/Services/SteamService.cs index b002d71..f3042d7 100644 --- a/GoldbergGUI.Core/Services/SteamService.cs +++ b/GoldbergGUI.Core/Services/SteamService.cs @@ -23,7 +23,7 @@ namespace GoldbergGUI.Core.Services public Task> GetListOfAppsByName(string name); public Task GetAppByName(string name); public Task GetAppById(int appid); - public Task> GetListOfDlc(SteamApp steamApp, bool useSteamDb); + public Task> GetListOfDlc(SteamApp steamApp, bool useSteamDb); } class SteamCache @@ -168,9 +168,9 @@ namespace GoldbergGUI.Core.Services return app; } - public async Task> GetListOfDlc(SteamApp steamApp, bool useSteamDb) + public async Task> GetListOfDlc(SteamApp steamApp, bool useSteamDb) { - var dlcList = new List(); + var dlcList = new List(); if (steamApp != null) { _log.Info($"Get DLC for App {steamApp}"); @@ -183,7 +183,7 @@ namespace GoldbergGUI.Core.Services var result = await _db.Table().Where(z => z.type == AppTypeDlc) .FirstOrDefaultAsync(y => y.AppId.Equals(x)).ConfigureAwait(true) ?? new SteamApp {AppId = x, Name = $"Unknown DLC {x}"}; - dlcList.Add(result); + dlcList.Add(result as DlcApp); _log.Debug($"{result.AppId}={result.Name}"); }); @@ -233,11 +233,11 @@ namespace GoldbergGUI.Core.Services var i = dlcList.FindIndex(x => x.AppId.Equals(dlcApp.AppId)); if (i > -1) { - if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp; + if (dlcList[i].Name.Contains("Unknown DLC")) dlcList[i] = dlcApp as DlcApp; } else { - dlcList.Add(dlcApp); + dlcList.Add(dlcApp as DlcApp); } } diff --git a/GoldbergGUI.Core/ViewModels/MainViewModel.cs b/GoldbergGUI.Core/ViewModels/MainViewModel.cs index 6f71093..b99a2cc 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 ObservableCollection _dlcs; + private ObservableCollection _dlcs; private string _accountName; private long _steamId; private bool _offline; @@ -130,7 +130,7 @@ namespace GoldbergGUI.Core.ViewModels } // ReSharper disable once InconsistentNaming - public ObservableCollection DLCs + public ObservableCollection DLCs { get => _dlcs; set @@ -382,7 +382,7 @@ namespace GoldbergGUI.Core.ViewModels StatusText = "Trying to get list of DLCs..."; var listOfDlc = await _steam.GetListOfDlc(new SteamApp {AppId = AppId, Name = GameName}, true) .ConfigureAwait(false); - DLCs = new MvxObservableCollection(listOfDlc); + DLCs = new MvxObservableCollection(listOfDlc); MainWindowEnabled = true; if (DLCs.Count > 0) { @@ -480,7 +480,7 @@ namespace GoldbergGUI.Core.ViewModels var expression = new Regex(@"(?.*) *= *(?.*)"); var pastedDlc = (from line in result.Split(new[] {"\n", "\r\n"}, StringSplitOptions.RemoveEmptyEntries) select expression.Match(line) into match - where match.Success select new SteamApp + where match.Success select new DlcApp { AppId = Convert.ToInt32(match.Groups["id"].Value), Name = match.Groups["name"].Value @@ -488,7 +488,7 @@ namespace GoldbergGUI.Core.ViewModels if (pastedDlc.Count > 0) { DLCs.Clear(); - DLCs = new ObservableCollection(pastedDlc); + DLCs = new ObservableCollection(pastedDlc); //var empty = DLCs.Count == 1 ? "" : "s"; //StatusText = $"Successfully got {DLCs.Count} DLC{empty} from clipboard! Ready."; var statusTextCount = DLCs.Count == 1 ? "one DLC" : $"{DLCs.Count} DLCs"; @@ -524,7 +524,7 @@ namespace GoldbergGUI.Core.ViewModels DllPath = "Path to game's steam_api(64).dll..."; GameName = "Game name..."; AppId = -1; - DLCs = new ObservableCollection(); + DLCs = new ObservableCollection(); AccountName = "Account name..."; SteamId = -1; Offline = false; @@ -544,7 +544,7 @@ namespace GoldbergGUI.Core.ViewModels private void SetFormFromConfig(GoldbergConfiguration config) { AppId = config.AppId; - DLCs = new ObservableCollection(config.DlcList); + DLCs = new ObservableCollection(config.DlcList); Offline = config.Offline; DisableNetworking = config.DisableNetworking; DisableOverlay = config.DisableOverlay; diff --git a/GoldbergGUI.WPF/Views/MainView.xaml b/GoldbergGUI.WPF/Views/MainView.xaml index b8d16ce..e14ebc1 100644 --- a/GoldbergGUI.WPF/Views/MainView.xaml +++ b/GoldbergGUI.WPF/Views/MainView.xaml @@ -7,6 +7,9 @@ xmlns:viewmodel="clr-namespace:GoldbergGUI.Core.ViewModels;assembly=GoldbergGUI.Core" mc:Ignorable="d" d:DesignHeight="500" d:DesignWidth="400" d:DataContext="{d:DesignInstance Type=viewmodel:MainViewModel }"> + + + @@ -53,10 +56,13 @@ + + + -