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:EqualsToBoolConverter x:Key="EqualsToBoolConverter" />
|
||||||
<local:IsTypeVisibilityConverter x:Key="IsTypeVisibilityConverter" />
|
<local:IsTypeVisibilityConverter x:Key="IsTypeVisibilityConverter" />
|
||||||
<local:AbsolutePathToStringConverter x:Key="AbsolutePathToStringConverter" />
|
<local:AbsolutePathToStringConverter x:Key="AbsolutePathToStringConverter" />
|
||||||
|
<local:FileSizeConverter x:Key="FileSizeConverter"/>
|
||||||
|
|
||||||
<!-- Colors -->
|
<!-- Colors -->
|
||||||
<Color x:Key="WindowBackgroundColor">#121212</Color>
|
<Color x:Key="WindowBackgroundColor">#121212</Color>
|
||||||
|
@ -5,6 +5,7 @@ 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.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Reactive;
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
|
using System.Reactive.Subjects;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@ -74,6 +75,8 @@ namespace Wabbajack
|
|||||||
private readonly ObservableAsPropertyHelper<bool> _LoadingImage;
|
private readonly ObservableAsPropertyHelper<bool> _LoadingImage;
|
||||||
public bool LoadingImage => _LoadingImage.Value;
|
public bool LoadingImage => _LoadingImage.Value;
|
||||||
|
|
||||||
|
private Subject<bool> IsLoadingIdle;
|
||||||
|
|
||||||
public ModListMetadataVM(ModListGalleryVM parent, ModlistMetadata metadata)
|
public ModListMetadataVM(ModListGalleryVM parent, ModlistMetadata metadata)
|
||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
@ -92,15 +95,26 @@ namespace Wabbajack
|
|||||||
IsBroken = metadata.ValidationSummary.HasFailures || metadata.ForceDown;
|
IsBroken = metadata.ValidationSummary.HasFailures || metadata.ForceDown;
|
||||||
//https://www.wabbajack.org/#/modlists/info?machineURL=eldersouls
|
//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}")));
|
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 () =>
|
ModListContentsCommend = ReactiveCommand.Create(async () =>
|
||||||
{
|
{
|
||||||
_parent.MWVM.ModListContentsVM.Value.Name = metadata.Title;
|
_parent.MWVM.ModListContentsVM.Value.Name = metadata.Title;
|
||||||
var status = await ClientAPI.GetDetailedStatus(metadata.Links.MachineURL);
|
IsLoadingIdle.OnNext(false);
|
||||||
var coll = _parent.MWVM.ModListContentsVM.Value.Status;
|
try
|
||||||
coll.Clear();
|
{
|
||||||
coll.AddRange(status.Archives);
|
var status = await ClientAPI.GetDetailedStatus(metadata.Links.MachineURL);
|
||||||
_parent.MWVM.NavigateTo(_parent.MWVM.ModListContentsVM.Value);
|
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>(
|
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(
|
||||||
canExecute: this.WhenAny(x => x.IsBroken).Select(x => !x),
|
canExecute: this.WhenAny(x => x.IsBroken).Select(x => !x),
|
||||||
execute: (unit) =>
|
execute: (unit) =>
|
||||||
|
@ -15,7 +15,7 @@ using Wabbajack.Common;
|
|||||||
|
|
||||||
namespace Wabbajack
|
namespace Wabbajack
|
||||||
{
|
{
|
||||||
public class ModListContentsVM : ViewModel
|
public class ModListContentsVM : BackNavigatingVM
|
||||||
{
|
{
|
||||||
private MainWindowVM _mwvm;
|
private MainWindowVM _mwvm;
|
||||||
[Reactive]
|
[Reactive]
|
||||||
@ -30,10 +30,11 @@ namespace Wabbajack
|
|||||||
private readonly ReadOnlyObservableCollection<ModListArchive> _archives;
|
private readonly ReadOnlyObservableCollection<ModListArchive> _archives;
|
||||||
public ReadOnlyObservableCollection<ModListArchive> Archives => _archives;
|
public ReadOnlyObservableCollection<ModListArchive> Archives => _archives;
|
||||||
|
|
||||||
public ModListContentsVM(MainWindowVM mwvm)
|
public ModListContentsVM(MainWindowVM mwvm) : base(mwvm)
|
||||||
{
|
{
|
||||||
_mwvm = mwvm;
|
_mwvm = mwvm;
|
||||||
Status = new ObservableCollectionExtended<DetailedStatusItem>();
|
Status = new ObservableCollectionExtended<DetailedStatusItem>();
|
||||||
|
|
||||||
|
|
||||||
Regex nameMatcher = new Regex(@"(?<=\.)[^\.]+(?=\+State)");
|
Regex nameMatcher = new Regex(@"(?<=\.)[^\.]+(?=\+State)");
|
||||||
string TransformClassName(Archive a)
|
string TransformClassName(Archive a)
|
||||||
@ -50,11 +51,22 @@ namespace Wabbajack
|
|||||||
.Transform(a => new ModListArchive
|
.Transform(a => new ModListArchive
|
||||||
{
|
{
|
||||||
Name = a.Name,
|
Name = a.Name,
|
||||||
Size = a.Archive?.Size.ToFileSizeString(),
|
Size = a.Archive?.Size ?? 0,
|
||||||
Url = a.Url ?? "",
|
Url = a.Url ?? "",
|
||||||
Downloader = TransformClassName(a.Archive) ?? "Unknown",
|
Downloader = TransformClassName(a.Archive) ?? "Unknown",
|
||||||
Hash = a.Archive!.Hash.ToBase64()
|
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)
|
.Bind(out _archives)
|
||||||
.Subscribe()
|
.Subscribe()
|
||||||
.DisposeWith(CompositeDisposable);
|
.DisposeWith(CompositeDisposable);
|
||||||
@ -64,7 +76,7 @@ namespace Wabbajack
|
|||||||
public class ModListArchive
|
public class ModListArchive
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string Size { get; set; }
|
public long Size { get; set; }
|
||||||
public string Url { get; set; }
|
public string Url { get; set; }
|
||||||
public string Downloader { get; set; }
|
public string Downloader { get; set; }
|
||||||
public string Hash { get; set; }
|
public string Hash { get; set; }
|
||||||
|
@ -30,15 +30,8 @@
|
|||||||
Text="Search" />
|
Text="Search" />
|
||||||
<TextBox
|
<TextBox
|
||||||
x:Name="SearchBox"
|
x:Name="SearchBox"
|
||||||
Width="300"
|
Width="400"
|
||||||
VerticalContentAlignment="Center" />
|
VerticalContentAlignment="Center" />
|
||||||
<Button
|
|
||||||
x:Name="ClearFiltersButton"
|
|
||||||
Margin="0,0,10,0"
|
|
||||||
Style="{StaticResource IconBareButtonStyle}"
|
|
||||||
ToolTip="Clear All Filters">
|
|
||||||
<iconPacks:Material Kind="FilterRemove" />
|
|
||||||
</Button>
|
|
||||||
</WrapPanel>
|
</WrapPanel>
|
||||||
<Button Grid.Row="0"
|
<Button Grid.Row="0"
|
||||||
x:Name="BackButton"
|
x:Name="BackButton"
|
||||||
@ -54,11 +47,11 @@
|
|||||||
|
|
||||||
<DataGrid Grid.Row="1" x:Name="ArchiveGrid" AutoGenerateColumns="False" AlternatingRowBackground="#131313" FontSize="14">
|
<DataGrid Grid.Row="1" x:Name="ArchiveGrid" AutoGenerateColumns="False" AlternatingRowBackground="#131313" FontSize="14">
|
||||||
<DataGrid.Columns>
|
<DataGrid.Columns>
|
||||||
<DataGridTextColumn Header="Name" Binding="{Binding Name}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Name" Binding="{Binding Name}" IsReadOnly="True"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="Downloader" Binding="{Binding Downloader}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Downloader" Binding="{Binding Downloader}" IsReadOnly="True"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="Size" Binding="{Binding Size}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Size" Binding="{Binding Size, Converter={StaticResource FileSizeConverter}}" IsReadOnly="True"></DataGridTextColumn>
|
||||||
<DataGridTextColumn Header="Hash" Binding="{Binding Hash}"></DataGridTextColumn>
|
<DataGridTextColumn Header="Hash" Binding="{Binding Hash}" IsReadOnly="True"></DataGridTextColumn>
|
||||||
<DataGridHyperlinkColumn Header="Link" Binding="{Binding Url}"></DataGridHyperlinkColumn>
|
<DataGridHyperlinkColumn Header="Link" Binding="{Binding Url}" IsReadOnly="True"></DataGridHyperlinkColumn>
|
||||||
</DataGrid.Columns>
|
</DataGrid.Columns>
|
||||||
</DataGrid>
|
</DataGrid>
|
||||||
|
|
||||||
|
@ -19,27 +19,17 @@ namespace Wabbajack
|
|||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
this.WhenActivated(disposable =>
|
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.ArchiveGrid.ItemsSource = this.ViewModel.Archives;
|
||||||
|
|
||||||
this.WhenAny(x => x.ViewModel.Name)
|
this.WhenAny(x => x.ViewModel.Name)
|
||||||
.BindToStrict(this, x => x.ModListTitle.Title)
|
.BindToStrict(this, x => x.ModListTitle.Title)
|
||||||
.DisposeWith(disposable);
|
.DisposeWith(disposable);
|
||||||
/*this.WhenAny(x => x.ViewModel.Archives)
|
this.BindStrict(ViewModel, x => x.SearchString, x => x.SearchBox.Text)
|
||||||
.BindToStrict(this, x => x.ArchiveGrid.ItemsSource)
|
.DisposeWith(disposable);
|
||||||
.DisposeWith(disposable);*/
|
this.WhenAny(x => x.ViewModel.BackCommand)
|
||||||
|
.BindToStrict(this, x => x.BackButton.Command)
|
||||||
|
.DisposeWith(disposable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user