From e1b753edd3edb3d412712638e1a9d1991f0b0265 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Wed, 10 Nov 2021 16:04:57 -0700 Subject: [PATCH] Revert "Fix login logout buttons" --- Wabbajack.App/App.axaml | 1 - Wabbajack.App/Assets/Wabbajack.axaml | 6 -- .../Configuration.cs | 2 +- Wabbajack.App/Controls/BrowseItemViewModel.cs | 1 - Wabbajack.App/Controls/ResourceView.axaml | 15 +++-- Wabbajack.App/Controls/ResourceView.axaml.cs | 15 +---- Wabbajack.App/Controls/ResourceViewModel.cs | 24 +++---- Wabbajack.App/Models/ImageCache.cs | 1 - .../Models}/SettingsManager.cs | 8 +-- Wabbajack.App/Screens/BrowseViewModel.cs | 4 +- .../Screens/CompilerConfigurationViewModel.cs | 1 - Wabbajack.App/Screens/LauncherView.axaml | 6 +- Wabbajack.App/Screens/LauncherView.axaml.cs | 19 ------ Wabbajack.App/Screens/SettingsView.axaml | 34 ++++------ Wabbajack.App/Screens/SettingsView.axaml.cs | 23 +------ Wabbajack.App/Screens/SettingsViewModel.cs | 66 +------------------ .../Screens/StandardInstallationViewModel.cs | 11 +--- Wabbajack.App/ServiceExtensions.cs | 11 ++++ Wabbajack.App/Utilities/LoggerProvider.cs | 1 - Wabbajack.App/Utilities/OSUtil.cs | 38 ----------- .../InstallConfigurationViewModel.cs | 4 +- .../ViewModels/NexusLoginViewModel.cs | 2 - .../ViewModels/OAuthLoginViewModel.cs | 5 -- Wabbajack.CLI/Program.cs | 1 + Wabbajack.Compiler.Test/Startup.cs | 1 - Wabbajack.DTOs/ModList/ModList.cs | 16 ----- .../SavedSettings/InstallationSettings.cs | 2 +- .../ServiceExtensions.cs | 2 - .../ServiceExtensions.cs | 3 +- Wabbajack.Paths.IO/KnownFolders.cs | 3 - Wabbajack.RateLimiter/Resource.cs | 29 ++------ .../ResourceSettingsManager.cs | 62 ----------------- .../ServiceExtensions.cs | 39 ++--------- 33 files changed, 76 insertions(+), 380 deletions(-) rename {Wabbajack.Services.OSIntegrated => Wabbajack.App}/Configuration.cs (88%) rename {Wabbajack.Services.OSIntegrated => Wabbajack.App/Models}/SettingsManager.cs (87%) delete mode 100644 Wabbajack.App/Utilities/OSUtil.cs delete mode 100644 Wabbajack.Services.OSIntegrated/ResourceSettingsManager.cs diff --git a/Wabbajack.App/App.axaml b/Wabbajack.App/App.axaml index 2f026076..842e97aa 100644 --- a/Wabbajack.App/App.axaml +++ b/Wabbajack.App/App.axaml @@ -9,7 +9,6 @@ - - - diff --git a/Wabbajack.Services.OSIntegrated/Configuration.cs b/Wabbajack.App/Configuration.cs similarity index 88% rename from Wabbajack.Services.OSIntegrated/Configuration.cs rename to Wabbajack.App/Configuration.cs index 7adf650b..5559d8cd 100644 --- a/Wabbajack.Services.OSIntegrated/Configuration.cs +++ b/Wabbajack.App/Configuration.cs @@ -1,6 +1,6 @@ using Wabbajack.Paths; -namespace Wabbajack.Services.OSIntegrated; +namespace Wabbajack.App; public class Configuration { diff --git a/Wabbajack.App/Controls/BrowseItemViewModel.cs b/Wabbajack.App/Controls/BrowseItemViewModel.cs index dfa9d9b4..5e0b7d05 100644 --- a/Wabbajack.App/Controls/BrowseItemViewModel.cs +++ b/Wabbajack.App/Controls/BrowseItemViewModel.cs @@ -21,7 +21,6 @@ using Wabbajack.DTOs.JsonConverters; using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.RateLimiter; -using Wabbajack.Services.OSIntegrated; using Wabbajack.VFS; namespace Wabbajack.App.Controls; diff --git a/Wabbajack.App/Controls/ResourceView.axaml b/Wabbajack.App/Controls/ResourceView.axaml index 9cbd59da..3097a736 100644 --- a/Wabbajack.App/Controls/ResourceView.axaml +++ b/Wabbajack.App/Controls/ResourceView.axaml @@ -4,10 +4,13 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" x:Class="Wabbajack.App.Controls.ResourceView"> - - - - - - + + + + + + + + + \ No newline at end of file diff --git a/Wabbajack.App/Controls/ResourceView.axaml.cs b/Wabbajack.App/Controls/ResourceView.axaml.cs index ad795dbd..bcf518de 100644 --- a/Wabbajack.App/Controls/ResourceView.axaml.cs +++ b/Wabbajack.App/Controls/ResourceView.axaml.cs @@ -17,21 +17,10 @@ public partial class ResourceView : ReactiveUserControl, IAct this.Bind(ViewModel, vm => vm.MaxTasks, view => view.MaxTasks.Text) .DisposeWith(disposables); - - this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text, - l => l is 0 or long.MaxValue ? "∞" : (l / 1024 / 1024).ToString(), - v => - { - v = v.Trim(); - if (v is "0" or "∞" || v == long.MaxValue.ToString()) - { - return long.MaxValue; - } - return long.TryParse(v, out var l) ? l * 1024 * 1024 : long.MaxValue; - }) + this.Bind(ViewModel, vm => vm.MaxThroughput, view => view.MaxThroughput.Text) .DisposeWith(disposables); - this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThroughput.Text, + this.OneWayBind(ViewModel, vm => vm.CurrentThroughput, view => view.CurrentThrougput.Text, val => val.FileSizeToString()) .DisposeWith(disposables); }); diff --git a/Wabbajack.App/Controls/ResourceViewModel.cs b/Wabbajack.App/Controls/ResourceViewModel.cs index 067bbe97..d3b51c1d 100644 --- a/Wabbajack.App/Controls/ResourceViewModel.cs +++ b/Wabbajack.App/Controls/ResourceViewModel.cs @@ -2,11 +2,9 @@ using System; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Timers; -using Avalonia.Threading; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Wabbajack.App.ViewModels; -using Wabbajack.Common; using Wabbajack.RateLimiter; namespace Wabbajack.App.Controls; @@ -20,7 +18,7 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab { Activator = new ViewModelActivator(); _resource = resource; - _timer = new Timer(250); + _timer = new Timer(1.0); Name = resource.Name; @@ -34,9 +32,14 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab _timer.Stop(); _timer.Elapsed -= TimerElapsed; }).DisposeWith(disposables); - - MaxTasks = _resource.MaxTasks; - MaxThroughput = _resource.MaxThroughput; + + this.WhenAnyValue(vm => vm.MaxThroughput) + .Skip(1) + .Subscribe(v => { _resource.MaxThroughput = MaxThroughput; }).DisposeWith(disposables); + + this.WhenAnyValue(vm => vm.MaxTasks) + .Skip(1) + .Subscribe(v => { _resource.MaxTasks = MaxTasks; }).DisposeWith(disposables); }); } @@ -47,8 +50,6 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab [Reactive] public long CurrentThroughput { get; set; } [Reactive] public string Name { get; set; } - - [Reactive] public string ThroughputHumanFriendly { get; set; } public void Dispose() @@ -58,9 +59,8 @@ public class ResourceViewModel : ViewModelBase, IActivatableViewModel, IDisposab private void TimerElapsed(object? sender, ElapsedEventArgs e) { - Dispatcher.UIThread.Post(() => { - CurrentThroughput = _resource.StatusReport.Transferred; - ThroughputHumanFriendly = _resource.StatusReport.Transferred.ToFileSizeString(); - }); + MaxTasks = _resource.MaxTasks; + MaxThroughput = _resource.MaxThroughput; + CurrentThroughput = _resource.StatusReport.Transferred; } } \ No newline at end of file diff --git a/Wabbajack.App/Models/ImageCache.cs b/Wabbajack.App/Models/ImageCache.cs index 51408fce..202331a8 100644 --- a/Wabbajack.App/Models/ImageCache.cs +++ b/Wabbajack.App/Models/ImageCache.cs @@ -12,7 +12,6 @@ using Wabbajack.Hashing.xxHash64; using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.RateLimiter; -using Wabbajack.Services.OSIntegrated; using Wabbajack.VFS; namespace Wabbajack.App.Models; diff --git a/Wabbajack.Services.OSIntegrated/SettingsManager.cs b/Wabbajack.App/Models/SettingsManager.cs similarity index 87% rename from Wabbajack.Services.OSIntegrated/SettingsManager.cs rename to Wabbajack.App/Models/SettingsManager.cs index ca04ff76..7ca49047 100644 --- a/Wabbajack.Services.OSIntegrated/SettingsManager.cs +++ b/Wabbajack.App/Models/SettingsManager.cs @@ -9,7 +9,7 @@ using Wabbajack.DTOs.JsonConverters; using Wabbajack.Paths; using Wabbajack.Paths.IO; -namespace Wabbajack.Services.OSIntegrated; +namespace Wabbajack.App.Models; public class SettingsManager { @@ -35,11 +35,7 @@ public class SettingsManager var tmp = GetPath(key).WithExtension(Ext.Temp); await using (var s = tmp.Open(FileMode.Create, FileAccess.Write)) { - var opts = new JsonSerializerOptions(_dtos.Options) - { - WriteIndented = true - }; - await JsonSerializer.SerializeAsync(s, value, opts); + await JsonSerializer.SerializeAsync(s, value, _dtos.Options); } await tmp.MoveToAsync(GetPath(key), true, CancellationToken.None); diff --git a/Wabbajack.App/Screens/BrowseViewModel.cs b/Wabbajack.App/Screens/BrowseViewModel.cs index 0c5e0027..04c51879 100644 --- a/Wabbajack.App/Screens/BrowseViewModel.cs +++ b/Wabbajack.App/Screens/BrowseViewModel.cs @@ -31,7 +31,7 @@ namespace Wabbajack.App.Screens; public class BrowseViewModel : ViewModelBase, IActivatableViewModel { - private readonly Wabbajack.Services.OSIntegrated.Configuration _configuration; + private readonly Configuration _configuration; private readonly DownloadDispatcher _dispatcher; private readonly IResource _dispatcherLimiter; private readonly DTOSerializer _dtos; @@ -54,7 +54,7 @@ public class BrowseViewModel : ViewModelBase, IActivatableViewModel IResource limiter, FileHashCache hashCache, IResource dispatcherLimiter, DownloadDispatcher dispatcher, GameLocator gameLocator, ImageCache imageCache, - DTOSerializer dtos, Wabbajack.Services.OSIntegrated.Configuration configuration) + DTOSerializer dtos, Configuration configuration) { LoadingLock = new LoadingLock(); Activator = new ViewModelActivator(); diff --git a/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs b/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs index b7d648ba..e4ffb383 100644 --- a/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs +++ b/Wabbajack.App/Screens/CompilerConfigurationViewModel.cs @@ -18,7 +18,6 @@ using Wabbajack.DTOs.JsonConverters; using Wabbajack.Installer; using Wabbajack.Paths; using Wabbajack.Paths.IO; -using Wabbajack.Services.OSIntegrated; using Consts = Wabbajack.Compiler.Consts; namespace Wabbajack.App.Screens; diff --git a/Wabbajack.App/Screens/LauncherView.axaml b/Wabbajack.App/Screens/LauncherView.axaml index 1aadfd0e..b1dd6f62 100644 --- a/Wabbajack.App/Screens/LauncherView.axaml +++ b/Wabbajack.App/Screens/LauncherView.axaml @@ -24,9 +24,9 @@ - - - + + + .DisposeWith(disposables); }); } - - private void ShowWebsite(object? sender, RoutedEventArgs e) - { - OSUtil.OpenWebsite(ViewModel!.Setting!.StrippedModListData?.Website!); - } - - private void ShowReadme(object? sender, RoutedEventArgs e) - { - OSUtil.OpenWebsite(new Uri(ViewModel!.Setting!.StrippedModListData?.Readme!)); - } - - private void ShowLocalFiles(object? sender, RoutedEventArgs e) - { - OSUtil.OpenFolder(ViewModel!.Setting!.Install); - } } \ No newline at end of file diff --git a/Wabbajack.App/Screens/SettingsView.axaml b/Wabbajack.App/Screens/SettingsView.axaml index 41273e7b..fb56369c 100644 --- a/Wabbajack.App/Screens/SettingsView.axaml +++ b/Wabbajack.App/Screens/SettingsView.axaml @@ -34,28 +34,22 @@ - - - - - - - - - - - - - + + + Resource Limits + + + + + + + + - + - - - - + + diff --git a/Wabbajack.App/Screens/SettingsView.axaml.cs b/Wabbajack.App/Screens/SettingsView.axaml.cs index 0fe9ad1f..fb7fc1cb 100644 --- a/Wabbajack.App/Screens/SettingsView.axaml.cs +++ b/Wabbajack.App/Screens/SettingsView.axaml.cs @@ -1,8 +1,6 @@ using System.Reactive.Disposables; -using Avalonia.Interactivity; using ReactiveUI; using Wabbajack.App.Views; -using Wabbajack.Common; namespace Wabbajack.App.Screens; @@ -17,27 +15,8 @@ public partial class SettingsView : ScreenBase .DisposeWith(disposables); this.BindCommand(ViewModel, vm => vm.NexusLogout, view => view.NexusLogOut) .DisposeWith(disposables); - - this.BindCommand(ViewModel, vm => vm.LoversLabLogin, view => view.LoversLabLogIn) + this.OneWayBind(ViewModel, vm => vm.Resources, view => view.ResourceList.Items) .DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.LoversLabLogout, view => view.LoversLabLogOut) - .DisposeWith(disposables); - - - this.BindCommand(ViewModel, vm => vm.VectorPlexusLogin, view => view.VectorPlexusLogIn) - .DisposeWith(disposables); - this.BindCommand(ViewModel, vm => vm.VectorPlexusLogout, view => view.VectorPlexusLogOut) - .DisposeWith(disposables); - - - this.OneWayBind(ViewModel, vm => vm.Resources, view => view.ResourcesList.Items) - .DisposeWith(disposables); - }); } - - private void SaveSettingsAndRestart(object? sender, RoutedEventArgs e) - { - ViewModel!.SaveResourceSettingsAndRestart().FireAndForget(); - } } \ No newline at end of file diff --git a/Wabbajack.App/Screens/SettingsViewModel.cs b/Wabbajack.App/Screens/SettingsViewModel.cs index 2187979b..e2cbbe40 100644 --- a/Wabbajack.App/Screens/SettingsViewModel.cs +++ b/Wabbajack.App/Screens/SettingsViewModel.cs @@ -1,25 +1,18 @@ -using System; using System.Collections.Generic; -using System.Diagnostics; using System.IO; using System.Linq; using System.Reactive; using System.Reactive.Disposables; using System.Reactive.Linq; using System.Reactive.Subjects; -using System.Reflection; -using System.Threading.Tasks; using Microsoft.Extensions.Logging; using ReactiveUI; using Wabbajack.App.Controls; using Wabbajack.App.Messages; -using Wabbajack.App.Models; using Wabbajack.App.ViewModels; -using Wabbajack.Common; using Wabbajack.Paths; using Wabbajack.Paths.IO; using Wabbajack.RateLimiter; -using Wabbajack.Services.OSIntegrated; using Wabbajack.Services.OSIntegrated.TokenProviders; namespace Wabbajack.App.Screens; @@ -29,26 +22,16 @@ public class SettingsViewModel : ViewModelBase private readonly Subject _fileSystemEvents = new(); private readonly ILogger _logger; public readonly IEnumerable Resources; - private readonly ResourceSettingsManager _resourceSettingsManager; public SettingsViewModel(ILogger logger, Configuration configuration, - ResourceSettingsManager resourceSettingsManager, - NexusApiTokenProvider nexusProvider, IEnumerable resources, LoversLabTokenProvider llProvider, VectorPlexusTokenProvider vpProvider) + NexusApiTokenProvider nexusProvider, IEnumerable resources) { - _resourceSettingsManager = resourceSettingsManager; _logger = logger; - Resources = resources.Select(r => new ResourceViewModel(r)) - .OrderBy(o => o.Name) - .ToArray(); + Resources = resources.Select(r => new ResourceViewModel(r)).ToArray(); Activator = new ViewModelActivator(); this.WhenActivated(disposables => { - foreach (var resource in Resources) - { - resource.Activator.Activate().DisposeWith(disposables); - } - configuration.EncryptedDataLocation.CreateDirectory(); Watcher = new FileSystemWatcher(configuration.EncryptedDataLocation.ToString()); Watcher.DisposeWith(disposables); @@ -67,61 +50,16 @@ public class SettingsViewModel : ViewModelBase ReactiveCommand.Create(() => { MessageBus.Current.SendMessage(new NavigateTo(typeof(NexusLoginViewModel))); }, haveNexusToken.Select(x => !x)); NexusLogout = ReactiveCommand.Create(nexusProvider.DeleteToken, haveNexusToken.Select(x => x)); - - var haveLLToken = _fileSystemEvents - .StartWith(AbsolutePath.Empty) - .Select(_ => llProvider.HaveToken()); - - LoversLabLogin = - ReactiveCommand.Create(() => { MessageBus.Current.SendMessage(new NavigateTo(typeof(LoversLabOAuthLoginViewModel))); }, - haveLLToken.Select(x => !x)); - LoversLabLogout = ReactiveCommand.Create(llProvider.DeleteToken, haveLLToken.Select(x => x)); - - var haveVectorPlexusToken = _fileSystemEvents - .StartWith(AbsolutePath.Empty) - .Select(_ => vpProvider.HaveToken()); - - VectorPlexusLogin = - ReactiveCommand.Create(() => { MessageBus.Current.SendMessage(new NavigateTo(typeof(VectorPlexusOAuthLoginViewModel))); }, - haveVectorPlexusToken.Select(x => !x)); - VectorPlexusLogout = ReactiveCommand.Create(vpProvider.DeleteToken, haveVectorPlexusToken.Select(x => x)); }); } public ReactiveCommand NexusLogin { get; set; } public ReactiveCommand NexusLogout { get; set; } - - public ReactiveCommand LoversLabLogin { get; set; } - public ReactiveCommand LoversLabLogout { get; set; } - - public ReactiveCommand VectorPlexusLogin { get; set; } - public ReactiveCommand VectorPlexusLogout { get; set; } - public FileSystemWatcher Watcher { get; set; } private void Pulse(object sender, FileSystemEventArgs e) { _fileSystemEvents.OnNext(e.FullPath?.ToAbsolutePath() ?? default); } - - public async Task SaveResourceSettingsAndRestart() - { - await _resourceSettingsManager.SaveSettings(Resources.ToDictionary(r => r.Name, r => - new ResourceSettingsManager.ResourceSetting() - { - MaxTasks = r.MaxTasks, - MaxThroughput = r.MaxThroughput - })); - - var proc = new Process() - { - StartInfo = new ProcessStartInfo() - { - FileName = Process.GetCurrentProcess().MainModule!.FileName - } - }; - proc.Start(); - Environment.Exit(0); - } } \ No newline at end of file diff --git a/Wabbajack.App/Screens/StandardInstallationViewModel.cs b/Wabbajack.App/Screens/StandardInstallationViewModel.cs index 36169ac8..72da3c17 100644 --- a/Wabbajack.App/Screens/StandardInstallationViewModel.cs +++ b/Wabbajack.App/Screens/StandardInstallationViewModel.cs @@ -198,15 +198,8 @@ public class StandardInstallationViewModel : ViewModelBase _logger.LogInformation("Installer created, starting the installation process"); try { - - if (!string.IsNullOrWhiteSpace(_config.ModList.Readme)) - OSUtil.OpenWebsite(new Uri(_config.ModList.Readme)); - var result = await Task.Run(async () => await _installer.Begin(CancellationToken.None)); if (!result) throw new Exception("Installation failed"); - - if (!string.IsNullOrWhiteSpace(_config.ModList.Readme)) - OSUtil.OpenWebsite(new Uri(_config.ModList.Readme)); if (result) await SaveConfigAndContinue(_config); } @@ -226,15 +219,13 @@ public class StandardInstallationViewModel : ViewModelBase await image.CopyToAsync(os); } - await _installStateManager.SetLastState(new InstallationConfigurationSetting { Downloads = config.Downloads, Install = config.Install, Metadata = config.Metadata, ModList = config.ModlistArchive, - Image = path, - StrippedModListData = config.ModList.Strip() + Image = path }); MessageBus.Current.SendMessage(new ConfigureLauncher(config.Install)); diff --git a/Wabbajack.App/ServiceExtensions.cs b/Wabbajack.App/ServiceExtensions.cs index 6529c5d1..c50ab48c 100644 --- a/Wabbajack.App/ServiceExtensions.cs +++ b/Wabbajack.App/ServiceExtensions.cs @@ -93,6 +93,17 @@ public static class ServiceExtensions CachePath = KnownFolders.WabbajackAppLocal.Combine("cef_cache").ToString() }); + services.AddSingleton(s => new Configuration + { + EncryptedDataLocation = KnownFolders.WabbajackAppLocal.Combine("encrypted"), + ModListsDownloadLocation = KnownFolders.EntryPoint.Combine("downloaded_mod_lists"), + SavedSettingsLocation = KnownFolders.WabbajackAppLocal.Combine("saved_settings"), + LogLocation = KnownFolders.EntryPoint.Combine("logs"), + ImageCacheLocation = KnownFolders.WabbajackAppLocal.Combine("image_cache") + }); + + services.AddSingleton(); + services.AddSingleton(s => { App.FrameworkInitialized += App_FrameworkInitialized; diff --git a/Wabbajack.App/Utilities/LoggerProvider.cs b/Wabbajack.App/Utilities/LoggerProvider.cs index 3ba19bfd..4d3e7ad5 100644 --- a/Wabbajack.App/Utilities/LoggerProvider.cs +++ b/Wabbajack.App/Utilities/LoggerProvider.cs @@ -10,7 +10,6 @@ using DynamicData; using Microsoft.Extensions.Logging; using Wabbajack.Paths; using Wabbajack.Paths.IO; -using Wabbajack.Services.OSIntegrated; namespace Wabbajack.App.Utilities; diff --git a/Wabbajack.App/Utilities/OSUtil.cs b/Wabbajack.App/Utilities/OSUtil.cs deleted file mode 100644 index 7c0777c4..00000000 --- a/Wabbajack.App/Utilities/OSUtil.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Runtime.InteropServices; -using Microsoft.CodeAnalysis; -using Wabbajack.Common; -using Wabbajack.Paths; -using Wabbajack.Paths.IO; - -namespace Wabbajack.App.Utilities; - -public static class OSUtil -{ - public static void OpenWebsite(Uri uri) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - var helper = new ProcessHelper() - { - Path = "cmd.exe".ToRelativePath().RelativeTo(KnownFolders.WindowsSystem32), - Arguments = new[] {"/C", $"rundll32 url.dll,FileProtocolHandler {uri}"} - }; - helper.Start().FireAndForget(); - } - - } - - public static void OpenFolder(AbsolutePath path) - { - if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows)) - { - var helper = new ProcessHelper() - { - Path = "explorer.exe".ToRelativePath().RelativeTo(KnownFolders.Windows), - Arguments = new object[] {path} - }; - helper.Start().FireAndForget(); - } - } -} \ No newline at end of file diff --git a/Wabbajack.App/ViewModels/InstallConfigurationViewModel.cs b/Wabbajack.App/ViewModels/InstallConfigurationViewModel.cs index 9b753e0a..589ff0ab 100644 --- a/Wabbajack.App/ViewModels/InstallConfigurationViewModel.cs +++ b/Wabbajack.App/ViewModels/InstallConfigurationViewModel.cs @@ -20,7 +20,6 @@ using Wabbajack.DTOs.SavedSettings; using Wabbajack.Installer; using Wabbajack.Paths; using Wabbajack.Paths.IO; -using Wabbajack.Services.OSIntegrated; namespace Wabbajack.App.ViewModels; @@ -125,8 +124,7 @@ public class InstallConfigurationViewModel : ViewModelBase, IActivatableViewMode ModList = ModListPath, Downloads = Download, Install = Install, - Metadata = metadata, - StrippedModListData = ModList?.Strip() + Metadata = metadata }); await _settingsManager.Save("last-install-path", ModListPath); diff --git a/Wabbajack.App/ViewModels/NexusLoginViewModel.cs b/Wabbajack.App/ViewModels/NexusLoginViewModel.cs index a6cc7ee2..f5ec6ad4 100644 --- a/Wabbajack.App/ViewModels/NexusLoginViewModel.cs +++ b/Wabbajack.App/ViewModels/NexusLoginViewModel.cs @@ -97,7 +97,5 @@ public class NexusLoginViewModel : GuidedWebViewModel Cookies = cookies, ApiKey = key }); - - MessageBus.Current.SendMessage(new NavigateBack()); } } \ No newline at end of file diff --git a/Wabbajack.App/ViewModels/OAuthLoginViewModel.cs b/Wabbajack.App/ViewModels/OAuthLoginViewModel.cs index 91ec3b3e..f3b9d519 100644 --- a/Wabbajack.App/ViewModels/OAuthLoginViewModel.cs +++ b/Wabbajack.App/ViewModels/OAuthLoginViewModel.cs @@ -9,11 +9,8 @@ using System.Web; using CefNet; using Microsoft.Extensions.Logging; using Wabbajack.App.Extensions; -using Wabbajack.App.Messages; using Wabbajack.DTOs.Logins; using Wabbajack.Services.OSIntegrated; -using Xunit.Sdk; -using MessageBus = ReactiveUI.MessageBus; namespace Wabbajack.App.ViewModels; @@ -90,8 +87,6 @@ public abstract class OAuthLoginViewModel : GuidedWebViewModel Cookies = cookies, ResultState = data! }); - - MessageBus.Current.SendMessage(new NavigateBack()); } private class AsyncSchemeHandler : CefSchemeHandlerFactory diff --git a/Wabbajack.CLI/Program.cs b/Wabbajack.CLI/Program.cs index 9ef7249e..436779c2 100644 --- a/Wabbajack.CLI/Program.cs +++ b/Wabbajack.CLI/Program.cs @@ -46,6 +46,7 @@ internal class Program services.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount}); services.AddSingleton(); services.AddSingleton(); + services.AddSingleton(); services.AddSingleton(s => new GitHubClient(new ProductHeaderValue("wabbajack"))); services.AddOSIntegrated(); diff --git a/Wabbajack.Compiler.Test/Startup.cs b/Wabbajack.Compiler.Test/Startup.cs index e7f75d37..0ccbf57e 100644 --- a/Wabbajack.Compiler.Test/Startup.cs +++ b/Wabbajack.Compiler.Test/Startup.cs @@ -4,7 +4,6 @@ using Wabbajack.Networking.WabbajackClientApi; using Wabbajack.Services.OSIntegrated; using Xunit.DependencyInjection; using Xunit.DependencyInjection.Logging; -using Configuration = Wabbajack.Services.OSIntegrated.Configuration; namespace Wabbajack.Compiler.Test; diff --git a/Wabbajack.DTOs/ModList/ModList.cs b/Wabbajack.DTOs/ModList/ModList.cs index 3f95355d..e8409cb1 100644 --- a/Wabbajack.DTOs/ModList/ModList.cs +++ b/Wabbajack.DTOs/ModList/ModList.cs @@ -66,20 +66,4 @@ public class ModList /// Whether the Modlist is NSFW or not /// public bool IsNSFW { get; set; } - - public ModList Strip() - { - return new ModList - { - Author = Author, - Description = Description, - GameType = GameType, - Name = Name, - Readme = Readme, - WabbajackVersion = WabbajackVersion, - Website = Website, - Version = Version, - IsNSFW = IsNSFW, - }; - } } \ No newline at end of file diff --git a/Wabbajack.DTOs/SavedSettings/InstallationSettings.cs b/Wabbajack.DTOs/SavedSettings/InstallationSettings.cs index eaeee715..5c5f50de 100644 --- a/Wabbajack.DTOs/SavedSettings/InstallationSettings.cs +++ b/Wabbajack.DTOs/SavedSettings/InstallationSettings.cs @@ -20,5 +20,5 @@ public class InstallationConfigurationSetting public ModlistMetadata? Metadata { get; set; } public AbsolutePath Image { get; set; } - public ModList? StrippedModListData { get; set; } + } \ No newline at end of file diff --git a/Wabbajack.Downloaders.Dispatcher/ServiceExtensions.cs b/Wabbajack.Downloaders.Dispatcher/ServiceExtensions.cs index a7329e4f..bedeb8ef 100644 --- a/Wabbajack.Downloaders.Dispatcher/ServiceExtensions.cs +++ b/Wabbajack.Downloaders.Dispatcher/ServiceExtensions.cs @@ -4,7 +4,6 @@ using Wabbajack.Downloaders.IPS4OAuth2Downloader; using Wabbajack.Downloaders.MediaFire; using Wabbajack.Downloaders.ModDB; using Wabbajack.DTOs.JsonConverters; -using Wabbajack.Networking.WabbajackClientApi; namespace Wabbajack.Downloaders; @@ -24,7 +23,6 @@ public static class ServiceExtensions .AddIPS4OAuth2Downloaders() .AddWabbajackCDNDownloader() .AddGameFileDownloader() - .AddWabbajackClient() .AddSingleton(); } } \ No newline at end of file diff --git a/Wabbajack.Networking.WabbajackClientApi/ServiceExtensions.cs b/Wabbajack.Networking.WabbajackClientApi/ServiceExtensions.cs index 50c375ee..4a8d4713 100644 --- a/Wabbajack.Networking.WabbajackClientApi/ServiceExtensions.cs +++ b/Wabbajack.Networking.WabbajackClientApi/ServiceExtensions.cs @@ -4,10 +4,9 @@ namespace Wabbajack.Networking.WabbajackClientApi; public static class ServiceExtensions { - public static IServiceCollection AddWabbajackClient(this IServiceCollection services) + public static void AddWabbajackClient(this IServiceCollection services) { services.AddSingleton(); services.AddSingleton(); - return services; } } \ No newline at end of file diff --git a/Wabbajack.Paths.IO/KnownFolders.cs b/Wabbajack.Paths.IO/KnownFolders.cs index dfe1ad84..f91c71a8 100644 --- a/Wabbajack.Paths.IO/KnownFolders.cs +++ b/Wabbajack.Paths.IO/KnownFolders.cs @@ -11,9 +11,6 @@ public static class KnownFolders public static AbsolutePath AppDataLocal => Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToAbsolutePath(); - public static AbsolutePath WindowsSystem32 => Environment.GetFolderPath(Environment.SpecialFolder.System).ToAbsolutePath(); - public static AbsolutePath WabbajackAppLocal => AppDataLocal.Combine("Wabbajack"); public static AbsolutePath CurrentDirectory => Directory.GetCurrentDirectory().ToAbsolutePath(); - public static AbsolutePath Windows => Environment.GetFolderPath(Environment.SpecialFolder.Windows).ToAbsolutePath(); } \ No newline at end of file diff --git a/Wabbajack.RateLimiter/Resource.cs b/Wabbajack.RateLimiter/Resource.cs index f22efa4d..bd312777 100644 --- a/Wabbajack.RateLimiter/Resource.cs +++ b/Wabbajack.RateLimiter/Resource.cs @@ -2,7 +2,6 @@ using System; using System.Collections.Concurrent; using System.Diagnostics; using System.Linq; -using System.Runtime.Versioning; using System.Threading; using System.Threading.Channels; using System.Threading.Tasks; @@ -11,9 +10,9 @@ namespace Wabbajack.RateLimiter; public class Resource : IResource { - private Channel _channel; - private SemaphoreSlim _semaphore; - private ConcurrentDictionary> _tasks; + private readonly Channel _channel; + private readonly SemaphoreSlim _semaphore; + private readonly ConcurrentDictionary> _tasks; private ulong _nextId; private long _totalUsed; @@ -23,28 +22,12 @@ public class Resource : IResource Name = humanName ?? ""; MaxTasks = maxTasks ?? Environment.ProcessorCount; MaxThroughput = maxThroughput; + _semaphore = new SemaphoreSlim(MaxTasks); _channel = Channel.CreateBounded(10); _tasks = new ConcurrentDictionary>(); - - var tsk = StartTask(CancellationToken.None); - } - public Resource(string humanName, Func> settingGetter) - { - Name = humanName; - _tasks = new ConcurrentDictionary>(); - - Task.Run(async () => - { - var (maxTasks, maxThroughput) = await settingGetter(); - MaxTasks = maxTasks; - MaxThroughput = maxThroughput; - _semaphore = new SemaphoreSlim(MaxTasks); - _channel = Channel.CreateBounded(10); - - await StartTask(CancellationToken.None); - }); + var tsk = StartTask(CancellationToken.None); } public int MaxTasks { get; set; } @@ -104,7 +87,7 @@ public class Resource : IResource await foreach (var item in _channel.Reader.ReadAllAsync(token)) { Interlocked.Add(ref _totalUsed, item.Size); - if (MaxThroughput is long.MaxValue or 0) + if (MaxThroughput == long.MaxValue) { item.Result.TrySetResult(); sw.Restart(); diff --git a/Wabbajack.Services.OSIntegrated/ResourceSettingsManager.cs b/Wabbajack.Services.OSIntegrated/ResourceSettingsManager.cs deleted file mode 100644 index 72050732..00000000 --- a/Wabbajack.Services.OSIntegrated/ResourceSettingsManager.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using Wabbajack.RateLimiter; -using Wabbajack.Services.OSIntegrated; - -namespace Wabbajack.App.Models; - -public class ResourceSettingsManager -{ - private readonly SettingsManager _manager; - private Dictionary? _settings; - - public ResourceSettingsManager(SettingsManager manager) - { - _manager = manager; - } - - private SemaphoreSlim _lock = new(1); - - public async Task GetSettings(string name) - { - - await _lock.WaitAsync(); - try - { - _settings ??= await _manager.Load>("resource_settings"); - - if (_settings.TryGetValue(name, out var found)) return found; - - var newSetting = new ResourceSetting - { - MaxTasks = Environment.ProcessorCount, - MaxThroughput = 0 - }; - - _settings.Add(name, newSetting); - - await _manager.Save("resource_settings", _settings); - - return _settings[name]; - } - finally - { - _lock.Release(); - } - - } - - public class ResourceSetting - { - public long MaxTasks { get; set; } - public long MaxThroughput { get; set; } - } - - public async Task SaveSettings(Dictionary settings) - { - await _manager.Save("resource_settings", settings); - } -} \ No newline at end of file diff --git a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs index a1c9526f..4736f43f 100644 --- a/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs +++ b/Wabbajack.Services.OSIntegrated/ServiceExtensions.cs @@ -4,7 +4,6 @@ using System.Net.Http; using System.Runtime.InteropServices; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; -using Wabbajack.App.Models; using Wabbajack.Compiler; using Wabbajack.Downloaders; using Wabbajack.Downloaders.GameFile; @@ -55,28 +54,17 @@ public static class ServiceExtensions : new BinaryPatchCache(KnownFolders.EntryPoint.Combine("patchCache.sqlite"))); service.AddSingleton(new ParallelOptions {MaxDegreeOfParallelism = Environment.ProcessorCount}); - - Func> GetSettings(IServiceProvider provider, string name) - { - return async () => - { - var s = await provider.GetService()!.GetSettings(name); - return ((int) s.MaxTasks, s.MaxThroughput); - }; - } - service.AddAllSingleton>(s => - new Resource("Downloads", GetSettings(s, "Downloads"))); - - service.AddAllSingleton>(s => new Resource("Web Requests", GetSettings(s, "Web Requests"))); - service.AddAllSingleton>(s => new Resource("VFS", GetSettings(s, "VFS"))); + new Resource("Downloads", 12)); + service.AddAllSingleton>(s => new Resource("Web Requests", 12)); + service.AddAllSingleton>(s => new Resource("VFS", 12)); service.AddAllSingleton>(s => - new Resource("File Hashing", GetSettings(s, "File Hashing"))); + new Resource("File Hashing", 12)); service.AddAllSingleton>(s => - new Resource("File Extractor", GetSettings(s, "File Extractor"))); + new Resource("File Extractor", 12)); service.AddAllSingleton>(s => - new Resource("Compiler", GetSettings(s, "Compiler"))); + new Resource("Compiler", 12)); service.AddSingleton(); @@ -134,21 +122,6 @@ public static class ServiceExtensions OSVersion = Environment.OSVersion.VersionString, Version = version }); - - // Settings - - service.AddSingleton(s => new Configuration - { - EncryptedDataLocation = KnownFolders.WabbajackAppLocal.Combine("encrypted"), - ModListsDownloadLocation = KnownFolders.EntryPoint.Combine("downloaded_mod_lists"), - SavedSettingsLocation = KnownFolders.WabbajackAppLocal.Combine("saved_settings"), - LogLocation = KnownFolders.EntryPoint.Combine("logs"), - ImageCacheLocation = KnownFolders.WabbajackAppLocal.Combine("image_cache") - }); - - service.AddSingleton(); - service.AddSingleton(); - return service; }