From 71021ee767d4657cf46677d2417770bd7c9689e8 Mon Sep 17 00:00:00 2001 From: Jeddunk Date: Wed, 22 Dec 2021 13:15:28 +0100 Subject: [PATCH] code cleanup; build x86 per default --- GoldbergGUI.Core/GoldbergGUI.Core.csproj | 1 + GoldbergGUI.Core/Models/GoldbergModel.cs | 46 +++++++-------- GoldbergGUI.Core/Models/SteamAppModel.cs | 2 +- GoldbergGUI.Core/Services/GoldbergService.cs | 14 ++--- GoldbergGUI.Core/Services/SteamService.cs | 20 +++---- GoldbergGUI.Core/Utils/CustomMvxAppStart.cs | 3 +- GoldbergGUI.Core/Utils/Misc.cs | 6 +- GoldbergGUI.Core/ViewModels/MainViewModel.cs | 56 ++++++++++--------- .../ViewModels/SearchResultViewModel.cs | 10 ++-- GoldbergGUI.WPF/App.xaml.cs | 1 - GoldbergGUI.WPF/AssemblyInfo.cs | 8 +-- GoldbergGUI.WPF/GoldbergGUI.WPF.csproj | 1 + GoldbergGUI.WPF/Setup.cs | 9 +-- GoldbergGUI.sln | 24 +++++++- 14 files changed, 110 insertions(+), 91 deletions(-) diff --git a/GoldbergGUI.Core/GoldbergGUI.Core.csproj b/GoldbergGUI.Core/GoldbergGUI.Core.csproj index b807a17..164c22f 100644 --- a/GoldbergGUI.Core/GoldbergGUI.Core.csproj +++ b/GoldbergGUI.Core/GoldbergGUI.Core.csproj @@ -4,6 +4,7 @@ netcoreapp3.1 0.2.0 Jeddunk + AnyCPU;x86;x64 diff --git a/GoldbergGUI.Core/Models/GoldbergModel.cs b/GoldbergGUI.Core/Models/GoldbergModel.cs index b0f01d2..d6a40fe 100644 --- a/GoldbergGUI.Core/Models/GoldbergModel.cs +++ b/GoldbergGUI.Core/Models/GoldbergModel.cs @@ -35,21 +35,21 @@ namespace GoldbergGUI.Core.Models /// List of DLC /// public List DlcList { get; set; } - + public List Depots { get; set; } - + public List SubscribedGroups { get; set; } - + //public List AppPaths { get; set; } - + public List Achievements { get; set; } - + public List Items { get; set; } - + public List Leaderboards { get; set; } - + public List Stats { get; set; } - + // Add controller setting here! /// /// Set offline mode. @@ -63,7 +63,7 @@ namespace GoldbergGUI.Core.Models /// Disable overlay (experimental only). /// public bool DisableOverlay { get; set; } - + public GoldbergGlobalConfiguration OverwrittenGlobalConfiguration { get; set; } } @@ -73,12 +73,12 @@ namespace GoldbergGUI.Core.Models public DlcApp(SteamApp steamApp) { - this.AppId = steamApp.AppId; - this.Name = steamApp.Name; - this.ComparableName = steamApp.ComparableName; - this.AppType = steamApp.AppType; - this.LastModified = steamApp.LastModified; - this.PriceChangeNumber = steamApp.PriceChangeNumber; + AppId = steamApp.AppId; + Name = steamApp.Name; + ComparableName = steamApp.ComparableName; + AppType = steamApp.AppType; + LastModified = steamApp.LastModified; + PriceChangeNumber = steamApp.PriceChangeNumber; } /// @@ -109,40 +109,40 @@ namespace GoldbergGUI.Core.Models /// Achievement description. /// [JsonPropertyName("description")] - public string Description { get; set; } + public string Description { get; set; } /// /// Human readable name, as shown on webpage, game library, overlay, etc. /// [JsonPropertyName("displayName")] - public string DisplayName { get; set; } + public string DisplayName { get; set; } /// /// Is achievement hidden? 0 = false, else true. /// [JsonPropertyName("hidden")] - public int Hidden { get; set; } - + public int Hidden { get; set; } + /// /// Path to icon when unlocked (colored). /// [JsonPropertyName("icon")] - public string Icon { get; set; } + public string Icon { get; set; } /// /// Path to icon when locked (grayed out). /// // ReSharper disable once StringLiteralTypo [JsonPropertyName("icongray")] - public string IconGray { get; set; } + public string IconGray { get; set; } /// /// Internal name. /// [JsonPropertyName("name")] - public string Name { get; set; } + public string Name { get; set; } } - + public class Item { [JsonPropertyName("Timestamp")] diff --git a/GoldbergGUI.Core/Models/SteamAppModel.cs b/GoldbergGUI.Core/Models/SteamAppModel.cs index b3ea457..4329b75 100644 --- a/GoldbergGUI.Core/Models/SteamAppModel.cs +++ b/GoldbergGUI.Core/Models/SteamAppModel.cs @@ -1,6 +1,6 @@ +using SQLite; using System.Collections.Generic; using System.Text.Json.Serialization; -using SQLite; // ReSharper disable UnusedMember.Global // ReSharper disable ClassNeverInstantiated.Global diff --git a/GoldbergGUI.Core/Services/GoldbergService.cs b/GoldbergGUI.Core/Services/GoldbergService.cs index 5af721b..bbe0be1 100644 --- a/GoldbergGUI.Core/Services/GoldbergService.cs +++ b/GoldbergGUI.Core/Services/GoldbergService.cs @@ -1,3 +1,6 @@ +using GoldbergGUI.Core.Models; +using GoldbergGUI.Core.Utils; +using MvvmCross.Logging; using System; using System.Collections.Generic; using System.IO; @@ -7,9 +10,6 @@ using System.Net.Http; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; -using GoldbergGUI.Core.Models; -using GoldbergGUI.Core.Utils; -using MvvmCross.Logging; namespace GoldbergGUI.Core.Services { @@ -249,7 +249,7 @@ namespace GoldbergGUI.Core.Services { var match = appPathExpression.Match(line); if (!match.Success) continue; - var i = dlcList.FindIndex(x => + var i = dlcList.FindIndex(x => x.AppId.Equals(Convert.ToInt32(match.Groups["id"].Value))); dlcList[i].AppPath = match.Groups["appPath"].Value; } @@ -319,14 +319,14 @@ namespace GoldbergGUI.Core.Services }); await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "DLC.txt"), dlcContent) .ConfigureAwait(false); - + /*if (!string.IsNullOrEmpty(depotContent)) { await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "depots.txt"), depotContent) .ConfigureAwait(false); }*/ - - + + if (!string.IsNullOrEmpty(appPathContent)) { await File.WriteAllTextAsync(Path.Combine(path, "steam_settings", "app_paths.txt"), appPathContent) diff --git a/GoldbergGUI.Core/Services/SteamService.cs b/GoldbergGUI.Core/Services/SteamService.cs index a80ef7f..5e79f4d 100644 --- a/GoldbergGUI.Core/Services/SteamService.cs +++ b/GoldbergGUI.Core/Services/SteamService.cs @@ -1,10 +1,3 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Net.Http; -using System.Text.Json; -using System.Text.RegularExpressions; -using System.Threading.Tasks; using AngleSharp.Dom; using AngleSharp.Html.Parser; using GoldbergGUI.Core.Models; @@ -13,6 +6,13 @@ using MvvmCross.Logging; using NinjaNye.SearchExtensions; using SQLite; using SteamStorefrontAPI; +using System; +using System.Collections.Generic; +using System.IO; +using System.Net.Http; +using System.Text.Json; +using System.Text.RegularExpressions; +using System.Threading.Tasks; namespace GoldbergGUI.Core.Services { @@ -91,7 +91,7 @@ namespace GoldbergGUI.Core.Services static SteamApps DeserializeSteamApps(Type type, string cacheString) { return type == typeof(SteamAppsV2) - ? (SteamApps) JsonSerializer.Deserialize(cacheString) + ? (SteamApps)JsonSerializer.Deserialize(cacheString) : JsonSerializer.Deserialize(cacheString); } @@ -196,7 +196,7 @@ namespace GoldbergGUI.Core.Services // Return current list if we don't intend to use SteamDB if (!useSteamDb) return dlcList; - + try { var steamDbUri = new Uri($"https://steamdb.info/app/{steamApp.AppId}/dlc/"); @@ -229,7 +229,7 @@ namespace GoldbergGUI.Core.Services var dlcName = query3 != null ? query3[1].Text().Replace("\n", "").Trim() : $"Unknown DLC {dlcId}"; - var dlcApp = new DlcApp {AppId = Convert.ToInt32(dlcId), Name = dlcName}; + var dlcApp = new DlcApp { AppId = Convert.ToInt32(dlcId), Name = dlcName }; var i = dlcList.FindIndex(x => x.AppId.Equals(dlcApp.AppId)); if (i > -1) { diff --git a/GoldbergGUI.Core/Utils/CustomMvxAppStart.cs b/GoldbergGUI.Core/Utils/CustomMvxAppStart.cs index d5fcc3a..8fa735e 100644 --- a/GoldbergGUI.Core/Utils/CustomMvxAppStart.cs +++ b/GoldbergGUI.Core/Utils/CustomMvxAppStart.cs @@ -1,8 +1,7 @@ -using System; -using System.Threading.Tasks; using MvvmCross.Exceptions; using MvvmCross.Navigation; using MvvmCross.ViewModels; +using System.Threading.Tasks; namespace GoldbergGUI.Core.Utils { diff --git a/GoldbergGUI.Core/Utils/Misc.cs b/GoldbergGUI.Core/Utils/Misc.cs index 6bf7df2..9e315d3 100644 --- a/GoldbergGUI.Core/Utils/Misc.cs +++ b/GoldbergGUI.Core/Utils/Misc.cs @@ -7,15 +7,15 @@ namespace GoldbergGUI.Core.Utils public class GlobalHelp { - public static string Header => + public static string Header => "Information\n"; - public static string TextPreLink => + public static string TextPreLink => "Usually these settings are saved under"; public static string Link => "%APPDATA%\\Goldberg SteamEmu Saves\\settings"; - public static string TextPostLink => + public static string TextPostLink => ", which makes these " + "available for every game that uses the Goldberg Emulator. However, if you want to set specific settings " + "for certain games (e.g. different language), you can remove the \"Global\" checkmark next to the option " + diff --git a/GoldbergGUI.Core/ViewModels/MainViewModel.cs b/GoldbergGUI.Core/ViewModels/MainViewModel.cs index b99a2cc..6f57aae 100644 --- a/GoldbergGUI.Core/ViewModels/MainViewModel.cs +++ b/GoldbergGUI.Core/ViewModels/MainViewModel.cs @@ -1,4 +1,12 @@ -using System; +using GoldbergGUI.Core.Models; +using GoldbergGUI.Core.Services; +using GoldbergGUI.Core.Utils; +using Microsoft.Win32; +using MvvmCross.Commands; +using MvvmCross.Logging; +using MvvmCross.Navigation; +using MvvmCross.ViewModels; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; @@ -9,14 +17,6 @@ using System.Runtime.InteropServices; using System.Text.RegularExpressions; using System.Threading.Tasks; using System.Windows; -using GoldbergGUI.Core.Models; -using GoldbergGUI.Core.Services; -using GoldbergGUI.Core.Utils; -using Microsoft.Win32; -using MvvmCross.Commands; -using MvvmCross.Logging; -using MvvmCross.Navigation; -using MvvmCross.ViewModels; namespace GoldbergGUI.Core.ViewModels { @@ -264,7 +264,7 @@ namespace GoldbergGUI.Core.ViewModels public static string AboutVersionText => FileVersionInfo.GetVersionInfo(Assembly.GetExecutingAssembly().Location).FileVersion; - + public static GlobalHelp G => new GlobalHelp(); // COMMANDS // @@ -380,7 +380,7 @@ namespace GoldbergGUI.Core.ViewModels MainWindowEnabled = false; StatusText = "Trying to get list of DLCs..."; - var listOfDlc = await _steam.GetListOfDlc(new SteamApp {AppId = AppId, Name = GameName}, true) + var listOfDlc = await _steam.GetListOfDlc(new SteamApp { AppId = AppId, Name = GameName }, true) .ConfigureAwait(false); DLCs = new MvxObservableCollection(listOfDlc); MainWindowEnabled = true; @@ -402,8 +402,8 @@ namespace GoldbergGUI.Core.ViewModels _log.Info("Saving global settings..."); var globalConfiguration = new GoldbergGlobalConfiguration { - AccountName = AccountName, - UserSteamId = SteamId, + AccountName = AccountName, + UserSteamId = SteamId, Language = SelectedLanguage }; await _goldberg.SetGlobalSettings(globalConfiguration).ConfigureAwait(false); @@ -414,13 +414,13 @@ namespace GoldbergGUI.Core.ViewModels MainWindowEnabled = false; StatusText = "Saving..."; await _goldberg.Save(dirPath, new GoldbergConfiguration - { - AppId = AppId, - DlcList = DLCs.ToList(), - Offline = Offline, - DisableNetworking = DisableNetworking, - DisableOverlay = DisableOverlay - } + { + AppId = AppId, + DlcList = DLCs.ToList(), + Offline = Offline, + DisableNetworking = DisableNetworking, + DisableOverlay = DisableOverlay + } ).ConfigureAwait(false); GoldbergApplied = _goldberg.GoldbergApplied(dirPath); MainWindowEnabled = true; @@ -478,13 +478,15 @@ namespace GoldbergGUI.Core.ViewModels { var result = Clipboard.GetText(); 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 DlcApp - { - AppId = Convert.ToInt32(match.Groups["id"].Value), - Name = match.Groups["name"].Value - }).ToList(); + var pastedDlc = (from line in result.Split(new[] { "\n", "\r\n" }, + StringSplitOptions.RemoveEmptyEntries) + select expression.Match(line) into match + where match.Success + select new DlcApp + { + AppId = Convert.ToInt32(match.Groups["id"].Value), + Name = match.Groups["name"].Value + }).ToList(); if (pastedDlc.Count > 0) { DLCs.Clear(); diff --git a/GoldbergGUI.Core/ViewModels/SearchResultViewModel.cs b/GoldbergGUI.Core/ViewModels/SearchResultViewModel.cs index dd46194..35f4dc2 100644 --- a/GoldbergGUI.Core/ViewModels/SearchResultViewModel.cs +++ b/GoldbergGUI.Core/ViewModels/SearchResultViewModel.cs @@ -1,10 +1,10 @@ -using System.Collections.Generic; -using System.Threading.Tasks; using GoldbergGUI.Core.Models; using MvvmCross.Commands; using MvvmCross.Logging; using MvvmCross.Navigation; using MvvmCross.ViewModels; +using System.Collections.Generic; +using System.Threading.Tasks; namespace GoldbergGUI.Core.ViewModels { @@ -14,7 +14,7 @@ namespace GoldbergGUI.Core.ViewModels private readonly IMvxLog _log; private IEnumerable _apps; - public SearchResultViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService) : + public SearchResultViewModel(IMvxLogProvider logProvider, IMvxNavigationService navigationService) : base(logProvider, navigationService) { _log = logProvider.GetLogFor(typeof(SearchResultViewModel)); @@ -25,7 +25,7 @@ namespace GoldbergGUI.Core.ViewModels { Apps = parameter; } - + public IEnumerable Apps { get => _apps; @@ -35,7 +35,7 @@ namespace GoldbergGUI.Core.ViewModels RaisePropertyChanged(() => Apps); } } - + public SteamApp Selected { get; diff --git a/GoldbergGUI.WPF/App.xaml.cs b/GoldbergGUI.WPF/App.xaml.cs index 7b2e5c1..5d14782 100644 --- a/GoldbergGUI.WPF/App.xaml.cs +++ b/GoldbergGUI.WPF/App.xaml.cs @@ -1,5 +1,4 @@ using MvvmCross.Core; -using MvvmCross.Platforms.Wpf.Core; using MvvmCross.Platforms.Wpf.Views; namespace GoldbergGUI.WPF diff --git a/GoldbergGUI.WPF/AssemblyInfo.cs b/GoldbergGUI.WPF/AssemblyInfo.cs index 4a05c7d..4f943de 100644 --- a/GoldbergGUI.WPF/AssemblyInfo.cs +++ b/GoldbergGUI.WPF/AssemblyInfo.cs @@ -2,9 +2,9 @@ using System.Windows; [assembly: ThemeInfo( ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located - //(used if a resource is not found in the page, - // or application resource dictionaries) + //(used if a resource is not found in the page, + // or application resource dictionaries) ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located - //(used if a resource is not found in the page, - // app, or any theme specific resource dictionaries) + //(used if a resource is not found in the page, + // app, or any theme specific resource dictionaries) )] \ No newline at end of file diff --git a/GoldbergGUI.WPF/GoldbergGUI.WPF.csproj b/GoldbergGUI.WPF/GoldbergGUI.WPF.csproj index 62b3ad1..d0e7dcb 100644 --- a/GoldbergGUI.WPF/GoldbergGUI.WPF.csproj +++ b/GoldbergGUI.WPF/GoldbergGUI.WPF.csproj @@ -6,6 +6,7 @@ true 0.2.0 Jeddunk + AnyCPU;x86;x64 diff --git a/GoldbergGUI.WPF/Setup.cs b/GoldbergGUI.WPF/Setup.cs index e11f828..c9f6d78 100644 --- a/GoldbergGUI.WPF/Setup.cs +++ b/GoldbergGUI.WPF/Setup.cs @@ -1,20 +1,17 @@ -using System; -using System.IO; -using System.Windows.Controls; -using System.Windows.Threading; using MvvmCross.Logging; using MvvmCross.Platforms.Wpf.Core; using Serilog; +using System.IO; namespace GoldbergGUI.WPF { public class Setup : MvxWpfSetup { public override MvxLogProviderType GetDefaultLogProviderType() => MvxLogProviderType.Serilog; - + protected override IMvxLogProvider CreateLogProvider() { - var logPath = Path.Combine(Directory.GetCurrentDirectory(),"goldberg_.log"); + var logPath = Path.Combine(Directory.GetCurrentDirectory(), "goldberg_.log"); Log.Logger = new LoggerConfiguration() .MinimumLevel.Debug() .WriteTo.Console() diff --git a/GoldbergGUI.sln b/GoldbergGUI.sln index 12167e8..2d2b88a 100644 --- a/GoldbergGUI.sln +++ b/GoldbergGUI.sln @@ -3,24 +3,44 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 16 VisualStudioVersion = 16.0.30717.126 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoldbergGUI.Core", "GoldbergGUI.Core\GoldbergGUI.Core.csproj", "{FB205F05-83DE-4D87-8CE2-F7DA320944FD}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoldbergGUI.Core", "GoldbergGUI.Core\GoldbergGUI.Core.csproj", "{FB205F05-83DE-4D87-8CE2-F7DA320944FD}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GoldbergGUI.WPF", "GoldbergGUI.WPF\GoldbergGUI.WPF.csproj", "{84ED15D3-725C-43B1-B8C7-51759CAABBAA}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GoldbergGUI.WPF", "GoldbergGUI.WPF\GoldbergGUI.WPF.csproj", "{84ED15D3-725C-43B1-B8C7-51759CAABBAA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|x64.ActiveCfg = Debug|x64 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|x64.Build.0 = Debug|x64 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|x86.ActiveCfg = Debug|x86 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Debug|x86.Build.0 = Debug|x86 {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|Any CPU.ActiveCfg = Release|Any CPU {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|Any CPU.Build.0 = Release|Any CPU + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|x64.ActiveCfg = Release|x64 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|x64.Build.0 = Release|x64 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|x86.ActiveCfg = Release|x86 + {FB205F05-83DE-4D87-8CE2-F7DA320944FD}.Release|x86.Build.0 = Release|x86 {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|x64.ActiveCfg = Debug|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|x64.Build.0 = Debug|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|x86.ActiveCfg = Debug|x86 + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Debug|x86.Build.0 = Debug|x86 {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|Any CPU.ActiveCfg = Release|Any CPU {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|Any CPU.Build.0 = Release|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|x64.ActiveCfg = Release|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|x64.Build.0 = Release|Any CPU + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|x86.ActiveCfg = Release|x86 + {84ED15D3-725C-43B1-B8C7-51759CAABBAA}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE