Removed readme as file option

This commit is contained in:
erri120 2020-04-15 19:40:41 +02:00
parent f8321f273a
commit a3305b08fe
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
13 changed files with 24 additions and 202 deletions

View File

@ -9,19 +9,14 @@ using Wabbajack.Common;
using Wabbajack.Lib.CompilationSteps;
using Wabbajack.Lib.Downloaders;
using Wabbajack.Lib.ModListRegistry;
using Wabbajack.Lib.Validation;
using Wabbajack.VirtualFileSystem;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;
namespace Wabbajack.Lib
{
public abstract class ACompiler : ABatchProcessor
{
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite;
public AbsolutePath ModListImage, ModListReadme;
public bool ReadmeIsWebsite;
public string? ModListName, ModListAuthor, ModListDescription, ModListWebsite, ModlistReadme;
public AbsolutePath ModListImage;
protected Version? WabbajackVersion;
public abstract AbsolutePath VFSCacheName { get; }
@ -136,12 +131,6 @@ namespace Wabbajack.Lib
{
ModList.Image = (RelativePath)"modlist-image.png";
}
if (ModListReadme.Exists)
{
ModList.Readme = $"readme{ModListReadme.Extension}";
}
ModList.ReadmeIsWebsite = ReadmeIsWebsite;
using (var of = ModListOutputFolder.Combine("modlist").Create())
ModList.ToJson(of);
@ -172,17 +161,6 @@ namespace Wabbajack.Lib
ins.CopyTo(os);
}
}
// Copy in readme
if (ModListReadme.Exists)
{
var ze = za.CreateEntry(ModList.Readme);
using (var os = ze.Open())
using (var ins = ModListReadme.OpenRead())
{
ins.CopyTo(os);
}
}
}
}

View File

@ -18,7 +18,7 @@ namespace Wabbajack.Lib.CompilationSteps
{
var files = new HashSet<AbsolutePath>
{
_compiler.ModListImage, _compiler.ModListReadme
_compiler.ModListImage
};
if (!files.Any(f => source.AbsolutePath.Equals(f))) return null;
if (!source.AbsolutePath.Exists) return null;
@ -31,11 +31,6 @@ namespace Wabbajack.Lib.CompilationSteps
result.Type = PropertyType.Banner;
_compiler.ModListImage = result.SourceDataID.RelativeTo(_compiler.ModListOutputFolder);
}
else
{
result.Type = PropertyType.Readme;
_compiler.ModListReadme = result.SourceDataID.RelativeTo(_compiler.ModListOutputFolder);
}
return result;
}

View File

@ -81,15 +81,10 @@ namespace Wabbajack.Lib
public string Name = string.Empty;
/// <summary>
/// readme path or website
/// URL to the readme
/// </summary>
public string Readme = string.Empty;
/// <summary>
/// Whether readme is a website
/// </summary>
public bool ReadmeIsWebsite;
/// <summary>
/// The build version of Wabbajack used when compiling the Modlist
/// </summary>

View File

@ -301,7 +301,7 @@ namespace Wabbajack.Lib
Name = ModListName ?? MO2Profile,
Author = ModListAuthor ?? "",
Description = ModListDescription ?? "",
Readme = (string)ModListReadme,
Readme = ModlistReadme ?? "",
Image = ModListImage != default ? ModListImage.FileName : default,
Website = ModListWebsite != null ? new Uri(ModListWebsite) : null
};

View File

@ -122,7 +122,6 @@ namespace Wabbajack
public string Author { get; set; }
public string Description { get; set; }
public string Website { get; set; }
public bool ReadmeIsWebsite { get; set; }
public string Readme { get; set; }
public AbsolutePath SplashScreen { get; set; }
}

View File

