mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Readme can be website now
This commit is contained in:
parent
74bbb5a4ec
commit
f26747bfe5
@ -22,6 +22,7 @@ namespace Wabbajack.Lib
|
||||
public abstract class ACompiler : ABatchProcessor
|
||||
{
|
||||
public string ModListName, ModListAuthor, ModListDescription, ModListImage, ModListWebsite, ModListReadme;
|
||||
public bool ReadmeIsWebsite;
|
||||
public string WabbajackVersion;
|
||||
|
||||
protected static string _vfsCacheName = "vfs_compile_cache.bin";
|
||||
@ -94,6 +95,8 @@ namespace Wabbajack.Lib
|
||||
ModList.Readme = $"readme{readme.Extension}";
|
||||
}
|
||||
|
||||
ModList.ReadmeIsWebsite = ReadmeIsWebsite;
|
||||
|
||||
//ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json"));
|
||||
ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), ref CerasConfig.Config);
|
||||
|
||||
|
@ -87,10 +87,15 @@ namespace Wabbajack.Lib
|
||||
public string Website;
|
||||
|
||||
/// <summary>
|
||||
/// Hash of the readme
|
||||
/// readme path or website
|
||||
/// </summary>
|
||||
public string Readme;
|
||||
|
||||
/// <summary>
|
||||
/// Whether readme is a website
|
||||
/// </summary>
|
||||
public bool ReadmeIsWebsite;
|
||||
|
||||
/// <summary>
|
||||
/// Content Report in HTML form
|
||||
/// </summary>
|
||||
|
@ -75,6 +75,7 @@ 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 string SplashScreen { get; set; }
|
||||
}
|
||||
|
@ -191,7 +191,8 @@ namespace Wabbajack
|
||||
ModListDescription = ModlistSettings.Description,
|
||||
ModListImage = ModlistSettings.ImagePath.TargetPath,
|
||||
ModListWebsite = ModlistSettings.Website,
|
||||
ModListReadme = ModlistSettings.ReadMeText.TargetPath,
|
||||
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
|
||||
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
|
||||
};
|
||||
await ActiveCompilation.Begin();
|
||||
}
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System;
|
||||
using System.Reactive.Linq;
|
||||
using System.Windows.Input;
|
||||
using DynamicData;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using ReactiveUI;
|
||||
using ReactiveUI.Fody.Helpers;
|
||||
using Wabbajack.Lib;
|
||||
|
||||
@ -22,13 +24,22 @@ namespace Wabbajack
|
||||
|
||||
public FilePickerVM ImagePath { get; }
|
||||
|
||||
public FilePickerVM ReadMeText { get; }
|
||||
public FilePickerVM ReadmeFilePath { get; }
|
||||
|
||||
[Reactive]
|
||||
public string ReadmeWebsite { 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;
|
||||
@ -38,19 +49,24 @@ namespace Wabbajack
|
||||
PathType = FilePickerVM.PathTypeOptions.File,
|
||||
};
|
||||
ImagePath.Filters.Add(new CommonFileDialogFilter("Banner image", "*.png"));
|
||||
ReadMeText = new FilePickerVM()
|
||||
ReadmeFilePath = new FilePickerVM()
|
||||
{
|
||||
PathType = FilePickerVM.PathTypeOptions.File,
|
||||
ExistCheckOption = FilePickerVM.CheckOptions.IfPathNotEmpty,
|
||||
};
|
||||
ReadMeText.Filters.Add(new CommonFileDialogFilter("Text", "*.txt"));
|
||||
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.ReadMeText.ErrorState).Select(err => err.Failed),
|
||||
resultSelector: (img, readme) => img || readme)
|
||||
this.WhenAny(x => x.ReadmeFilePath.ErrorState).Select(err => err.Failed),
|
||||
this.WhenAny(x => x.ReadmeIsWebsite),
|
||||
resultSelector: (img, readme, isWebsite) => img || (readme && isWebsite))
|
||||
.Publish()
|
||||
.RefCount();
|
||||
|
||||
SwapToTextReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = false);
|
||||
SwapToWebsiteReadmeCommand = ReactiveCommand.Create(() => ReadmeIsWebsite = true);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
@ -61,7 +77,15 @@ namespace Wabbajack
|
||||
ModListName = _settings.ModListName;
|
||||
}
|
||||
Description = _settings.Description;
|
||||
ReadMeText.TargetPath = _settings.Readme;
|
||||
ReadmeIsWebsite = _settings.ReadmeIsWebsite;
|
||||
if (ReadmeIsWebsite)
|
||||
{
|
||||
ReadmeWebsite = _settings.Readme;
|
||||
}
|
||||
else
|
||||
{
|
||||
ReadmeFilePath.TargetPath = _settings.Readme;
|
||||
}
|
||||
ImagePath.TargetPath = _settings.SplashScreen;
|
||||
Website = _settings.Website;
|
||||
}
|
||||
@ -71,7 +95,15 @@ namespace Wabbajack
|
||||
_settings.Author = AuthorText;
|
||||
_settings.ModListName = ModListName;
|
||||
_settings.Description = Description;
|
||||
_settings.Readme = ReadMeText.TargetPath;
|
||||
_settings.ReadmeIsWebsite = ReadmeIsWebsite;
|
||||
if (ReadmeIsWebsite)
|
||||
{
|
||||
_settings.Readme = ReadmeWebsite;
|
||||
}
|
||||
else
|
||||
{
|
||||
_settings.Readme = ReadmeFilePath.TargetPath;
|
||||
}
|
||||
_settings.SplashScreen = ImagePath.TargetPath;
|
||||
_settings.Website = Website;
|
||||
}
|
||||
|
@ -204,7 +204,8 @@ namespace Wabbajack
|
||||
ModListDescription = ModlistSettings.Description,
|
||||
ModListImage = ModlistSettings.ImagePath.TargetPath,
|
||||
ModListWebsite = ModlistSettings.Website,
|
||||
ModListReadme = ModlistSettings.ReadMeText.TargetPath,
|
||||
ModListReadme = ModlistSettings.ReadmeIsWebsite ? ModlistSettings.ReadmeWebsite : ModlistSettings.ReadmeFilePath.TargetPath,
|
||||
ReadmeIsWebsite = ModlistSettings.ReadmeIsWebsite,
|
||||
};
|
||||
await ActiveCompilation.Begin();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
using ReactiveUI;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.IO.Compression;
|
||||
using System.Reactive;
|
||||
@ -86,25 +87,32 @@ namespace Wabbajack
|
||||
public void OpenReadmeWindow()
|
||||
{
|
||||
if (string.IsNullOrEmpty(Readme)) return;
|
||||
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||
using (var ms = new MemoryStream())
|
||||
if (SourceModList.ReadmeIsWebsite)
|
||||
{
|
||||
var entry = ar.GetEntry(Readme);
|
||||
if (entry == null)
|
||||
Process.Start(Readme);
|
||||
}
|
||||
else
|
||||
{
|
||||
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
Utils.Log($"Tried to open a non-existant 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();
|
||||
var entry = ar.GetEntry(Readme);
|
||||
if (entry == null)
|
||||
{
|
||||
Utils.Log($"Tried to open a non-existant 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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,12 +150,69 @@
|
||||
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding Website, UpdateSourceTrigger=PropertyChanged}" />
|
||||
<TextBlock
|
||||
Margin="{StaticResource TitleMargin}"
|
||||
Text="Readme Path"
|
||||
ToolTip="Path to a readme file." />
|
||||
<local:FilePicker
|
||||
PickerVM="{Binding ReadMeText}"
|
||||
Style="{StaticResource PickerStyle}"
|
||||
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
|
||||
Grid.Column="0"
|
||||
Height="27"
|
||||
Margin="0,0,3,0"
|
||||
VerticalAlignment="Center"
|
||||
PickerVM="{Binding ReadmeFilePath}"
|
||||
ToolTip="Path to a readme file."
|
||||
Visibility="{Binding ReadmeIsWebsite, Converter={StaticResource bool2VisibilityConverter}, ConverterParameter=False}" />
|
||||
<TextBox
|
||||
Grid.Column="0"
|
||||
Height="27"
|
||||
Margin="0,0,3,0"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding ReadmeWebsite}"
|
||||
ToolTip="Readme website"
|
||||
Visibility="{Binding ReadmeIsWebsite, Converter={StaticResource bool2VisibilityConverter}}" />
|
||||
<Button
|
||||
Grid.Column="1"
|
||||
Width="27"
|
||||
Command="{Binding SwapToWebsiteReadmeCommand}"
|
||||
ToolTip="Set readme to be a website">
|
||||
<Button.Style>
|
||||
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding 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
|
||||
Grid.Column="2"
|
||||
Width="27"
|
||||
Command="{Binding SwapToTextReadmeCommand}"
|
||||
ToolTip="Source readme from a local file (txt | html)">
|
||||
<Button.Style>
|
||||
<Style BasedOn="{StaticResource IconBareButtonStyle}" TargetType="Button">
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding 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>
|
||||
</StackPanel>
|
||||
</ScrollViewer>
|
||||
<Border
|
||||
|
Loading…
Reference in New Issue
Block a user