mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Modlist contents viewer
This commit is contained in:
parent
5051e800b4
commit
e9864244cb
20
Wabbajack/Converters/FileSizeConverter.cs
Normal file
20
Wabbajack/Converters/FileSizeConverter.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class FileSizeConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return ((long)value).ToFileSizeString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
@ -18,6 +18,7 @@
|
||||
<local:EqualsToBoolConverter x:Key="EqualsToBoolConverter" />
|
||||
<local:IsTypeVisibilityConverter x:Key="IsTypeVisibilityConverter" />
|
||||
<local:AbsolutePathToStringConverter x:Key="AbsolutePathToStringConverter" />
|
||||
<local:FileSizeConverter x:Key="FileSizeConverter"/>
|
||||
|
||||
<!-- Colors -->
|
||||
<Color x:Key="WindowBackgroundColor">#121212</Color>
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Input;
|
||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
||||
using System.Net;
|
||||
using System.Reactive;
|
||||
using System.Reactive.Linq;
|
||||
using System.Reactive.Subjects;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
@ -74,6 +75,8 @@ namespace Wabbajack
|
||||
private readonly ObservableAsPropertyHelper<bool> _LoadingImage;
|
||||
public bool LoadingImage => _LoadingImage.Value;
|
||||
|
||||
private Subject<bool> IsLoadingIdle;
|
||||
|
||||
public ModListMetadataVM(ModListGalleryVM parent, ModlistMetadata metadata)
|
||||
{
|
||||
_parent = parent;
|
||||
@ -92,15 +95,26 @@ namespace Wabbajack
|
||||
IsBroken = metadata.ValidationSummary.HasFailures || metadata.ForceDown;
|
||||
//https://www.wabbajack.org/#/modlists/info?machineURL=eldersouls
|
||||
OpenWebsiteCommand = ReactiveCommand.Create(() => Utils.OpenWebsite(new Uri($"https://www.wabbajack.org/#/modlists/info?machineURL={Metadata.Links.MachineURL}")));
|
||||
|
||||
IsLoadingIdle = new Subject<bool>();
|
||||
|
||||
ModListContentsCommend = ReactiveCommand.Create(async () =>
|
||||
{
|
||||
_parent.MWVM.ModListContentsVM.Value.Name = metadata.Title;
|
||||
var status = await ClientAPI.GetDetailedStatus(metadata.Links.MachineURL);
|
||||
var coll = _parent.MWVM.ModListContentsVM.Value.Status;
|
||||
coll.Clear();
|
||||
coll.AddRange(status.Archives);
|
||||
_parent.MWVM.NavigateTo(_parent.MWVM.ModListContentsVM.Value);
|
||||
});
|
||||
IsLoadingIdle.OnNext(false);
|
||||
try
|
||||
{
|
||||
var status = await ClientAPI.GetDetailedStatus(metadata.Links.MachineURL);
|
||||
var coll = _parent.MWVM.ModListContentsVM.Value.Status;
|
||||
coll.Clear();
|
||||
coll.AddRange(status.Archives);
|
||||
_parent.MWVM.NavigateTo(_parent.MWVM.ModListContentsVM.Value);
|
||||
}
|
||||
finally
|
||||
{
|
||||
IsLoadingIdle.OnNext(true);
|
||||
}
|
||||
}, IsLoadingIdle.StartWith(true));
|
||||
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(
|
||||
canExecute: this.WhenAny(x => x.IsBroken).Select(x => !x),
|
||||
execute: (unit) =>
|
||||
|
@ -15,7 +15,7 @@ using Wabbajack.Common;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class ModListContentsVM : ViewModel
|
||||
public class ModListContentsVM : BackNavigatingVM
|
||||
{
|
||||
private MainWindowVM _mwvm;
|
||||
[Reactive]
|
||||
@ -30,11 +30,12 @@ namespace Wabbajack
|
||||
private readonly ReadOnlyObservableCollection<ModListArchive> _archives;
|
||||
public ReadOnlyObservableCollection<ModListArchive> Archives => _archives;
|
||||
|
||||
public ModListContentsVM(MainWindowVM mwvm)
|
||||
public ModListContentsVM(MainWindowVM mwvm) : base(mwvm)
|
||||
{
|
||||
_mwvm = mwvm;
|
||||
Status = new ObservableCollectionExtended<DetailedStatusItem>();
|
||||
|
||||
|
||||
Regex nameMatcher = new Regex(@"(?<=\.)[^\.]+(?=\+State)");
|
||||
string TransformClassName(Archive a)
|
||||
{
|
||||
@ -50,11 +51,22 @@ namespace Wabbajack
|
||||
.Transform(a => new ModListArchive
|
||||
{
|
||||
Name = a.Name,
|
||||
Size = a.Archive?.Size.ToFileSizeString(),
|
||||
Size = a.Archive?.Size ?? 0,
|
||||
Url = a.Url ?? "",
|
||||
Downloader = TransformClassName(a.Archive) ?? "Unknown",
|
||||
Hash = a.Archive!.Hash.ToBase64()
|
||||
})
|
||||
.Filter(this.WhenAny(x => x.SearchString)
|
||||
.StartWith("")
|
||||
.Throttle(TimeSpan.FromMilliseconds(250))
|
||||
.Select<string, Func<ModListArchive, bool>>(s => (ModListArchive ar) =>
|
||||
string.IsNullOrEmpty(s) ||
|
||||
ar.Name.ContainsCaseInsensitive(s) ||
|
||||
ar.Downloader.ContainsCaseInsensitive(s) ||
|
||||
ar.Hash.ContainsCaseInsensitive(s) ||
|
||||
ar.Size.ToString() == s ||
|
||||
ar.Url.ContainsCaseInsensitive(s)))
|
||||
.ObserveOnGuiThread()
|
||||
.Bind(out _archives)
|
||||
.Subscribe()
|
||||
.DisposeWith(CompositeDisposable);
|
||||
@ -64,7 +76,7 @@ namespace Wabbajack
|
||||
public class ModListArchive
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string Size { get; set; }
|
||||
public long Size { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Downloader { get; set; }
|
||||
public string Hash { get; set; }
|
||||
|
@ -30,15 +30,8 @@
|
||||
Text="Search" />
|
||||
<TextBox
|
||||
x:Name="SearchBox"
|
||||
Width="300"
|
||||
Width="400"
|
||||
VerticalContentAlignment="Center" />
|
||||
<Button
|
||||
x:Name="ClearFiltersButton"
|
||||
Margin="0,0,10,0"
|
||||
Style="{StaticResource IconBareButtonStyle}"
|
||||
ToolTip="Clear All Filters">
|
||||
<iconPacks:Material Kind="FilterRemove" />
|
||||
</Button>
|
||||
</WrapPanel>
|
||||
<Button Grid.Row="0"
|
||||
x:Name="BackButton"
|
||||
@ -54,11 +47,11 @@
|
||||
|
||||
<DataGrid Grid.Row="1" x:Name="ArchiveGrid" AutoGenerateColumns="False" AlternatingRowBackground="#131313" FontSize="14">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Downloader" Binding="{Binding Downloader}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Size" Binding="{Binding Size}"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Hash" Binding="{Binding Hash}"></DataGridTextColumn>
|
||||
<DataGridHyperlinkColumn Header="Link" Binding="{Binding Url}"></DataGridHyperlinkColumn>
|
||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Downloader" Binding="{Binding Downloader}" IsReadOnly="True"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Size" Binding="{Binding Size, Converter={StaticResource FileSizeConverter}}" IsReadOnly="True"></DataGridTextColumn>
|
||||
<DataGridTextColumn Header="Hash" Binding="{Binding Hash}" IsReadOnly="True"></DataGridTextColumn>
|
||||
<DataGridHyperlinkColumn Header="Link" Binding="{Binding Url}" IsReadOnly="True"></DataGridHyperlinkColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
|
||||
|
@ -19,27 +19,17 @@ namespace Wabbajack
|
||||
InitializeComponent();
|
||||
this.WhenActivated(disposable =>
|
||||
{
|
||||
/*
|
||||
var queryText = this
|
||||
.WhenAny(x => x.SearchBox)
|
||||
.Select(t => t.Text)
|
||||
.StartWith("")
|
||||
.Select<string, Func<ModListArchive, bool>>(s => (ModListArchive ar) =>
|
||||
string.IsNullOrEmpty(s) ||
|
||||
ar.Name.ContainsCaseInsensitive(s) ||
|
||||
ar.Downloader.ContainsCaseInsensitive(s) ||
|
||||
ar.Hash.ContainsCaseInsensitive(s) ||
|
||||
ar.Size.ContainsCaseInsensitive(s) ||
|
||||
ar.Url.ContainsCaseInsensitive(s));
|
||||
*/
|
||||
|
||||
this.ArchiveGrid.ItemsSource = this.ViewModel.Archives;
|
||||
|
||||
this.WhenAny(x => x.ViewModel.Name)
|
||||
.BindToStrict(this, x => x.ModListTitle.Title)
|
||||
.DisposeWith(disposable);
|
||||
/*this.WhenAny(x => x.ViewModel.Archives)
|
||||
.BindToStrict(this, x => x.ArchiveGrid.ItemsSource)
|
||||
.DisposeWith(disposable);*/
|
||||
this.BindStrict(ViewModel, x => x.SearchString, x => x.SearchBox.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.WhenAny(x => x.ViewModel.BackCommand)
|
||||
.BindToStrict(this, x => x.BackButton.Command)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user