Readme is now readable when installing

This commit is contained in:
erri120 2019-10-11 14:57:42 +02:00
parent 9b428aefdc
commit 299f22b1fc
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
4 changed files with 78 additions and 26 deletions

View File

@ -219,6 +219,7 @@ namespace Wabbajack
private ModlistPropertiesWindow modlistPropertiesWindow;
public string newImagePath;
public string readmePath;
public bool ChangedProperties;
private void OpenModListProperties()
{
@ -239,8 +240,43 @@ namespace Wabbajack
OpenModListProperties();
}
}
}
}
public bool HasReadme { get; set; }
public ICommand OpenReadme
{
get
{
return new LambdaCommand(()=> true,OpenReadmeWindow);
}
}
private void OpenReadmeWindow()
{
if (UIReady)
{
var text = "";
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())
{
var entry = ar.GetEntry(_modList.Readme);
using (var e = entry.Open())
e.CopyTo(ms);
ms.Seek(0, SeekOrigin.Begin);
using (var sr = new StreamReader(ms))
{
string line;
while ((line = sr.ReadLine()) != null)
text += line+Environment.NewLine;
//text = sr.ReadToEnd();
}
}
var viewer = new TextViewer(text);
viewer.Show();
}
}
private bool _uiReady = false;
public bool UIReady
@ -371,7 +407,6 @@ namespace Wabbajack
SplashScreenSummary = _modList.Description;
if (!string.IsNullOrEmpty(_modList.Image) && _modList.Image.Length == 36)
{
//TODO: if(_modList.Image != null) SplashScreenImage = _modList.Image;
SplashScreenImage = _wabbajackLogo;
using (var fs = new FileStream(_modListPath, FileMode.Open, FileAccess.Read, FileShare.Read))
using (var ar = new ZipArchive(fs, ZipArchiveMode.Read))
@ -503,8 +538,9 @@ namespace Wabbajack
ModListName = ChangedProperties ? SplashScreenModName : null,
ModListAuthor = ChangedProperties ? SplashScreenAuthorName : null,
ModListDescription = ChangedProperties ? SplashScreenSummary : null,
ModListImage = ChangedProperties ? newImagePath ?? null : null,
ModListWebsite = ChangedProperties ? _nexusSiteURL : null
ModListImage = ChangedProperties ? newImagePath : null,
ModListWebsite = ChangedProperties ? _nexusSiteURL : null,
ModListReadme = ChangedProperties ? readmePath : null
};
var th = new Thread(() =>
{

View File

@ -49,8 +49,12 @@
<Grid Grid.Row="1" Grid.Column="0" Margin="0,0,2,4" Name="PropertyInstallerGrid">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Image Grid.Row="0" Source="{Binding SplashScreenImage}" Stretch="Fill"/>
<Button Grid.Row="1" Height="30" Command="{Binding OpenReadme}" IsEnabled="{Binding HadReadme}">
<TextBlock Text="Open README" FontSize="15" FontWeight="Bold"/>
</Button>
</Grid>
<!-- End Properties -->

View File

@ -11,44 +11,50 @@
Closing="Window_Closing">
<Grid Margin="8">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="300"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="450"/>
<ColumnDefinition Width="430"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Margin="5">
<Grid.RowDefinitions>
<RowDefinition Height="289"/>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Image Grid.Row="0" Stretch="Uniform" Name="SplashScreenProperty"/>
<Button Grid.Row="1" Height="30" Click="SetSplashScreen_Click" ToolTip="Use a 1400x900 png file for the best results">
<Image Grid.Row="0" Stretch="Fill" Name="SplashScreenProperty"/>
<Button Height="30" Grid.Row="1" Click="SetSplashScreen_Click" ToolTip="Use a 1400x900 png file for the best results">
<TextBlock Text="Change splash screen image" FontSize="15" FontWeight="Bold"/>
</Button>
</Grid>
<Grid Grid.Column="1" Grid.Row="0" Margin="0 5 0 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="423*"/>
<ColumnDefinition Width="17*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/>
<RowDefinition Height="234"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBox Grid.Row="0" Text="ModList Name" Name="ModlistNameProperty" ToolTip="Change the name of your ModList" MaxLength="50" AcceptsTab="False" FontSize="15" FontWeight="Bold" Margin="0,0,0,5"/>
<TextBox Grid.Row="1" Text="Author" Name="ModlistAuthorProperty" ToolTip="Change the name of the Author" MaxLength="50" AcceptsTab="False" FontSize="15" Margin="0 0 0 5" />
<TextBox Grid.Row="2" Text="Description (700 characters max)" Name="ModlistDescriptionProperty" ToolTip="Change the description" MaxLength="700" AcceptsReturn="True" TextWrapping="Wrap" AcceptsTab="False" FontSize="15" Margin="0,0,0,-23"/>
<TextBox Grid.Row="2" Text="Description (700 characters max)" Name="ModlistDescriptionProperty" ToolTip="Change the description" MaxLength="700" AcceptsReturn="True" TextWrapping="Wrap" AcceptsTab="False" FontSize="15" Margin="0,0,0,0"/>
</Grid>
<TextBox Grid.ColumnSpan="2" Text="Website" Name="ModlistWebsiteProperty" ToolTip="Change the website" MaxLength="80" AcceptsReturn="False" AcceptsTab="False" FontSize="15" Margin="5,328,17,128"/>
<TextBox Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Text="Website" Name="ModlistWebsiteProperty" ToolTip="Change the website" MaxLength="80" AcceptsReturn="False" AcceptsTab="False" FontSize="15"/>
<Grid Grid.Column="0" Grid.Row="2" Grid.ColumnSpan="2" Height="30" Margin="0,10,0,-10">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<TextBox Height="30" Grid.ColumnSpan="3" Text="Readme path" Name="ModlistReadmeProperty" AcceptsReturn="False" AcceptsTab="False" FontSize="15"/>
<Button Height="30" Grid.Column="2" Content="Choose" Click="ChooseReadme_Click"/>
</Grid>
<Button Grid.Row="2" Grid.ColumnSpan="2" Click="SaveProperties_Click">
<Button Grid.Column="0" Grid.Row="3" Grid.ColumnSpan="2" Click="SaveProperties_Click" Margin="0,160,0,-160" Height="30" VerticalAlignment="Bottom">
<TextBlock Text="Save" FontSize="15" FontWeight="Bold"/>
</Button>
</Grid>

View File

@ -47,15 +47,12 @@ namespace Wabbajack
state.newImagePath = newBannerFile;
state.SplashScreenImage = splashScreen;
}
string modListName = ModlistNameProperty.Text;
string modListAuthor = ModlistAuthorProperty.Text;
string modListDescription = ModlistDescriptionProperty.Text;
string modListWebsite = ModlistWebsiteProperty.Text;
state.SplashScreenModName = modListName;
state.SplashScreenSummary = modListDescription;
state.SplashScreenAuthorName = modListAuthor;
state._nexusSiteURL = modListWebsite;
state.SplashScreenModName = ModlistNameProperty.Text;
state.SplashScreenSummary = ModlistDescriptionProperty.Text;
state.SplashScreenAuthorName = ModlistAuthorProperty.Text;
state._nexusSiteURL = ModlistWebsiteProperty.Text;
state.readmePath = ModlistReadmeProperty.Text;
state.ChangedProperties = true;
@ -69,5 +66,14 @@ namespace Wabbajack
base.OnClosed(e);
IsClosed = true;
}
private void ChooseReadme_Click(object sender, RoutedEventArgs e)
{
var file = UIUtils.OpenFileDialog("Readme|*.txt");
if (file != null)
{
ModlistReadmeProperty.Text = file;
}
}
}
}