From 6007c326e1dabe365052b4c9c4db616389d3dbbb Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Mon, 19 Oct 2020 16:16:35 -0600 Subject: [PATCH] Could compile via the UI --- Wabbajack.Common/Consts.cs | 2 + .../View Models/Compilers/MO2CompilerVM.cs | 73 ++++++++++++++----- 2 files changed, 57 insertions(+), 18 deletions(-) diff --git a/Wabbajack.Common/Consts.cs b/Wabbajack.Common/Consts.cs index 1c9e4cc4..f85d2dfa 100644 --- a/Wabbajack.Common/Consts.cs +++ b/Wabbajack.Common/Consts.cs @@ -130,6 +130,8 @@ namespace Wabbajack.Common public static AbsolutePath SettingsFile => LocalAppDataPath.Combine("settings.json"); public static RelativePath SettingsIni = (RelativePath)"settings.ini"; public static byte SettingsVersion => 2; + public static RelativePath NativeSettingsJson = (RelativePath)"native_compiler_settings.json"; + public static bool IsServer = false; public static string CompressedBodyHeader = "x-compressed-body"; diff --git a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs index d7493a05..b8255f75 100644 --- a/Wabbajack/View Models/Compilers/MO2CompilerVM.cs +++ b/Wabbajack/View Models/Compilers/MO2CompilerVM.cs @@ -10,6 +10,7 @@ using System.Threading.Tasks; using DynamicData; using Wabbajack.Common; using Wabbajack.Lib; +using WebSocketSharp; namespace Wabbajack { @@ -49,7 +50,7 @@ namespace Wabbajack PathType = FilePickerVM.PathTypeOptions.File, PromptTitle = "Select a Modlist" }; - ModListLocation.Filters.Add(new CommonFileDialogFilter("MO2 Profile (modlist.txt)", ".txt")); + ModListLocation.Filters.Add(new CommonFileDialogFilter("MO2 Profile (modlist.txt) or Native Settings (native_compiler_settings.json)", ".txt,.json")); DownloadLocation = new FilePickerVM() { @@ -63,8 +64,18 @@ namespace Wabbajack { try { - var profileFolder = loc.Parent; - return profileFolder.Parent.Parent; + if (loc.FileName == Consts.ModListTxt) + { + var profileFolder = loc.Parent; + return profileFolder.Parent.Parent; + } + + if (loc.FileName == Consts.NativeSettingsJson) + { + return loc.Parent; + } + + return default; } catch (Exception) { @@ -77,6 +88,11 @@ namespace Wabbajack { try { + if (loc.FileName == Consts.NativeSettingsJson) + { + var settings = loc.FromJson(); + return settings.ModListName; + } return (string)loc.Parent.FileName; } catch (Exception) @@ -179,24 +195,45 @@ namespace Wabbajack try { - using (ActiveCompilation = new MO2Compiler( - sourcePath: Mo2Folder, - downloadsPath: DownloadLocation.TargetPath, - mo2Profile: MOProfile, - outputFile: outputFile) + ACompiler compiler; + + if (ModListLocation.TargetPath.FileName == Consts.NativeSettingsJson) { - ModListName = ModlistSettings.ModListName, - ModListAuthor = ModlistSettings.AuthorText, - ModListDescription = ModlistSettings.Description, - ModListImage = ModlistSettings.ImagePath.TargetPath, - ModListWebsite = ModlistSettings.Website, - ModlistReadme = ModlistSettings.Readme, - ModlistVersion = ModlistSettings.Version, - ModlistIsNSFW = ModlistSettings.IsNSFW - }) + var settings = ModListLocation.TargetPath.FromJson(); + compiler = new NativeCompiler(settings, Mo2Folder, DownloadLocation.TargetPath, outputFile) + { + ModListName = ModlistSettings.ModListName, + ModListAuthor = ModlistSettings.AuthorText, + ModListDescription = ModlistSettings.Description, + ModListImage = ModlistSettings.ImagePath.TargetPath, + ModListWebsite = ModlistSettings.Website, + ModlistReadme = ModlistSettings.Readme, + ModlistVersion = ModlistSettings.Version, + ModlistIsNSFW = ModlistSettings.IsNSFW + }; + } + else + { + compiler = new MO2Compiler( + sourcePath: Mo2Folder, + downloadsPath: DownloadLocation.TargetPath, + mo2Profile: MOProfile, + outputFile: outputFile) + { + ModListName = ModlistSettings.ModListName, + ModListAuthor = ModlistSettings.AuthorText, + ModListDescription = ModlistSettings.Description, + ModListImage = ModlistSettings.ImagePath.TargetPath, + ModListWebsite = ModlistSettings.Website, + ModlistReadme = ModlistSettings.Readme, + ModlistVersion = ModlistSettings.Version, + ModlistIsNSFW = ModlistSettings.IsNSFW + }; + } + using (ActiveCompilation = compiler +) { Parent.MWVM.Settings.Performance.SetProcessorSettings(ActiveCompilation); - var success = await ActiveCompilation.Begin(); return GetResponse.Create(success, ActiveCompilation.ModList); }