@ -186,8 +186,7 @@ namespace Wabbajack
ModListDescription = ModlistSettings.Description,
ModListImage = ModlistSettings.ImagePath.TargetPath,
ModListWebsite = ModlistSettings.Website,
//ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
ModlistReadme = ModlistSettings.Readme,
MO2DownloadsFolder = DownloadLocation.TargetPath,
})
{

View File

@ -11,7 +11,7 @@ namespace Wabbajack
{
public class ModlistSettingsEditorVM : ViewModel
{
private CompilationModlistSettings _settings;
private readonly CompilationModlistSettings _settings;
[Reactive]
public string ModListName { get; set; }
@ -24,49 +24,28 @@ namespace Wabbajack
public FilePickerVM ImagePath { get; }
public FilePickerVM ReadmeFilePath { get; }
[Reactive]
public string ReadmeWebsite { get; set; }
public string Readme { get; set; }
[Reactive]
public string Website { get; set; }
[Reactive]
public bool ReadmeIsWebsite { get; set; }
public IObservable<bool> InError { get; }
public ICommand SwapToTextReadmeCommand { get; }
public ICommand SwapToWebsiteReadmeCommand { get; }
public ModlistSettingsEditorVM(CompilationModlistSettings settings)
{
this._settings = settings;
_settings = settings;
ImagePath = new FilePickerVM()
{
ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty,
PathType = FilePickerVM.PathTypeOptions.File,
};
ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png"));
ReadmeFilePath = new FilePickerVM()
{
PathType = FilePickerVM.PathTypeOptions.File,
ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty,
};
ReadmeFilePath.Filters.Add(new CommonFileDialogFilter("Text", "*.txt"));
ReadmeFilePath.Filters.Add(new CommonFileDialogFilter("HTML File", "*.html"));
InError = Observable.CombineLatest(
this.WhenAny(x => x.ImagePath.ErrorState).Select(err => err.Failed),
this.WhenAny(x => x.ReadmeFilePath.ErrorState).Select(err => err.Failed),
this.WhenAny(x => x.ReadmeIsWebsite),
resultSelector: (img, readme, isWebsite) => img || (readme && !isWebsite))
InError = this.WhenAny(x => x.ImagePath.ErrorState)
.Select(err => err.Failed)
.Publish()
.RefCount();
SwapToTextReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = false);
SwapToWebsiteReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = true);
}
public void Init()
@ -77,17 +56,7 @@ namespace Wabbajack
ModListName = _settings.ModListName;
}
Description = _settings.Description;
ReadmeIsWebsite = _settings.ReadmeIsWebsite;
if (ReadmeIsWebsite)
{
// TODO README
// ReadmeWebsite = _settings.Readme;
}
else
{
// TODO README
//ReadmeFilePath.TargetPath = _settings.Readme;
}
Readme = _settings.Readme;
ImagePath.TargetPath = _settings.SplashScreen;
Website = _settings.Website;
}
@ -97,16 +66,7 @@ namespace Wabbajack
_settings.Author = AuthorText;
_settings.ModListName = ModListName;
_settings.Description = Description;
_settings.ReadmeIsWebsite = ReadmeIsWebsite;
if (ReadmeIsWebsite)
{
_settings.Readme = ReadmeWebsite;
}
else
{
// TODO README
//_settings.Readme = ReadmeFilePath.TargetPath;
}
_settings.Readme = Readme;
_settings.SplashScreen = ImagePath.TargetPath;
_settings.Website = Website;
}

View File

@ -199,7 +199,7 @@ namespace Wabbajack
ModListDescription = ModlistSettings.Description,
ModListImage = ModlistSettings.ImagePath.TargetPath,
ModListWebsite = ModlistSettings.Website,
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.Readme : ModlistSettings.ReadmeFilePath.TargetPath,
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
})
{

View File

@ -102,7 +102,7 @@ namespace Wabbajack
{
try
{
modList.OpenReadmeWindow();
modList.OpenReadme();
}
catch (Exception ex)
{

View File

@ -313,7 +313,7 @@ namespace Wabbajack
new ManifestWindow(ModList.SourceModList).Show();
});
OpenReadmeCommand = ReactiveCommand.Create(
execute: () => this.ModList?.OpenReadmeWindow(),
execute: () => this.ModList?.OpenReadme(),
canExecute: this.WhenAny(x => x.ModList)
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
.ObserveOnGuiThread());
@ -367,7 +367,7 @@ namespace Wabbajack
Completed = ErrorResponse.Create(success);
try
{
this.ModList?.OpenReadmeWindow();
this.ModList?.OpenReadme();
}
catch (Exception ex)
{

View File

@ -1,6 +1,5 @@
using ReactiveUI;
using System;
using System.Diagnostics;
using System.IO;
using System.IO.Compression;
using System.Reactive;
@ -89,37 +88,10 @@ namespace Wabbajack
.RefCount();
}
public void OpenReadmeWindow()
public void OpenReadme()
{
if (string.IsNullOrEmpty(Readme)) return;
if (SourceModList.ReadmeIsWebsite)
{
Utils.OpenWebsite(new Uri(Readme));
}
else
{
using var fs = ModListPath.OpenShared();
using var ar = new ZipArchive(fs, ZipArchiveMode.Read);
using var ms = new MemoryStream();
var entry = ar.GetEntry(Readme);
if (entry == null)
{
Utils.Log($"Tried to open a non-existent readme: {Readme}");
return;
}
using (var e = entry.Open())
{
e.CopyTo(ms);
}
ms.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(ms);
var viewer = new TextViewer(reader.ReadToEnd(), Name);
viewer.Show();
}
Utils.OpenWebsite(new Uri(Readme));
}
public override void Dispose()
@ -127,7 +99,7 @@ namespace Wabbajack
base.Dispose();
// Just drop reference explicitly, as it's large, so it can be GCed
// Even if someone is holding a stale reference to the VM
this.SourceModList = null;
SourceModList = null;
}
}
}

