From b6089c34f6f6991c8a3a87adcbf8abbae5c289d7 Mon Sep 17 00:00:00 2001 From: erri120 Date: Tue, 3 Dec 2019 13:13:37 +0100 Subject: [PATCH] Steam Workshop Items can now be installed --- Wabbajack.Lib/VortexInstaller.cs | 50 +++++++++++++++++++++++++++++++- 1 file changed, 49 insertions(+), 1 deletion(-) diff --git a/Wabbajack.Lib/VortexInstaller.cs b/Wabbajack.Lib/VortexInstaller.cs index f37f162d..ab3e289b 100644 --- a/Wabbajack.Lib/VortexInstaller.cs +++ b/Wabbajack.Lib/VortexInstaller.cs @@ -1,4 +1,6 @@ -using System.Linq; +using System.Diagnostics; +using System.Linq; +using System.Windows; using Wabbajack.Common; using Directory = Alphaleonis.Win32.Filesystem.Directory; using File = Alphaleonis.Win32.Filesystem.File; @@ -52,12 +54,58 @@ namespace Wabbajack.Lib BuildFolderStructure(); InstallArchives(); InstallIncludedFiles(); + InstallSteamWorkshopItems(); //InstallIncludedDownloadMetas(); Info("Installation complete! You may exit the program."); return true; } + private void InstallSteamWorkshopItems() + { + //var currentLib = ""; + SteamGame currentSteamGame = null; + SteamHandler.Instance.Games.Where(g => g.Game == GameInfo.Game).Do(s => currentSteamGame = s); + /*SteamHandler.Instance.InstallFolders.Where(f => f.Contains(currentSteamGame.InstallDir)).Do(s => currentLib = s); + + var downloadFolder = Path.Combine(currentLib, "workshop", "downloads", currentSteamGame.AppId.ToString()); + var contentFolder = Path.Combine(currentLib, "workshop", "content", currentSteamGame.AppId.ToString()); + */ + if (!ModList.Directives.Any(s => s is SteamMeta)) + return; + + var result = MessageBox.Show("The ModList you are installing requires Steam Workshop Items to exist. " + + "You can check the Workshop Items in the manifest of this ModList. Wabbajack can start Steam for you " + + "and download the Items automatically. Do you want to proceed with this step?", + "Warning", MessageBoxButton.YesNo); + + if (result != MessageBoxResult.Yes) + return; + + ModList.Directives.OfType() + .PMap(Queue, item => + { + Status("Extracting Steam meta file to temp folder"); + var path = Path.Combine(DownloadFolder, $"steamWorkshopItem_{item.ItemID}.meta"); + if (!File.Exists(path)) + File.WriteAllBytes(path, LoadBytesFromPath(item.SourceDataID)); + + Status("Downloading Steam Workshop Item through steam cmd"); + + var p = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = System.IO.Path.Combine(SteamHandler.Instance.SteamPath, "steam.exe"), + CreateNoWindow = true, + Arguments = $"console +workshop_download_item {currentSteamGame.AppId} {item.ItemID}" + } + }; + + p.Start(); + }); + } + private void InstallIncludedFiles() { Info("Writing inline files");