mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Port ModListGalleryVM
This commit is contained in:
parent
eb0b5b0ea5
commit
9a13413472
@ -1,21 +1,21 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Disposables;
|
using System.Reactive.Disposables;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Reactive.Subjects;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using DynamicData;
|
using DynamicData;
|
||||||
using DynamicData.Binding;
|
using DynamicData.Binding;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
using ReactiveUI;
|
using ReactiveUI;
|
||||||
using ReactiveUI.Fody.Helpers;
|
using ReactiveUI.Fody.Helpers;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
using Wabbajack.Lib;
|
using Wabbajack.Downloaders.GameFile;
|
||||||
using Wabbajack.Lib.ModListRegistry;
|
using Wabbajack.DTOs;
|
||||||
|
using Wabbajack.Hashing.xxHash64;
|
||||||
|
using Wabbajack.Lib.Extensions;
|
||||||
|
using Wabbajack.Networking.WabbajackClientApi;
|
||||||
|
|
||||||
namespace Wabbajack
|
namespace Wabbajack
|
||||||
{
|
{
|
||||||
@ -48,6 +48,9 @@ namespace Wabbajack
|
|||||||
public List<string> GameTypeEntries { get { return GetGameTypeEntries(); } }
|
public List<string> GameTypeEntries { get { return GetGameTypeEntries(); } }
|
||||||
|
|
||||||
private readonly ObservableAsPropertyHelper<bool> _Loaded;
|
private readonly ObservableAsPropertyHelper<bool> _Loaded;
|
||||||
|
private readonly Client _wjClient;
|
||||||
|
private readonly ILogger<ModListGalleryVM> _logger;
|
||||||
|
private readonly GameLocator _locator;
|
||||||
|
|
||||||
private FiltersSettings settings => MWVM.Settings.Filters;
|
private FiltersSettings settings => MWVM.Settings.Filters;
|
||||||
|
|
||||||
@ -55,10 +58,14 @@ namespace Wabbajack
|
|||||||
|
|
||||||
public ICommand ClearFiltersCommand { get; }
|
public ICommand ClearFiltersCommand { get; }
|
||||||
|
|
||||||
public ModListGalleryVM(MainWindowVM mainWindowVM)
|
public ModListGalleryVM(ILogger<ModListGalleryVM> logger, MainWindowVM mainWindowVM, Client wjClient,
|
||||||
|
GameLocator locator)
|
||||||
: base(mainWindowVM)
|
: base(mainWindowVM)
|
||||||
{
|
{
|
||||||
MWVM = mainWindowVM;
|
MWVM = mainWindowVM;
|
||||||
|
_wjClient = wjClient;
|
||||||
|
_logger = logger;
|
||||||
|
_locator = locator;
|
||||||
|
|
||||||
// load persistent filter settings
|
// load persistent filter settings
|
||||||
if (settings.IsPersistent)
|
if (settings.IsPersistent)
|
||||||
@ -103,14 +110,14 @@ namespace Wabbajack
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
Error = null;
|
Error = null;
|
||||||
var list = await ModlistMetadata.LoadFromGithub();
|
var list = await _wjClient.LoadLists();
|
||||||
Error = ErrorResponse.Success;
|
Error = ErrorResponse.Success;
|
||||||
return list
|
return list
|
||||||
.AsObservableChangeSet(x => x.DownloadMetadata?.Hash ?? Hash.Empty);
|
.AsObservableChangeSet(x => x.DownloadMetadata?.Hash ?? default);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Utils.Error(ex);
|
_logger.LogError(ex, "While Loading Lists");
|
||||||
Error = ErrorResponse.Fail(ex);
|
Error = ErrorResponse.Fail(ex);
|
||||||
return Observable.Empty<IChangeSet<ModlistMetadata, Hash>>();
|
return Observable.Empty<IChangeSet<ModlistMetadata, Hash>>();
|
||||||
}
|
}
|
||||||
@ -137,7 +144,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
if (!onlyInstalled) return true;
|
if (!onlyInstalled) return true;
|
||||||
if (!GameRegistry.Games.TryGetValue(vm.Metadata.Game, out var gameMeta)) return false;
|
if (!GameRegistry.Games.TryGetValue(vm.Metadata.Game, out var gameMeta)) return false;
|
||||||
return gameMeta.IsInstalled;
|
return _locator.IsInstalled(gameMeta.Game);
|
||||||
}))
|
}))
|
||||||
// Filter on search box
|
// Filter on search box
|
||||||
.Filter(this.WhenAny(x => x.Search)
|
.Filter(this.WhenAny(x => x.Search)
|
||||||
@ -192,7 +199,7 @@ namespace Wabbajack
|
|||||||
private List<string> GetGameTypeEntries()
|
private List<string> GetGameTypeEntries()
|
||||||
{
|
{
|
||||||
List<string> gameEntries = new List<string> { ALL_GAME_TYPE };
|
List<string> gameEntries = new List<string> { ALL_GAME_TYPE };
|
||||||
gameEntries.AddRange(EnumExtensions.GetAllItems<Game>().Select(gameType => gameType.GetDescription<Game>()));
|
gameEntries.AddRange(GameRegistry.Games.Values.Select(gameType => gameType.HumanFriendlyGameName));
|
||||||
gameEntries.Sort();
|
gameEntries.Sort();
|
||||||
return gameEntries;
|
return gameEntries;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user