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; private ModlistPropertiesWindow modlistPropertiesWindow;
public string newImagePath; public string newImagePath;
public string readmePath;
public bool ChangedProperties; public bool ChangedProperties;
private void OpenModListProperties() private void OpenModListProperties()
{ {
@ -239,8 +240,43 @@ namespace Wabbajack
OpenModListProperties(); 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; private bool _uiReady = false;
public bool UIReady public bool UIReady
@ -371,7 +407,6 @@ namespace Wabbajack
SplashScreenSummary = _modList.Description; SplashScreenSummary = _modList.Description;
if (!string.IsNullOrEmpty(_modList.Image) && _modList.Image.Length == 36) if (!string.IsNullOrEmpty(_modList.Image) && _modList.Image.Length == 36)
{ {
//TODO: if(_modList.Image != null) SplashScreenImage = _modList.Image;
SplashScreenImage = _wabbajackLogo; SplashScreenImage = _wabbajackLogo;
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))
@ -503,8 +538,9 @@ namespace Wabbajack
ModListName = ChangedProperties ? SplashScreenModName : null, ModListName = ChangedProperties ? SplashScreenModName : null,
ModListAuthor = ChangedProperties ? SplashScreenAuthorName : null, ModListAuthor = ChangedProperties ? SplashScreenAuthorName : null,
ModListDescription = ChangedProperties ? SplashScreenSummary : null, ModListDescription = ChangedProperties ? SplashScreenSummary : null,
ModListImage = ChangedProperties ? newImagePath ?? null : null, ModListImage = ChangedProperties ? newImagePath : null,
ModListWebsite = ChangedProperties ? _nexusSiteURL : null ModListWebsite = ChangedProperties ? _nexusSiteURL : null,
ModListReadme = ChangedProperties ? readmePath : null
}; };
var th = new Thread(() => 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 Grid.Row="1" Grid.Column="0" Margin="0,0,2,4" Name="PropertyInstallerGrid">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Grid.Row="0" Source="{Binding SplashScreenImage}" Stretch="Fill"/> <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> </Grid>
<!-- End Properties --> <!-- End Properties -->

View File

@ -11,44 +11,50 @@
Closing="Window_Closing"> Closing="Window_Closing">
<Grid Margin="8"> <Grid Margin="8">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="*"/> <RowDefinition Height="300"/>
<RowDefinition Height="30"/>
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
<ColumnDefinition Width="450"/> <ColumnDefinition Width="*"/>
<ColumnDefinition Width="430"/> <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<Grid Grid.Column="0" Grid.Row="0" Margin="5"> <Grid Grid.Column="0" Grid.Row="0" Margin="5">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="289"/> <RowDefinition Height="*"/>
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<Image Grid.Row="0" Stretch="Uniform" Name="SplashScreenProperty"/> <Image Grid.Row="0" Stretch="Fill" Name="SplashScreenProperty"/>
<Button Grid.Row="1" Height="30" Click="SetSplashScreen_Click" ToolTip="Use a 1400x900 png file for the best results"> <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"/> <TextBlock Text="Change splash screen image" FontSize="15" FontWeight="Bold"/>
</Button> </Button>
</Grid> </Grid>
<Grid Grid.Column="1" Grid.Row="0" Margin="0 5 0 5"> <Grid Grid.Column="1" Grid.Row="0" Margin="0 5 0 5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="423*"/>
<ColumnDefinition Width="17*"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
<RowDefinition Height="30"/> <RowDefinition Height="30"/>
<RowDefinition Height="234"/> <RowDefinition Height="*"/>
</Grid.RowDefinitions> </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="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="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> </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"/> <TextBlock Text="Save" FontSize="15" FontWeight="Bold"/>
</Button> </Button>
</Grid> </Grid>

View File

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