Merge pull request #811 from LordOfRhun/modlist-information

[Feature] added more information on modlist tiles
This commit is contained in:
Timothy Baldridge 2020-05-09 15:22:15 -07:00 committed by GitHub
commit ca9d5fde37
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 143 additions and 1 deletions

View File

@ -29,6 +29,9 @@ namespace Wabbajack.Lib.ModListRegistry
[JsonProperty("official")]
public bool Official { get; set; }
[JsonProperty("tags")]
public List<string> tags { get; set; } = new List<string>();
[JsonProperty("nsfw")]
public bool NSFW { get; set; }

View File

@ -120,5 +120,23 @@ namespace Wabbajack
}
});
}
/// <summary>
/// Format bytes to a greater unit
/// </summary>
/// <param name="bytes">number of bytes</param>
/// <returns></returns>
public static string FormatBytes(long bytes)
{
string[] Suffix = { "B", "KB", "MB", "GB", "TB" };
int i;
double dblSByte = bytes;
for (i = 0; i < Suffix.Length && bytes >= 1024; i++, bytes /= 1024)
{
dblSByte = bytes / 1024.0;
}
return String.Format("{0:0.##} {1}", dblSByte, Suffix[i]);
}
}
}

View File

@ -20,6 +20,17 @@ using Wabbajack.Lib.ModListRegistry;
namespace Wabbajack
{
public struct ModListTag
{
public ModListTag(string name)
{
Name = name;
}
public string Name { get; }
}
public class ModListMetadataVM : ViewModel
{
public ModlistMetadata Metadata { get; }
@ -33,12 +44,21 @@ namespace Wabbajack
public AbsolutePath Location { get; }
[Reactive]
public List<ModListTag> ModListTagList { get; private set; }
[Reactive]
public Percent ProgressPercent { get; private set; }
[Reactive]
public bool IsBroken { get; private set; }
[Reactive]
public string DownloadSizeText { get; private set; }
[Reactive]
public string InstallSizeText { get; private set; }
[Reactive]
public IErrorResponse Error { get; private set; }
@ -53,6 +73,13 @@ namespace Wabbajack
_parent = parent;
Metadata = metadata;
Location = Consts.ModListDownloadFolder.Combine(Metadata.Links.MachineURL + (string)Consts.ModListExtension);
ModListTagList = new List<ModListTag>();
Metadata.tags.ForEach(tag =>
{
ModListTagList.Add(new ModListTag(tag));
});
DownloadSizeText = "Download size : " + UIUtils.FormatBytes(Metadata.DownloadMetadata.SizeOfArchives);
InstallSizeText = "Installation size : " + UIUtils.FormatBytes(Metadata.DownloadMetadata.SizeOfInstalledFiles);
IsBroken = metadata.ValidationSummary.HasFailures;
OpenWebsiteCommand = ReactiveCommand.Create(() => Utils.OpenWebsite(new Uri($"https://www.wabbajack.org/modlist/{Metadata.Links.MachineURL}")));
ExecuteCommand = ReactiveCommand.CreateFromObservable<Unit, Unit>(

View File

@ -146,6 +146,100 @@
</Style>
</Ellipse.Style>
</Ellipse>
<ItemsControl ItemsSource="{Binding ModListTagList}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<Border
BorderThickness="1"
Grid.Row="0"
Grid.ColumnSpan="2"
CornerRadius="7,7,7,7"
Opacity="0.90"
Background="{StaticResource Analogous1Brush}"
Margin="10,5,0,5">
<TextBlock
Margin="5,5,5,5"
FontSize="15"
Text="{Binding Name}"/>
</Border>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
<Label
Content="{Binding DownloadSizeText}"
HorizontalAlignment="Left"
Margin="10,257,0,0"
VerticalAlignment="Top"
Opacity="0" >
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=ModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<Label
Content="{Binding InstallSizeText}"
HorizontalAlignment="Left"
Margin="10,272,0,0"
VerticalAlignment="Top"
Opacity="0" >
<Label.Style>
<Style TargetType="Label">
<Style.Triggers>
<DataTrigger Binding="{Binding IsMouseOver, ElementName=ModListTile}" Value="True">
<DataTrigger.EnterActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="1"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.EnterActions>
<DataTrigger.ExitActions>
<BeginStoryboard>
<Storyboard>
<DoubleAnimation
Storyboard.TargetProperty="Opacity"
To="0"
Duration="0:0:0.08" />
</Storyboard>
</BeginStoryboard>
</DataTrigger.ExitActions>
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
</Grid>
</Border>
<local:UnderMaintenanceOverlay