mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
stop patching exe files
This commit is contained in:
parent
7c4c2a586c
commit
f82d6a39f7
@ -2,7 +2,8 @@
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
StartupUri="MainWindow.xaml">
|
||||
StartupUri="ModeSelectionWindow.xaml"
|
||||
ShutdownMode="OnExplicitShutdown">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<ResourceDictionary.MergedDictionaries>
|
||||
|
@ -116,28 +116,6 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
|
||||
public bool IgnoreMissingFiles
|
||||
{
|
||||
get => _ignoreMissingFiles;
|
||||
set
|
||||
{
|
||||
if (value)
|
||||
{
|
||||
if (MessageBox.Show(
|
||||
"Setting this value could result in broken installations. \n Are you sure you want to continue?",
|
||||
"Ignore Missing Files?", MessageBoxButton.OKCancel, MessageBoxImage.Warning)
|
||||
== MessageBoxResult.OK)
|
||||
_ignoreMissingFiles = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_ignoreMissingFiles = value;
|
||||
}
|
||||
|
||||
OnPropertyChanged("IgnoreMissingFiles");
|
||||
}
|
||||
}
|
||||
|
||||
public string ModListName
|
||||
{
|
||||
get => _modListName;
|
||||
@ -360,7 +338,7 @@ namespace Wabbajack
|
||||
|
||||
private void UpdateLoop()
|
||||
{
|
||||
while (true)
|
||||
while (Running)
|
||||
{
|
||||
if (Dirty)
|
||||
lock (InternalStatus)
|
||||
@ -399,6 +377,8 @@ namespace Wabbajack
|
||||
}
|
||||
}
|
||||
|
||||
public bool Running { get; set; } = true;
|
||||
|
||||
internal void ConfigureForInstall(ModList modlist)
|
||||
{
|
||||
_modList = modlist;
|
||||
@ -503,7 +483,6 @@ namespace Wabbajack
|
||||
{
|
||||
var installer = new Installer(_modList, Location);
|
||||
|
||||
installer.IgnoreMissingFiles = IgnoreMissingFiles;
|
||||
installer.DownloadFolder = DownloadLocation;
|
||||
var th = new Thread(() =>
|
||||
{
|
||||
@ -530,7 +509,6 @@ namespace Wabbajack
|
||||
else if (_mo2Folder != null)
|
||||
{
|
||||
var compiler = new Compiler(_mo2Folder);
|
||||
compiler.IgnoreMissingFiles = IgnoreMissingFiles;
|
||||
compiler.MO2Profile = ModListName;
|
||||
var th = new Thread(() =>
|
||||
{
|
||||
|
@ -246,16 +246,34 @@ namespace Wabbajack
|
||||
};
|
||||
|
||||
GenerateReport();
|
||||
PatchExecutable();
|
||||
ExportModlist();
|
||||
|
||||
ResetMembers();
|
||||
|
||||
ShowReport();
|
||||
|
||||
Info("Done Building Modpack");
|
||||
Info("Done Building Modlist");
|
||||
return true;
|
||||
}
|
||||
|
||||
private void ExportModlist()
|
||||
{
|
||||
var out_path = MO2Profile + ".modlist";
|
||||
|
||||
Utils.Log($"Exporting Modlist to : {out_path}");
|
||||
|
||||
using (var os = File.OpenWrite(out_path))
|
||||
using (var bw = new BinaryWriter(os))
|
||||
{
|
||||
var formatter = new BinaryFormatter();
|
||||
using (var compressed = LZ4Stream.Encode(bw.BaseStream,
|
||||
new LZ4EncoderSettings { CompressionLevel = LZ4Level.L10_OPT }, true))
|
||||
{
|
||||
formatter.Serialize(compressed, ModList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ShowReport()
|
||||
{
|
||||
if (!ShowReportWhenFinished) return;
|
||||
@ -1141,15 +1159,6 @@ namespace Wabbajack
|
||||
{
|
||||
var orig_pos = os.Length;
|
||||
os.Position = os.Length;
|
||||
//using (var compressor = new BZip2OutputStream(bw.BaseStream))
|
||||
/*using (var sw = new StreamWriter(compressor))
|
||||
using (var writer = new JsonTextWriter(sw))
|
||||
{
|
||||
var serializer = new JsonSerializer();
|
||||
serializer.TypeNameHandling = TypeNameHandling.Auto;
|
||||
serializer.Serialize(writer, ModList);
|
||||
}*/
|
||||
//bw.Write(data);
|
||||
var formatter = new BinaryFormatter();
|
||||
|
||||
using (var compressed = LZ4Stream.Encode(bw.BaseStream,
|
||||
|
@ -357,7 +357,10 @@ namespace Wabbajack
|
||||
vfiles.DoIndexed((idx, file) =>
|
||||
{
|
||||
Utils.Status("Installing files", idx * 100 / vfiles.Count);
|
||||
File.Copy(file.FromFile.StagedPath, Path.Combine(Outputfolder, file.To));
|
||||
var dest = Path.Combine(Outputfolder, file.To);
|
||||
if (File.Exists(dest))
|
||||
File.Delete(dest);
|
||||
File.Copy(file.FromFile.StagedPath, dest);
|
||||
});
|
||||
|
||||
Status("Unstaging files");
|
||||
@ -578,7 +581,7 @@ namespace Wabbajack
|
||||
{
|
||||
var read = webs.Read(buffer, 0, buffer_size);
|
||||
if (read == 0) break;
|
||||
Status("Downloading {archive.Name}", (int)(total_read * 100 / content_size));
|
||||
Status($"Downloading {archive.Name}", (int)(total_read * 100 / content_size));
|
||||
|
||||
fs.Write(buffer, 0, read);
|
||||
total_read += read;
|
||||
@ -618,33 +621,30 @@ namespace Wabbajack
|
||||
return HashArchive(e);
|
||||
}
|
||||
|
||||
public static ModList CheckForModList()
|
||||
public static ModList LoadModlist(string file)
|
||||
{
|
||||
Utils.Log("Looking for attached modlist");
|
||||
using (var s = File.OpenRead(Assembly.GetExecutingAssembly().Location))
|
||||
Utils.Log("Reading Modlist, this may take a moment");
|
||||
try
|
||||
{
|
||||
var magic_bytes = Encoding.ASCII.GetBytes(Consts.ModListMagic);
|
||||
s.Position = s.Length - magic_bytes.Length;
|
||||
using (var br = new BinaryReader(s))
|
||||
using (var s = File.OpenRead(file))
|
||||
{
|
||||
var bytes = br.ReadBytes(magic_bytes.Length);
|
||||
var magic = Encoding.ASCII.GetString(bytes);
|
||||
|
||||
if (magic != Consts.ModListMagic) return null;
|
||||
|
||||
s.Position = s.Length - magic_bytes.Length - 8;
|
||||
var start_pos = br.ReadInt64();
|
||||
s.Position = start_pos;
|
||||
Utils.Log("Modlist found, loading...");
|
||||
using (var dc = LZ4Stream.Decode(br.BaseStream, leaveOpen: true))
|
||||
using (var br = new BinaryReader(s))
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
var list = formatter.Deserialize(dc);
|
||||
Utils.Log("Modlist loaded.");
|
||||
return (ModList) list;
|
||||
using (var dc = LZ4Stream.Decode(br.BaseStream, leaveOpen: true))
|
||||
{
|
||||
IFormatter formatter = new BinaryFormatter();
|
||||
var list = formatter.Deserialize(dc);
|
||||
Utils.Log("Modlist loaded.");
|
||||
return (ModList) list;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Utils.Log("Error Loading modlist");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -115,6 +115,5 @@
|
||||
<Button Content="View Modlist Contents" Grid.Row="5" Grid.Column="1" Height="30" Visibility="{Binding ShowReportButton}"
|
||||
Command="{Binding ShowReportCommand}" Margin="10" />
|
||||
<Button Content="Begin" Grid.Row="6" Height="30" Grid.Column="1" Command="{Binding Begin}" IsEnabled="{Binding UIReady}" Margin="10"/>
|
||||
<CheckBox Content="Ignore Missing Files" Grid.Row="7" Height="20" IsChecked="{Binding IgnoreMissingFiles}" IsEnabled="{Binding UIReady}" Visibility="Collapsed"/>
|
||||
</Grid>
|
||||
</Window>
|
@ -2,7 +2,11 @@
|
||||
using System.ComponentModel;
|
||||
using System.Threading;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using Alphaleonis.Win32.Filesystem;
|
||||
using Wabbajack.Common;
|
||||
using Application = System.Windows.Application;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
@ -13,20 +17,18 @@ namespace Wabbajack
|
||||
{
|
||||
private AppState _state;
|
||||
|
||||
public MainWindow()
|
||||
public enum RunMode
|
||||
{
|
||||
Compile,
|
||||
Install
|
||||
}
|
||||
|
||||
public MainWindow(RunMode mode, string source)
|
||||
{
|
||||
var args = Environment.GetCommandLineArgs();
|
||||
var DebugMode = false;
|
||||
string MO2Folder = null, InstallFolder = null, MO2Profile = null;
|
||||
|
||||
if (args.Length > 1)
|
||||
{
|
||||
DebugMode = true;
|
||||
MO2Folder = args[1];
|
||||
MO2Profile = args[2];
|
||||
InstallFolder = args[3];
|
||||
}
|
||||
|
||||
InitializeComponent();
|
||||
|
||||
var context = new AppState(Dispatcher, "Building");
|
||||
@ -44,12 +46,36 @@ namespace Wabbajack
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
context.UIReady = false;
|
||||
var modlist = Installer.CheckForModList();
|
||||
if (modlist == null)
|
||||
Utils.Log("No Modlist found, running in Compiler mode.");
|
||||
else
|
||||
context.ConfigureForInstall(modlist);
|
||||
if (mode == RunMode.Compile)
|
||||
{
|
||||
Utils.Log("Compiler ready to execute");
|
||||
context.Location = Path.GetDirectoryName(source);
|
||||
}
|
||||
else if (mode == RunMode.Install)
|
||||
{
|
||||
context.UIReady = false;
|
||||
var modlist = Installer.LoadModlist(source);
|
||||
if (modlist == null)
|
||||
{
|
||||
MessageBox.Show("Invalid Modlist, or file not found.", "Invalid Modlist", MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
context.Running = false;
|
||||
ExitWhenClosing = false;
|
||||
var window = new ModeSelectionWindow();
|
||||
window.ShowActivated = true;
|
||||
window.Show();
|
||||
Close();
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
context.ConfigureForInstall(modlist);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
context.UIReady = true;
|
||||
}).Start();
|
||||
}
|
||||
@ -66,9 +92,13 @@ namespace Wabbajack
|
||||
_state.LogMsg(((Exception) e.ExceptionObject).ExceptionToString());
|
||||
}
|
||||
|
||||
|
||||
internal bool ExitWhenClosing = true;
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e)
|
||||
{
|
||||
Application.Current.Shutdown();
|
||||
if (ExitWhenClosing)
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
}
|
||||
}
|
25
Wabbajack/ModeSelectionWindow.xaml
Normal file
25
Wabbajack/ModeSelectionWindow.xaml
Normal file
@ -0,0 +1,25 @@
|
||||
<Window x:Class="Wabbajack.ModeSelectionWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
Style="{StaticResource {x:Type Window}}" Icon="square_transparent_icon.ico" WindowStyle="ToolWindow"
|
||||
xmlns:local="clr-namespace:Wabbajack"
|
||||
mc:Ignorable="d"
|
||||
Title="ModeSelectionWindow" Height="450" Width="800" ResizeMode="NoResize"
|
||||
Closing="Close_Window">
|
||||
<Grid Margin="20">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition Height="70"></RowDefinition>
|
||||
<RowDefinition Height="70"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Image Name="Banner"></Image>
|
||||
<Button Name="InstallModlist" Grid.Row="1" Margin="2" Click="InstallModlist_Click">
|
||||
<TextBlock FontSize="40">Install a ModList</TextBlock>
|
||||
</Button>
|
||||
<Button Name="CreateModlist" Grid.Row="2" Margin="2" Click="CreateModlist_Click">
|
||||
<TextBlock FontSize="40">Create a ModList</TextBlock>
|
||||
</Button>
|
||||
</Grid>
|
||||
</Window>
|
64
Wabbajack/ModeSelectionWindow.xaml.cs
Normal file
64
Wabbajack/ModeSelectionWindow.xaml.cs
Normal file
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Shapes;
|
||||
using static Wabbajack.MainWindow;
|
||||
|
||||
namespace Wabbajack
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for ModeSelectionWindow.xaml
|
||||
/// </summary>
|
||||
public partial class ModeSelectionWindow : Window
|
||||
{
|
||||
public ModeSelectionWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
var img = UIUtils.BitmapImageFromResource("Wabbajack.banner_small.png");
|
||||
Banner.Source = img;
|
||||
}
|
||||
|
||||
private void CreateModlist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var file = UIUtils.OpenFileDialog("MO2 Modlist(modlist.txt)|modlist.txt");
|
||||
if (file != null)
|
||||
{
|
||||
ShutdownOnClose = false;
|
||||
new MainWindow(RunMode.Compile, file).Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void InstallModlist_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
var file = UIUtils.OpenFileDialog("Wabbajack Modlist (*.modlist)|*.modlist");
|
||||
if (file != null)
|
||||
{
|
||||
ShutdownOnClose = false;
|
||||
new MainWindow(RunMode.Install, file).Show();
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Close_Window(object sender, CancelEventArgs e)
|
||||
{
|
||||
if (ShutdownOnClose)
|
||||
Application.Current.Shutdown();
|
||||
}
|
||||
|
||||
public bool ShutdownOnClose { get; set; } = true;
|
||||
}
|
||||
}
|
@ -6,6 +6,8 @@ using System.Security.Cryptography.X509Certificates;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
using Wabbajack.Common;
|
||||
@ -62,6 +64,24 @@ namespace Wabbajack
|
||||
return null;
|
||||
}
|
||||
|
||||
public static BitmapImage BitmapImageFromResource(string name)
|
||||
{
|
||||
var img = new BitmapImage();
|
||||
img.BeginInit();
|
||||
img.StreamSource = Assembly.GetExecutingAssembly().GetManifestResourceStream(name);
|
||||
img.EndInit();
|
||||
return img;
|
||||
}
|
||||
|
||||
public static string OpenFileDialog(string filter)
|
||||
{
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
ofd.Filter = filter;
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
return ofd.FileName;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Dispatcher Dispatcher { get; set; }
|
||||
}
|
||||
}
|
||||
|
@ -182,6 +182,9 @@
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Data.cs" />
|
||||
<Compile Include="LambdaCommand.cs" />
|
||||
<Compile Include="ModeSelectionWindow.xaml.cs">
|
||||
<DependentUpon>ModeSelectionWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ReportBuilder.cs" />
|
||||
<Compile Include="Themes\LeftMarginMultiplierConverter.cs" />
|
||||
<Compile Include="Themes\TreeViewItemExtensions.cs" />
|
||||
@ -203,6 +206,10 @@
|
||||
<DependentUpon>MainWindow.xaml</DependentUpon>
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Page Include="ModeSelectionWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Styles.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@ -274,6 +281,9 @@
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="banner.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="banner_small.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\packages\Fody.5.1.1\build\Fody.targets" Condition="Exists('..\packages\Fody.5.1.1\build\Fody.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
|
BIN
Wabbajack/banner_small.png
Normal file
BIN
Wabbajack/banner_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 KiB |
BIN
logos/banner_small.png
Normal file
BIN
logos/banner_small.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 KiB |
Loading…
Reference in New Issue
Block a user