mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Modlist image and readme embedded in .wabbajack and displayable
This commit is contained in:
parent
57c421967d
commit
b74c8bf544
@ -81,6 +81,18 @@ namespace Wabbajack.Lib
|
|||||||
{
|
{
|
||||||
Utils.Log($"Exporting ModList to : {ModListOutputFile}");
|
Utils.Log($"Exporting ModList to : {ModListOutputFile}");
|
||||||
|
|
||||||
|
// Modify readme and modlist image to relative paths if they exist
|
||||||
|
var modlistImage = new FileInfo(ModListImage);
|
||||||
|
var readme = new FileInfo(ModListReadme);
|
||||||
|
if (modlistImage.Exists)
|
||||||
|
{
|
||||||
|
ModList.Image = "modlist-image.png";
|
||||||
|
}
|
||||||
|
if (readme.Exists)
|
||||||
|
{
|
||||||
|
ModList.Readme = $"readme{readme.Extension}";
|
||||||
|
}
|
||||||
|
|
||||||
//ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json"));
|
//ModList.ToJSON(Path.Combine(ModListOutputFolder, "modlist.json"));
|
||||||
ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), ref CerasConfig.Config);
|
ModList.ToCERAS(Path.Combine(ModListOutputFolder, "modlist"), ref CerasConfig.Config);
|
||||||
|
|
||||||
@ -102,6 +114,28 @@ namespace Wabbajack.Lib
|
|||||||
ins.CopyTo(os);
|
ins.CopyTo(os);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Copy in modimage
|
||||||
|
if (modlistImage.Exists)
|
||||||
|
{
|
||||||
|
var ze = za.CreateEntry(ModList.Image);
|
||||||
|
using (var os = ze.Open())
|
||||||
|
using (var ins = File.OpenRead(ModListImage))
|
||||||
|
{
|
||||||
|
ins.CopyTo(os);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Copy in readme
|
||||||
|
if (readme.Exists)
|
||||||
|
{
|
||||||
|
var ze = za.CreateEntry(ModList.Readme);
|
||||||
|
using (var os = ze.Open())
|
||||||
|
using (var ins = File.OpenRead(ModListReadme))
|
||||||
|
{
|
||||||
|
ins.CopyTo(os);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,6 +40,10 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
PathType = FilePickerVM.PathTypeOptions.File,
|
PathType = FilePickerVM.PathTypeOptions.File,
|
||||||
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
ExistCheckOption = FilePickerVM.ExistCheckOptions.IfNotEmpty,
|
||||||
|
Filters =
|
||||||
|
{
|
||||||
|
new CommonFileDialogFilter("Text", "*.txt"),
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.IO.Compression;
|
using System.IO.Compression;
|
||||||
|
using System.Reactive;
|
||||||
using System.Reactive.Linq;
|
using System.Reactive.Linq;
|
||||||
using System.Windows.Media.Imaging;
|
using System.Windows.Media.Imaging;
|
||||||
using Wabbajack.Common;
|
using Wabbajack.Common;
|
||||||
@ -16,7 +17,6 @@ namespace Wabbajack
|
|||||||
public string Name => SourceModList.Name;
|
public string Name => SourceModList.Name;
|
||||||
public string ReportHTML => SourceModList.ReportHTML;
|
public string ReportHTML => SourceModList.ReportHTML;
|
||||||
public string Readme => SourceModList.Readme;
|
public string Readme => SourceModList.Readme;
|
||||||
public string ImageURL => SourceModList.Image;
|
|
||||||
public string Author => SourceModList.Author;
|
public string Author => SourceModList.Author;
|
||||||
public string Description => SourceModList.Description;
|
public string Description => SourceModList.Description;
|
||||||
public string Website => SourceModList.Website;
|
public string Website => SourceModList.Website;
|
||||||
@ -32,20 +32,18 @@ namespace Wabbajack
|
|||||||
ModListPath = modListPath;
|
ModListPath = modListPath;
|
||||||
SourceModList = sourceModList;
|
SourceModList = sourceModList;
|
||||||
|
|
||||||
ImageObservable = Observable.Return(ImageURL)
|
ImageObservable = Observable.Return(Unit.Default)
|
||||||
.ObserveOn(RxApp.TaskpoolScheduler)
|
.ObserveOn(RxApp.TaskpoolScheduler)
|
||||||
.Select(url =>
|
.Select(filePath =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!File.Exists(url)) return default(MemoryStream);
|
|
||||||
if (string.IsNullOrWhiteSpace(sourceModList.Image)) return default(MemoryStream);
|
|
||||||
if (sourceModList.Image.Length != 36) return default(MemoryStream);
|
|
||||||
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
using (var fs = new FileStream(ModListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||||
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
|
||||||
{
|
{
|
||||||
var ms = new MemoryStream();
|
var ms = new MemoryStream();
|
||||||
var entry = ar.GetEntry(sourceModList.Image);
|
var entry = ar.GetEntry("modlist-image.png");
|
||||||
|
if (entry == null) return default(MemoryStream);
|
||||||
using (var e = entry.Open())
|
using (var e = entry.Open())
|
||||||
{
|
{
|
||||||
e.CopyTo(ms);
|
e.CopyTo(ms);
|
||||||
|
@ -146,7 +146,7 @@
|
|||||||
Style="{StaticResource PickerStyle}"
|
Style="{StaticResource PickerStyle}"
|
||||||
ToolTip="Path to an image to display for the modlist." />
|
ToolTip="Path to an image to display for the modlist." />
|
||||||
<TextBlock Margin="{StaticResource TitleMargin}" Text="Website" />
|
<TextBlock Margin="{StaticResource TitleMargin}" Text="Website" />
|
||||||
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding Website}" />
|
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding Website, UpdateSourceTrigger=PropertyChanged}" />
|
||||||
<TextBlock
|
<TextBlock
|
||||||
Margin="{StaticResource TitleMargin}"
|
Margin="{StaticResource TitleMargin}"
|
||||||
Text="Readme Path"
|
Text="Readme Path"
|
||||||
|
Loading…
Reference in New Issue
Block a user