mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Fleshed out the Manifest
This commit is contained in:
parent
853ab81bbf
commit
f03db43798
@ -1,14 +1,24 @@
|
||||
using Wabbajack.Lib;
|
||||
using System.Collections.Generic;
|
||||
using Wabbajack.Common;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
namespace Wabbajack.View_Models
|
||||
namespace Wabbajack
|
||||
{
|
||||
public class ManifestVM : ViewModel
|
||||
{
|
||||
public readonly Manifest Manifest;
|
||||
public Manifest Manifest { get; set; }
|
||||
|
||||
public ManifestVM(ModList modlist)
|
||||
public string Name => !string.IsNullOrWhiteSpace(Manifest.Name) ? Manifest.Name : "Wabbajack Modlist";
|
||||
public string Author => !string.IsNullOrWhiteSpace(Manifest.Author) ? $"Created by {Manifest.Author}" : "Created by Jyggalag";
|
||||
public string Description => !string.IsNullOrWhiteSpace(Manifest.Description) ? Manifest.Description : "";
|
||||
public string InstallSize => $"Install Size: {Manifest.InstallSize.ToFileSizeString()}";
|
||||
public string DownloadSize => $"Download Size: {Manifest.DownloadSize.ToFileSizeString()}";
|
||||
|
||||
public IEnumerable<Archive> Archives => Manifest.Archives;
|
||||
|
||||
public ManifestVM(Manifest manifest)
|
||||
{
|
||||
Manifest = new Manifest(modlist);
|
||||
Manifest = manifest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,60 @@
|
||||
<reactiveUi:ReactiveUserControl x:TypeArguments="viewModels:ManifestVM" x:Class="Wabbajack.ManifestView"
|
||||
<reactiveUi:ReactiveUserControl x:TypeArguments="local:ManifestVM" x:Class="Wabbajack.ManifestView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:reactiveUi="http://reactiveui.net"
|
||||
xmlns:viewModels="clr-namespace:Wabbajack.View_Models"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="450" d:DesignWidth="800">
|
||||
<ScrollViewer>
|
||||
<Grid Margin="8">
|
||||
<TextBlock x:Name="Name" FontSize="20"/>
|
||||
</Grid>
|
||||
<ScrollViewer.Resources>
|
||||
<Style x:Key="HeaderStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#03DAC6"/>
|
||||
</Style>
|
||||
<Style x:Key="HyperlinkStyle" TargetType="{x:Type Hyperlink}">
|
||||
<Setter Property="Foreground" Value="#BB76FC"/>
|
||||
</Style>
|
||||
<Style x:Key="ModTitleStyle" TargetType="{x:Type TextBlock}">
|
||||
<Setter Property="Foreground" Value="#C7FC86"/>
|
||||
</Style>
|
||||
</ScrollViewer.Resources>
|
||||
<StackPanel Margin="8">
|
||||
<TextBlock x:Name="Name" FontSize="32" HorizontalAlignment="Center" Style="{StaticResource HeaderStyle}"/>
|
||||
<TextBlock x:Name="Author" FontSize="14" Padding="0 3 0 3"/>
|
||||
<TextBlock x:Name="Description" FontSize="14" TextWrapping="Wrap"/>
|
||||
|
||||
<!--<ItemsControl Margin="8" x:Name="ManifestItemsControl">
|
||||
<ItemsControl.Resources>
|
||||
<DataTemplate x:Key="HeaderTemplate">
|
||||
<Grid>
|
||||
<TextBlock Text="{Binding Path=Text}" FontSize="20"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.Resources>
|
||||
<TextBlock FontSize="26" Padding="0 6 0 0" Text="Mods"/>
|
||||
<TextBlock x:Name="InstallSize" FontSize="20"/>
|
||||
<TextBlock x:Name="DownloadSize" FontSize="20" Padding="0 0 0 3"/>
|
||||
|
||||
<ItemsControl Padding="0 3 0 6" x:Name="ModsList">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<ScrollViewer />
|
||||
<StackPanel/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
|
||||
<ItemsControl.ItemTemplateSelector>
|
||||
<DataTemplateSelector x:Name="DataTemplateSelector"/>
|
||||
</ItemsControl.ItemTemplateSelector>
|
||||
|
||||
</ItemsControl>-->
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="0 3 0 3">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
<ColumnDefinition Width="Auto"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="Auto"/>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="0" FontSize="16" Text="{Binding Path=Name}" Style="{StaticResource ModTitleStyle}"/>
|
||||
<TextBlock Padding="3 0 0 0" Grid.Column="1" Grid.Row="0" FontSize="16">
|
||||
<Hyperlink NavigateUri="{Binding Path=Name}" Style="{StaticResource HyperlinkStyle}" RequestNavigate="Hyperlink_OnRequestNavigate">Link</Hyperlink>
|
||||
</TextBlock>
|
||||
<TextBlock Padding="6 0 0 0" Grid.Column="0" Grid.Row="1" FontSize="12" Text="{Binding Path=Hash}"/>
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
</reactiveUi:ReactiveUserControl>
|
||||
|
@ -1,7 +1,13 @@
|
||||
using System.Reactive.Disposables;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Reactive.Disposables;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Navigation;
|
||||
using Microsoft.VisualBasic.CompilerServices;
|
||||
using ReactiveUI;
|
||||
using Wabbajack.Lib;
|
||||
using Wabbajack.View_Models;
|
||||
using Wabbajack.Lib.Downloaders;
|
||||
using Utils = Wabbajack.Common.Utils;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -12,14 +18,42 @@ namespace Wabbajack
|
||||
public ManifestView(ModList modlist)
|
||||
{
|
||||
Modlist = modlist;
|
||||
|
||||
var manifest = new Manifest(modlist);
|
||||
if(ViewModel == null)
|
||||
ViewModel = new ManifestVM(manifest);
|
||||
|
||||
InitializeComponent();
|
||||
ViewModel = new ManifestVM(modlist);
|
||||
|
||||
this.WhenActivated(disposable =>
|
||||
{
|
||||
this.Bind(ViewModel, x => x.Manifest.Name, x => x.Name.Text)
|
||||
this.OneWayBind(ViewModel, x => x.Name, x => x.Name.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Author, x => x.Author.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Description, x => x.Description.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.Archives, x => x.ModsList.ItemsSource)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.InstallSize, x => x.InstallSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
this.OneWayBind(ViewModel, x => x.DownloadSize, x => x.DownloadSize.Text)
|
||||
.DisposeWith(disposable);
|
||||
});
|
||||
}
|
||||
|
||||
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
||||
{
|
||||
if (!(sender is Hyperlink hyperlink)) return;
|
||||
if (!(hyperlink.DataContext is Archive archive)) return;
|
||||
|
||||
var url = archive.State.GetManifestURL(archive);
|
||||
if (string.IsNullOrWhiteSpace(url)) return;
|
||||
|
||||
//url = url.Replace("&", "^&");
|
||||
Process.Start(new ProcessStartInfo("cmd", $"/c start {url}") {CreateNoWindow = true});
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,22 @@
|
||||
<Window x:Class="Wabbajack.ManifestWindow"
|
||||
<mah:MetroWindow x:Class="Wabbajack.ManifestWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
xmlns:mah="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
Title="ManifestWindow" Height="450" Width="800" d:DataContext="{d:DesignInstance local:ManifestWindow }">
|
||||
Title="Manifest"
|
||||
Width="1280"
|
||||
Height="960"
|
||||
MinWidth="850"
|
||||
MinHeight="650"
|
||||
ResizeMode="CanResize"
|
||||
TitleBarHeight="25"
|
||||
UseLayoutRounding="True"
|
||||
WindowTitleBrush="{StaticResource MahApps.Brushes.Accent}"
|
||||
Style="{StaticResource {x:Type Window}}"
|
||||
d:DataContext="{d:DesignInstance local:ManifestWindow }">
|
||||
<Grid x:Name="Grid">
|
||||
</Grid>
|
||||
</Window>
|
||||
</mah:MetroWindow>
|
||||
|
@ -9,8 +9,14 @@ namespace Wabbajack
|
||||
public ManifestWindow(ModList modlist)
|
||||
{
|
||||
Modlist = modlist;
|
||||
|
||||
InitializeComponent();
|
||||
Grid.Children.Add(new ManifestView(Modlist));
|
||||
|
||||
var manifestView = new ManifestView(Modlist);
|
||||
|
||||
Grid.Children.Add(manifestView);
|
||||
|
||||
Title = $"{Modlist.Name} by {Modlist.Author}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user