View File

@ -107,7 +107,7 @@
x:Key="ValueStyle"
BasedOn="{StaticResource MainTextBoxStyle}"
TargetType="TextBox">
<Setter Property="MaxLength" Value="50" />
<Setter Property="MaxLength" Value="150" />
<Setter Property="AcceptsTab" Value="False" />
<Setter Property="FontSize" Value="15" />
<Setter Property="Margin" Value="0,0,0,6" />
@ -143,66 +143,8 @@
<TextBlock
Margin="{StaticResource TitleMargin}"
Text="Readme"
ToolTip="Path to a readme file." />
<Grid Margin="0,0,0,6">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<local:FilePicker
x:Name="ReadmeFilePickerSetting"
Grid.Column="0"
Height="27"
Margin="0,0,3,0"
VerticalAlignment="Center"
ToolTip="Path to a readme file." />
<TextBox
x:Name="ReadmeWebsiteSetting"
Grid.Column="0"
Height="27"
Margin="0,0,3,0"
VerticalAlignment="Center"
ToolTip="Readme website" />
<Button
x:Name="SwapToReadmeWebsiteButton"
Grid.Column="1"
Width="27"
ToolTip="Set readme to be a website">
<Button.Style>
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CurrentModlistSettings.ReadmeIsWebsite}" Value="True">
<Setter Property="Foreground" Value="{StaticResource SecondaryBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<icon:PackIconMaterial
Width="20"
Height="20"
Kind="Web" />
</Button>
<Button
x:Name="SwapToReadmeFileButton"
Grid.Column="2"
Width="27"
ToolTip="Source readme from a local file (txt | html)">
<Button.Style>
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding CurrentModlistSettings.ReadmeIsWebsite}" Value="False">
<Setter Property="Foreground" Value="{StaticResource SecondaryBrush}" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
<icon:PackIconMaterial
Width="20"
Height="20"
Kind="File" />
</Button>
</Grid>
ToolTip="Link to the Readme." />
<TextBox x:Name="ReadmeSetting" Style="{StaticResource ValueStyle}"/>
</StackPanel>
</ScrollViewer>
<Border

View File

@ -72,25 +72,7 @@ namespace Wabbajack
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Website, x => x.WebsiteSetting.Text)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.ReadmeFilePath)
.BindToStrict(this, x => x.ReadmeFilePickerSetting.PickerVM)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.ReadmeIsWebsite)
.Select(isWebsite => isWebsite ? Visibility.Collapsed : Visibility.Visible)
.BindToStrict(this, x => x.ReadmeFilePickerSetting.Visibility)
.DisposeWith(dispose);
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.ReadmeWebsite, x => x.ReadmeWebsiteSetting.Text)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.ReadmeIsWebsite)
.Select(isWebsite => isWebsite ? Visibility.Visible : Visibility.Collapsed)
.BindToStrict(this, x => x.ReadmeWebsiteSetting.Visibility)
.DisposeWith(dispose);
this.MarkAsNeeded<CompilerView, CompilerVM, bool>(this.ViewModel, x => x.CurrentModlistSettings.ReadmeIsWebsite);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.SwapToWebsiteReadmeCommand)
.BindToStrict(this, x => x.SwapToReadmeWebsiteButton.Command)
.DisposeWith(dispose);
this.WhenAny(x => x.ViewModel.CurrentModlistSettings.SwapToTextReadmeCommand)
.BindToStrict(this, x => x.SwapToReadmeFileButton.Command)
this.BindStrict(this.ViewModel, x => x.CurrentModlistSettings.Readme, x => x.ReadmeSetting.Text)
.DisposeWith(dispose);
// Bottom Compiler Settings