From ee086596fc84c66dd9b647c6182502a509359c0a Mon Sep 17 00:00:00 2001 From: trawzified <55751269+tr4wzified@users.noreply.github.com> Date: Sat, 27 Apr 2024 13:50:55 +0200 Subject: [PATCH] Add (WIP) CreateModListView, other miscellaneous changes --- Wabbajack.App.Wpf/App.xaml.cs | 4 +- .../Messages/NavigateToGlobal.cs | 2 +- .../ViewModels/CreateModListVM.cs | 74 +++ ...MetadataVM.cs => BaseModListMetadataVM.cs} | 37 +- .../Gallery/CreateModListMetadataVM.cs | 25 + .../Gallery/GalleryModListMetadataVM.cs | 60 +++ .../ViewModels/Gallery/ModListGalleryVM.cs | 32 +- Wabbajack.App.Wpf/ViewModels/HomeVM.cs | 1 - Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs | 28 +- Wabbajack.App.Wpf/ViewModels/NavigationVM.cs | 4 +- .../Views/Compilers/CreateModListView.xaml | 131 +++++ .../Views/Compilers/CreateModListView.xaml.cs | 38 ++ .../Views/CreateModListTileView.xaml | 476 ++++++++++++++++++ .../Views/CreateModListTileView.xaml.cs | 35 ++ Wabbajack.App.Wpf/Views/HomeView.xaml | 10 +- Wabbajack.App.Wpf/Views/MainWindow.xaml | 5 + Wabbajack.App.Wpf/Views/ModListTileView.xaml | 2 +- .../Views/ModListTileView.xaml.cs | 113 +---- .../Views/NavigationView.xaml.cs | 4 +- 19 files changed, 891 insertions(+), 190 deletions(-) create mode 100644 Wabbajack.App.Wpf/ViewModels/CreateModListVM.cs rename Wabbajack.App.Wpf/ViewModels/Gallery/{ModListMetadataVM.cs => BaseModListMetadataVM.cs} (85%) create mode 100644 Wabbajack.App.Wpf/ViewModels/Gallery/CreateModListMetadataVM.cs create mode 100644 Wabbajack.App.Wpf/ViewModels/Gallery/GalleryModListMetadataVM.cs create mode 100644 Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml create mode 100644 Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml.cs create mode 100644 Wabbajack.App.Wpf/Views/CreateModListTileView.xaml create mode 100644 Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs diff --git a/Wabbajack.App.Wpf/App.xaml.cs b/Wabbajack.App.Wpf/App.xaml.cs index 46ef304f..8f7d723e 100644 --- a/Wabbajack.App.Wpf/App.xaml.cs +++ b/Wabbajack.App.Wpf/App.xaml.cs @@ -166,12 +166,12 @@ namespace Wabbajack services.AddSingleton(); services.AddSingleton(); - services.AddTransient(); - services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); + services.AddTransient(); services.AddTransient(); services.AddTransient(); diff --git a/Wabbajack.App.Wpf/Messages/NavigateToGlobal.cs b/Wabbajack.App.Wpf/Messages/NavigateToGlobal.cs index ca1345f2..711aa3d9 100644 --- a/Wabbajack.App.Wpf/Messages/NavigateToGlobal.cs +++ b/Wabbajack.App.Wpf/Messages/NavigateToGlobal.cs @@ -8,7 +8,7 @@ public enum ScreenType ModListGallery, Installer, Settings, - Compiler, + CreateAList, ModListContents, WebBrowser } diff --git a/Wabbajack.App.Wpf/ViewModels/CreateModListVM.cs b/Wabbajack.App.Wpf/ViewModels/CreateModListVM.cs new file mode 100644 index 00000000..9130e934 --- /dev/null +++ b/Wabbajack.App.Wpf/ViewModels/CreateModListVM.cs @@ -0,0 +1,74 @@ +using System; +using System.Collections.ObjectModel; +using System.Linq; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Threading; +using System.Threading.Tasks; +using DynamicData; +using Microsoft.Extensions.Logging; +using ReactiveUI; +using Wabbajack.Common; +using Wabbajack.Networking.WabbajackClientApi; +using Wabbajack.Services.OSIntegrated; +using Wabbajack.Services.OSIntegrated.Services; + +namespace Wabbajack +{ + public class CreateModListVM : ViewModel + { + private readonly SettingsManager _settingsManager; + private readonly IServiceProvider _serviceProvider; + private readonly ILogger _logger; + private readonly Client _wjClient; + + private readonly ModListDownloadMaintainer _maintainer; + private readonly CancellationToken _cancellationToken; + + private readonly SourceCache _modLists = new(x => x.Metadata.NamespacedName); + public ReadOnlyObservableCollection _filteredModLists; + + public ReadOnlyObservableCollection ModLists => _filteredModLists; + + public CreateModListVM(ILogger logger, SettingsManager settingsManager, + IServiceProvider serviceProvider, Client wjClient, ModListDownloadMaintainer maintainer) + { + _logger = logger; + _settingsManager = settingsManager; + _serviceProvider = serviceProvider; + _wjClient = wjClient; + _maintainer = maintainer; + + LoadModLists().FireAndForget(); + + this.WhenActivated(disposables => + { + _modLists.Connect() + .ObserveOn(RxApp.MainThreadScheduler) + .Bind(out _filteredModLists) + .Subscribe((_) => { }) + .DisposeWith(disposables); + }); + } + private async Task LoadModLists() + { + using var ll = LoadingLock.WithLoading(); + try + { + var modLists = await _wjClient.LoadLists(); + _modLists.Edit(e => + { + e.Clear(); + e.AddOrUpdate(modLists.Select(m => + new CreateModListMetadataVM(_logger, this, m, _maintainer, _wjClient, _cancellationToken))); + }); + } + catch (Exception ex) + { + _logger.LogError(ex, "While loading lists"); + ll.Fail(); + } + ll.Succeed(); + } + } +} diff --git a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs b/Wabbajack.App.Wpf/ViewModels/Gallery/BaseModListMetadataVM.cs similarity index 85% rename from Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs rename to Wabbajack.App.Wpf/ViewModels/Gallery/BaseModListMetadataVM.cs index d50c8cde..e9092f71 100644 --- a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListMetadataVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/Gallery/BaseModListMetadataVM.cs @@ -1,30 +1,23 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Reactive; using System.Reactive.Linq; using System.Reactive.Subjects; using System.Threading; using System.Threading.Tasks; using System.Windows.Input; using System.Windows.Media.Imaging; -using DynamicData; using Microsoft.Extensions.Logging; using ReactiveUI; using ReactiveUI.Fody.Helpers; using Wabbajack.Common; using Wabbajack.DTOs; -using Wabbajack.DTOs.ServerResponses; -using Wabbajack; -using Wabbajack.Extensions; using Wabbajack.Messages; using Wabbajack.Models; using Wabbajack.Networking.WabbajackClientApi; using Wabbajack.Paths; -using Wabbajack.Paths.IO; using Wabbajack.RateLimiter; using Wabbajack.Services.OSIntegrated.Services; -using System.Windows.Media; namespace Wabbajack { @@ -39,19 +32,15 @@ namespace Wabbajack public string Name { get; } } - public class ModListMetadataVM : ViewModel + public class BaseModListMetadataVM : ViewModel { public ModlistMetadata Metadata { get; } - private ModListGalleryVM _parent; public ICommand OpenWebsiteCommand { get; } public ICommand ExecuteCommand { get; } public ICommand ModListContentsCommend { get; } - private readonly ObservableAsPropertyHelper _Exists; - public bool Exists => _Exists.Value; - public AbsolutePath Location { get; } public LoadingLock LoadingImageLock { get; } = new(); @@ -108,11 +97,10 @@ namespace Wabbajack private readonly Client _wjClient; private readonly CancellationToken _cancellationToken; - public ModListMetadataVM(ILogger logger, ModListGalleryVM parent, ModlistMetadata metadata, + public BaseModListMetadataVM(ILogger logger, ModlistMetadata metadata, ModListDownloadMaintainer maintainer, Client wjClient, CancellationToken cancellationToken) { _logger = logger; - _parent = parent; _maintainer = maintainer; Metadata = metadata; _wjClient = wjClient; @@ -162,23 +150,6 @@ namespace Wabbajack .CombineLatest(this.WhenAnyValue(vm => vm.IsBroken)) .Select(v => !v.First && !v.Second)); - _Exists = Observable.Interval(TimeSpan.FromSeconds(0.5)) - .Unit() - .StartWith(Unit.Default) - .FlowSwitch(_parent.WhenAny(x => x.IsActive)) - .SelectAsync(async _ => - { - try - { - return !IsDownloading && await maintainer.HaveModList(metadata); - } - catch (Exception) - { - return true; - } - }) - .ToGuiProperty(this, nameof(Exists)); - var modlistImageSource = Metadata.ValidationSummary?.SmallImage?.ToString() ?? Metadata.Links.ImageUri; var imageObs = Observable.Return(modlistImageSource) .DownloadBitmapImage((ex) => _logger.LogError("Error downloading modlist image {Title} from {ImageUri}: {Exception}", Metadata.Title, modlistImageSource, ex.Message), LoadingImageLock); @@ -194,7 +165,7 @@ namespace Wabbajack - private async Task Download() + protected async Task Download() { try { @@ -222,7 +193,7 @@ namespace Wabbajack } } - private async Task UpdateStatus() + protected async Task UpdateStatus() { if (await _maintainer.HaveModList(Metadata)) Status = ModListStatus.Downloaded; diff --git a/Wabbajack.App.Wpf/ViewModels/Gallery/CreateModListMetadataVM.cs b/Wabbajack.App.Wpf/ViewModels/Gallery/CreateModListMetadataVM.cs new file mode 100644 index 00000000..5368e685 --- /dev/null +++ b/Wabbajack.App.Wpf/ViewModels/Gallery/CreateModListMetadataVM.cs @@ -0,0 +1,25 @@ +using System.Linq; +using System.Threading; +using Microsoft.Extensions.Logging; +using ReactiveUI.Fody.Helpers; +using Wabbajack.Compiler; +using Wabbajack.DTOs; +using Wabbajack.Networking.WabbajackClientApi; +using Wabbajack.Services.OSIntegrated.Services; + +namespace Wabbajack +{ + public class CreateModListMetadataVM : BaseModListMetadataVM + { + private CreateModListVM _parent; + [Reactive] + public CompilerSettings CompilerSettings { get; set; } + + public CreateModListMetadataVM(ILogger logger, CreateModListVM parent, ModlistMetadata metadata, + ModListDownloadMaintainer maintainer, Client wjClient, CancellationToken cancellationToken) : base(logger, metadata, maintainer, wjClient, cancellationToken) + { + _parent = parent; + CompilerSettings = _parent.ModLists.FirstOrDefault(ml => ml.Metadata.Links.MachineURL == wjClient.GetMyModlists()); + } + } +} diff --git a/Wabbajack.App.Wpf/ViewModels/Gallery/GalleryModListMetadataVM.cs b/Wabbajack.App.Wpf/ViewModels/Gallery/GalleryModListMetadataVM.cs new file mode 100644 index 00000000..2cbf8fe5 --- /dev/null +++ b/Wabbajack.App.Wpf/ViewModels/Gallery/GalleryModListMetadataVM.cs @@ -0,0 +1,60 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reactive; +using System.Reactive.Linq; +using System.Reactive.Subjects; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Input; +using System.Windows.Media.Imaging; +using DynamicData; +using Microsoft.Extensions.Logging; +using ReactiveUI; +using ReactiveUI.Fody.Helpers; +using Wabbajack.Common; +using Wabbajack.DTOs; +using Wabbajack.DTOs.ServerResponses; +using Wabbajack; +using Wabbajack.Extensions; +using Wabbajack.Messages; +using Wabbajack.Models; +using Wabbajack.Networking.WabbajackClientApi; +using Wabbajack.Paths; +using Wabbajack.Paths.IO; +using Wabbajack.RateLimiter; +using Wabbajack.Services.OSIntegrated.Services; +using System.Windows.Media; + +namespace Wabbajack +{ + public class GalleryModListMetadataVM : BaseModListMetadataVM + { + private ModListGalleryVM _parent; + + private readonly ObservableAsPropertyHelper _Exists; + public bool Exists => _Exists.Value; + + public GalleryModListMetadataVM(ILogger logger, ModListGalleryVM parent, ModlistMetadata metadata, + ModListDownloadMaintainer maintainer, Client wjClient, CancellationToken cancellationToken) : base(logger, metadata, maintainer, wjClient, cancellationToken) + { + _parent = parent; + _Exists = Observable.Interval(TimeSpan.FromSeconds(0.5)) + .Unit() + .StartWith(Unit.Default) + .FlowSwitch(_parent.WhenAny(x => x.IsActive)) + .SelectAsync(async _ => + { + try + { + return !IsDownloading && await maintainer.HaveModList(metadata); + } + catch (Exception) + { + return true; + } + }) + .ToGuiProperty(this, nameof(Exists)); + } + } +} diff --git a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListGalleryVM.cs b/Wabbajack.App.Wpf/ViewModels/Gallery/ModListGalleryVM.cs index 3266d704..838c6190 100644 --- a/Wabbajack.App.Wpf/ViewModels/Gallery/ModListGalleryVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/Gallery/ModListGalleryVM.cs @@ -1,6 +1,4 @@ - - -using System; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; @@ -28,10 +26,10 @@ namespace Wabbajack { public MainWindowVM MWVM { get; } - private readonly SourceCache _modLists = new(x => x.Metadata.NamespacedName); - public ReadOnlyObservableCollection _filteredModLists; + private readonly SourceCache _modLists = new(x => x.Metadata.NamespacedName); + public ReadOnlyObservableCollection _filteredModLists; - public ReadOnlyObservableCollection ModLists => _filteredModLists; + public ReadOnlyObservableCollection ModLists => _filteredModLists; private const string ALL_GAME_IDENTIFIER = "All games"; @@ -49,8 +47,8 @@ namespace Wabbajack [Reactive] public double MinModlistSize { get; set; } [Reactive] public double MaxModlistSize { get; set; } - [Reactive] public ModListMetadataVM SmallestSizedModlist { get; set; } - [Reactive] public ModListMetadataVM LargestSizedModlist { get; set; } + [Reactive] public GalleryModListMetadataVM SmallestSizedModlist { get; set; } + [Reactive] public GalleryModListMetadataVM LargestSizedModlist { get; set; } public class GameTypeEntry { @@ -134,7 +132,7 @@ namespace Wabbajack .Throttle(searchThrottle, RxApp.MainThreadScheduler) .Select(change => change.Value.Trim()) .StartWith(Search) - .Select>(txt => + .Select>(txt => { if (string.IsNullOrWhiteSpace(txt)) return _ => true; return item => item.Metadata.Title.ContainsCaseInsensitive(txt) || @@ -144,7 +142,7 @@ namespace Wabbajack var onlyInstalledGamesFilter = this.ObservableForProperty(vm => vm.OnlyInstalled) .Select(v => v.Value) - .Select>(onlyInstalled => + .Select>(onlyInstalled => { if (onlyInstalled == false) return _ => true; return item => _locator.IsInstalled(item.Metadata.Game); @@ -154,7 +152,7 @@ namespace Wabbajack var showUnofficial = this.ObservableForProperty(vm => vm.ShowUnofficialLists) .Select(v => v.Value) .StartWith(false) - .Select>(unoffical => + .Select>(unoffical => { if (unoffical) return x => true; return x => x.Metadata.Official; @@ -162,12 +160,12 @@ namespace Wabbajack var showNSFWFilter = this.ObservableForProperty(vm => vm.ShowNSFW) .Select(v => v.Value) - .Select>(showNsfw => { return item => item.Metadata.NSFW == showNsfw; }) + .Select>(showNsfw => { return item => item.Metadata.NSFW == showNsfw; }) .StartWith(item => item.Metadata.NSFW == false); var gameFilter = this.ObservableForProperty(vm => vm.GameType) .Select(v => v.Value) - .Select>(selected => + .Select>(selected => { _filteringOnGame = true; if (selected is null or ALL_GAME_IDENTIFIER) return _ => true; @@ -178,7 +176,7 @@ namespace Wabbajack var minModlistSizeFilter = this.ObservableForProperty(vm => vm.MinModlistSize) .Throttle(TimeSpan.FromSeconds(0.05), RxApp.MainThreadScheduler) .Select(v => v.Value) - .Select>(minModlistSize => + .Select>(minModlistSize => { return item => item.Metadata.DownloadMetadata.TotalSize >= minModlistSize; }); @@ -186,7 +184,7 @@ namespace Wabbajack var maxModlistSizeFilter = this.ObservableForProperty(vm => vm.MaxModlistSize) .Throttle(TimeSpan.FromSeconds(0.05), RxApp.MainThreadScheduler) .Select(v => v.Value) - .Select>(maxModlistSize => + .Select>(maxModlistSize => { return item => item.Metadata.DownloadMetadata.TotalSize <= maxModlistSize; }); @@ -194,7 +192,7 @@ namespace Wabbajack var searchSorter = this.WhenValueChanged(vm => vm.Search) .Throttle(searchThrottle, RxApp.MainThreadScheduler) - .Select(s => SortExpressionComparer + .Select(s => SortExpressionComparer .Descending(m => m.Metadata.Title.StartsWith(s, StringComparison.InvariantCultureIgnoreCase)) .ThenByDescending(m => m.Metadata.Title.Contains(s, StringComparison.InvariantCultureIgnoreCase)) .ThenByDescending(m => !m.IsBroken)); @@ -278,7 +276,7 @@ namespace Wabbajack { e.Clear(); e.AddOrUpdate(modLists.Select(m => - new ModListMetadataVM(_logger, this, m, _maintainer, _wjClient, _cancellationToken))); + new GalleryModListMetadataVM(_logger, this, m, _maintainer, _wjClient, _cancellationToken))); }); SmallestSizedModlist = _modLists.Items.Any() ? _modLists.Items.MinBy(ml => ml.Metadata.DownloadMetadata.TotalSize) : null; LargestSizedModlist = _modLists.Items.Any() ? _modLists.Items.MaxBy(ml => ml.Metadata.DownloadMetadata.TotalSize) : null; diff --git a/Wabbajack.App.Wpf/ViewModels/HomeVM.cs b/Wabbajack.App.Wpf/ViewModels/HomeVM.cs index f4440d28..a961fd98 100644 --- a/Wabbajack.App.Wpf/ViewModels/HomeVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/HomeVM.cs @@ -24,7 +24,6 @@ namespace Wabbajack { private readonly ILogger _logger; private readonly Client _wjClient; - private readonly SourceCache _modLists = new(x => x.Metadata.NamespacedName); public HomeVM(ILogger logger, Client wjClient) { diff --git a/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs b/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs index 1d99549a..eda566e8 100644 --- a/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/MainWindowVM.cs @@ -44,10 +44,10 @@ namespace Wabbajack public ObservableCollectionExtended Log { get; } = new ObservableCollectionExtended(); - public readonly CompilerVM Compiler; - public readonly InstallerVM Installer; - public readonly SettingsVM SettingsPane; - public readonly ModListGalleryVM Gallery; + public readonly CreateModListVM CreateAListVM; + public readonly InstallerVM InstallerVM; + public readonly SettingsVM SettingsPaneVM; + public readonly ModListGalleryVM GalleryVM; public readonly HomeVM HomeVM; public readonly WebBrowserVM WebBrowserVM; public readonly Lazy ModListContentsVM; @@ -78,17 +78,17 @@ namespace Wabbajack public MainWindowVM(ILogger logger, Client wjClient, IServiceProvider serviceProvider, HomeVM homeVM, ModListGalleryVM modListGalleryVM, ResourceMonitor resourceMonitor, - InstallerVM installer, CompilerVM compilerVM, SettingsVM settingsVM, WebBrowserVM webBrowserVM, NavigationVM navigationVM) + InstallerVM installer, CreateModListVM createAListVM, SettingsVM settingsVM, WebBrowserVM webBrowserVM, NavigationVM navigationVM) { _logger = logger; _wjClient = wjClient; _resourceMonitor = resourceMonitor; _serviceProvider = serviceProvider; ConverterRegistration.Register(); - Installer = installer; - Compiler = compilerVM; - SettingsPane = settingsVM; - Gallery = modListGalleryVM; + InstallerVM = installer; + CreateAListVM = createAListVM; + SettingsPaneVM = settingsVM; + GalleryVM = modListGalleryVM; HomeVM = homeVM; WebBrowserVM = webBrowserVM; NavigationVM = navigationVM; @@ -231,10 +231,10 @@ namespace Wabbajack ActivePane = s switch { ScreenType.Home => HomeVM, - ScreenType.ModListGallery => Gallery, - ScreenType.Installer => Installer, - ScreenType.Compiler => Compiler, - ScreenType.Settings => SettingsPane, + ScreenType.ModListGallery => GalleryVM, + ScreenType.Installer => InstallerVM, + ScreenType.CreateAList => CreateAListVM, + ScreenType.Settings => SettingsPaneVM, _ => ActivePane }; } @@ -263,7 +263,7 @@ namespace Wabbajack var cancellationTokenSource = _serviceProvider.GetRequiredService(); cancellationTokenSource.Cancel(); - bool IsInstalling() => Installer.InstallState is InstallState.Installing; + bool IsInstalling() => InstallerVM.InstallState is InstallState.Installing; while (DateTime.Now < endTime && IsInstalling()) { diff --git a/Wabbajack.App.Wpf/ViewModels/NavigationVM.cs b/Wabbajack.App.Wpf/ViewModels/NavigationVM.cs index 77f1a722..073711ae 100644 --- a/Wabbajack.App.Wpf/ViewModels/NavigationVM.cs +++ b/Wabbajack.App.Wpf/ViewModels/NavigationVM.cs @@ -37,7 +37,7 @@ namespace Wabbajack LoadLastLoadedModlist.Send(); NavigateToGlobal.Send(ScreenType.Installer); }); - CompileCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.Compiler)); + CreateAListCommand = ReactiveCommand.Create(() => NavigateToGlobal.Send(ScreenType.CreateAList)); SettingsCommand = ReactiveCommand.Create( /* canExecute: this.WhenAny(x => x.ActivePane) @@ -58,7 +58,7 @@ namespace Wabbajack public ICommand HomeCommand { get; } public ICommand BrowseCommand { get; } public ICommand InstallCommand { get; } - public ICommand CompileCommand { get; } + public ICommand CreateAListCommand { get; } public ICommand SettingsCommand { get; } public string Version { get; } } diff --git a/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml b/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml new file mode 100644 index 00000000..f5d2dc4a --- /dev/null +++ b/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml @@ -0,0 +1,131 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + Import the modlist.txt file to set up a new modlist export + + + + + + + + + + + + + + + + + + Continue the export of an existing modlist or push an update + + + + + + + + + + + + + + + + + + + + Recently Compiled Modlists + + + + + + + + + + + + + + + + + + + diff --git a/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml.cs b/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml.cs new file mode 100644 index 00000000..576a24a8 --- /dev/null +++ b/Wabbajack.App.Wpf/Views/Compilers/CreateModListView.xaml.cs @@ -0,0 +1,38 @@ +using System; +using System.Diagnostics.Eventing.Reader; +using System.Linq; +using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Threading.Tasks; +using System.Windows.Controls; +using ReactiveUI; +using System.Windows; +using System.Windows.Forms; +using DynamicData; +using Microsoft.WindowsAPICodePack.Dialogs; +using Wabbajack.Common; +using Wabbajack.Paths; +using Wabbajack.Paths.IO; +using Wabbajack.ViewModels.Controls; + +namespace Wabbajack +{ + /// + /// Interaction logic for CreateAListView.xaml + /// + public partial class CreateModListView : ReactiveUserControl + { + public CreateModListView() + { + InitializeComponent(); + + this.WhenActivated(dispose => + { + this.WhenAny(x => x.ViewModel.ModLists) + .BindToStrict(this, x => x.CreatedModListsControl.ItemsSource) + .DisposeWith(dispose); + }); + + } + } +} diff --git a/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml new file mode 100644 index 00000000..68ca20e8 --- /dev/null +++ b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml @@ -0,0 +1,476 @@ + + + #92000000 + + #DF000000 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs new file mode 100644 index 00000000..23542645 --- /dev/null +++ b/Wabbajack.App.Wpf/Views/CreateModListTileView.xaml.cs @@ -0,0 +1,35 @@ +using System.Reactive.Disposables; +using System.Reactive.Linq; +using System.Windows; +using ReactiveUI; + +namespace Wabbajack +{ + /// + /// Interaction logic for CreateModListTileView.xaml + /// + public partial class CreateModListTileView : ReactiveUserControl + { + public CreateModListTileView() + { + InitializeComponent(); + this.WhenActivated(disposables => + { + ViewModel.WhenAnyValue(vm => vm.Image) + .BindToStrict(this, v => v.ModlistImage.ImageSource) + .DisposeWith(disposables); + + var textXformed = ViewModel.WhenAnyValue(vm => vm.Metadata.Title) + .CombineLatest(ViewModel.WhenAnyValue(vm => vm.Metadata.ImageContainsTitle), + ViewModel.WhenAnyValue(vm => vm.IsBroken)) + .Select(x => x.Second && !x.Third ? "" : x.First); + + + ViewModel.WhenAnyValue(x => x.LoadingImageLock.IsLoading) + .Select(x => x ? Visibility.Visible : Visibility.Collapsed) + .BindToStrict(this, x => x.LoadingProgress.Visibility) + .DisposeWith(disposables); + }); + } + } +} diff --git a/Wabbajack.App.Wpf/Views/HomeView.xaml b/Wabbajack.App.Wpf/Views/HomeView.xaml index 5987bedf..12b2c679 100644 --- a/Wabbajack.App.Wpf/Views/HomeView.xaml +++ b/Wabbajack.App.Wpf/Views/HomeView.xaml @@ -12,7 +12,7 @@ d:DesignWidth="1000" x:TypeArguments="local:HomeVM" mc:Ignorable="d"> - + @@ -47,7 +47,7 @@ - + @@ -78,7 +78,7 @@ - + @@ -109,7 +109,7 @@ - + @@ -140,7 +140,7 @@ - + diff --git a/Wabbajack.App.Wpf/Views/MainWindow.xaml b/Wabbajack.App.Wpf/Views/MainWindow.xaml index 5ba72d95..2598ba5c 100644 --- a/Wabbajack.App.Wpf/Views/MainWindow.xaml +++ b/Wabbajack.App.Wpf/Views/MainWindow.xaml @@ -67,9 +67,14 @@ + + + + diff --git a/Wabbajack.App.Wpf/Views/ModListTileView.xaml b/Wabbajack.App.Wpf/Views/ModListTileView.xaml index 87f21c65..97e1a22a 100644 --- a/Wabbajack.App.Wpf/Views/ModListTileView.xaml +++ b/Wabbajack.App.Wpf/Views/ModListTileView.xaml @@ -10,7 +10,7 @@ xmlns:rxui="http://reactiveui.net" d:DesignHeight="450" d:DesignWidth="800" - x:TypeArguments="local:ModListMetadataVM" + x:TypeArguments="local:GalleryModListMetadataVM" mc:Ignorable="d"> #92000000 diff --git a/Wabbajack.App.Wpf/Views/ModListTileView.xaml.cs b/Wabbajack.App.Wpf/Views/ModListTileView.xaml.cs index 85ab4d8f..b6e527af 100644 --- a/Wabbajack.App.Wpf/Views/ModListTileView.xaml.cs +++ b/Wabbajack.App.Wpf/Views/ModListTileView.xaml.cs @@ -14,7 +14,7 @@ namespace Wabbajack /// /// Interaction logic for ModListTileView.xaml /// - public partial class ModListTileView : ReactiveUserControl + public partial class ModListTileView : ReactiveUserControl { public ModListTileView() { @@ -24,55 +24,12 @@ namespace Wabbajack ViewModel.WhenAnyValue(vm => vm.Image) .BindToStrict(this, v => v.ModlistImage.ImageSource) .DisposeWith(disposables); - - /* - this.WhenAny(x => x.ViewModel.Metadata.Links.ImageUri) - .Select(x => new BitmapImage() { UriSource = new Uri(x) }) - .BindToStrict(this, v => v.ModlistImage.ImageSource) - .DisposeWith(disposables); - */ - /* - ViewModel.WhenAnyValue(x => x.Metadata.Links.ImageUri) - .Select(x => { - var img = new BitmapImage(); - img.BeginInit(); - img.CacheOption = BitmapCacheOption.OnDemand; - img.DecodePixelWidth = 327; - var uri = new Uri(x, UriKind.Absolute); - img.UriSource = uri; - img.EndInit(); - - return img; - }) - .BindToStrict(this, v => v.ModlistImage.ImageSource) - .DisposeWith(disposables); - */ - var textXformed = ViewModel.WhenAnyValue(vm => vm.Metadata.Title) .CombineLatest(ViewModel.WhenAnyValue(vm => vm.Metadata.ImageContainsTitle), ViewModel.WhenAnyValue(vm => vm.IsBroken)) .Select(x => x.Second && !x.Third ? "" : x.First); - - /* - textXformed - .BindToStrict(this, view => view.ModListTitle.Text) - .DisposeWith(disposables); - - textXformed - .BindToStrict(this, view => view.ModListTitleShadow.Text) - .DisposeWith(disposables); - - ViewModel.WhenAnyValue(x => x.Metadata.Description) - .BindToStrict(this, x => x.MetadataDescription.Text) - .DisposeWith(disposables); - - ViewModel.WhenAnyValue(x => x.ModListTagList) - .BindToStrict(this, x => x.TagsList.ItemsSource) - .DisposeWith(disposables); - */ - ViewModel.WhenAnyValue(x => x.LoadingImageLock.IsLoading) .Select(x => x ? Visibility.Visible : Visibility.Collapsed) .BindToStrict(this, x => x.LoadingProgress.Visibility) @@ -82,74 +39,6 @@ namespace Wabbajack .Select(x => x ? Visibility.Visible : Visibility.Collapsed) .BindToStrict(this, view => view.Overlay.Visibility) .DisposeWith(disposables); - - /* - ViewModel.WhenAnyValue(x => x.OpenWebsiteCommand) - .BindToStrict(this, x => x.OpenWebsiteButton.Command) - .DisposeWith(disposables); - - ViewModel.WhenAnyValue(x => x.ModListContentsCommend) - .BindToStrict(this, x => x.ModListContentsButton.Command) - .DisposeWith(disposables); - - ViewModel.WhenAnyValue(x => x.ExecuteCommand) - .BindToStrict(this, x => x.ExecuteButton.Command) - .DisposeWith(disposables); - */ - - - /* - ViewModel.WhenAnyValue(x => x.ProgressPercent) - .ObserveOn(RxApp.MainThreadScheduler) - .Select(p => p.Value) - .BindTo(this, x => x.DownloadProgressBar.Value) - .DisposeWith(disposables); - */ - - /* - ViewModel.WhenAnyValue(x => x.Status) - .ObserveOnGuiThread() - .Subscribe(x => - { - IconContainer.Children.Clear(); - IconContainer.Children.Add(new PackIconMaterial - { - Width = 20, - Height = 20, - Kind = x switch - { - ModListMetadataVM.ModListStatus.Downloaded => PackIconMaterialKind.Play, - ModListMetadataVM.ModListStatus.Downloading => PackIconMaterialKind.Network, - ModListMetadataVM.ModListStatus.NotDownloaded => PackIconMaterialKind.Download, - _ => throw new ArgumentOutOfRangeException(nameof(x), x, null) - } - }); - }) - .DisposeWith(disposables); - */ - - /* - this.MarkAsNeeded(this.ViewModel, x => x.IsBroken); - this.MarkAsNeeded(this.ViewModel, x => x.Exists); - this.MarkAsNeeded(this.ViewModel, x => x.Metadata.Links.ImageUri); - this.WhenAny(x => x.ViewModel.ProgressPercent) - .Select(p => p.Value) - .BindToStrict(this, x => x.DownloadProgressBar.Value) - .DisposeWith(dispose); - - - this.WhenAny(x => x.ViewModel.ModListContentsCommend) - .BindToStrict(this, x => x.ModListContentsButton.Command) - .DisposeWith(dispose); - - this.WhenAny(x => x.ViewModel.Image) - .BindToStrict(this, x => x.ModListImage.Source) - .DisposeWith(dispose); - this.WhenAny(x => x.ViewModel.LoadingImage) - .Select(x => x ? Visibility.Visible : Visibility.Collapsed) - .BindToStrict(this, x => x.LoadingProgress.Visibility) - .DisposeWith(dispose); - */ }); } } diff --git a/Wabbajack.App.Wpf/Views/NavigationView.xaml.cs b/Wabbajack.App.Wpf/Views/NavigationView.xaml.cs index 31487fbd..ef20be40 100644 --- a/Wabbajack.App.Wpf/Views/NavigationView.xaml.cs +++ b/Wabbajack.App.Wpf/Views/NavigationView.xaml.cs @@ -23,7 +23,7 @@ namespace Wabbajack ScreenButtonDictionary = new() { { ScreenType.Home, HomeButton }, { ScreenType.ModListGallery, BrowseButton }, - { ScreenType.Compiler, CompileButton }, + { ScreenType.CreateAList, CompileButton }, { ScreenType.Settings, SettingsButton }, }; this.WhenActivated(dispose => @@ -32,7 +32,7 @@ namespace Wabbajack .DisposeWith(dispose); this.BindCommand(ViewModel, vm => vm.HomeCommand, v => v.HomeButton) .DisposeWith(dispose); - this.BindCommand(ViewModel, vm => vm.CompileCommand, v => v.CompileButton) + this.BindCommand(ViewModel, vm => vm.CreateAListCommand, v => v.CompileButton) .DisposeWith(dispose); this.BindCommand(ViewModel, vm => vm.SettingsCommand, v => v.SettingsButton) .DisposeWith(dispose);