Merge pull request #240 from erri120/vortex-fixes-5

Vortex fixes 5
This commit is contained in:
Timothy Baldridge 2019-12-07 11:30:11 -07:00 committed by GitHub
commit b9ae379c09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 72 additions and 15 deletions

View File

@ -10,6 +10,7 @@ namespace Wabbajack.Common
public static bool TestMode { get; set; } = false;
public static string GameFolderFilesDir = "Game Folder Files";
public static string ManualGameFilesDir = "Manual Game Files";
public static string LOOTFolderFilesDir = "LOOT Config Files";
public static string BSACreationDir = "TEMP_BSA_FILES";

View File

@ -67,19 +67,12 @@ namespace Wabbajack.Common
public List<string> RequiredFiles { get; internal set; }
public bool Disabled { get; internal set; }
public string GameLocation
public string GameLocation(bool steam)
{
get
{
if (Consts.TestMode)
return Directory.GetCurrentDirectory();
if (Consts.TestMode)
return Directory.GetCurrentDirectory();
return (string) Registry.GetValue(GameLocationRegistryKey, "installed path", null)
??
(string) Registry.GetValue(
GameLocationRegistryKey.Replace(@"HKEY_LOCAL_MACHINE\SOFTWARE\",
@"HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\"), "installed path", null);
}
return steam ? SteamHandler.Instance.Games.FirstOrDefault(g => g.Game == Game)?.InstallDir : GOGHandler.Instance.Games.FirstOrDefault(g => g.Game == Game)?.Path;
}
}

View File

@ -41,7 +41,7 @@ namespace Wabbajack.Lib
var game = GameRegistry.Games[ModList.GameType];
if (GameFolder == null)
GameFolder = game.GameLocation;
GameFolder = game.GameLocation(SteamHandler.Instance.Games.Any(g => g.Game == game.Game));
if (GameFolder == null)
{

View File

@ -180,7 +180,15 @@ namespace Wabbajack.Lib
#endif
var replace = f;
replace.Path = Path.Combine("Manual Game Files", element.FullPath.Substring(DownloadsFolder.Length + 1).Replace('|', '\\'));
var name = replace.File.Name;
var archiveName = targetArchive.Name;
var elementPath = element.FullPath.Substring(element.FullPath.IndexOf('|')+1);
var gameToFile = name.Substring(GamePath.Length + 1).Replace(elementPath, "");
if (gameToFile.EndsWith("\\"))
gameToFile = gameToFile.Substring(0, gameToFile.Length - 1);
//replace.Path = replace.Path.Replace(Consts.GameFolderFilesDir, Consts.ManualGameFilesDir);
replace.Path = Path.Combine(Consts.ManualGameFilesDir, archiveName, gameToFile, elementPath);
//replace.Path = Path.Combine(Consts.ManualGameFilesDir, element.FullPath.Substring(DownloadsFolder.Length + 1).Replace('|', '\\'));
AllFiles.RemoveAt(i);
AllFiles.Insert(i, replace);
//AllFiles.Replace(f, replace);
@ -312,7 +320,7 @@ namespace Wabbajack.Lib
.Where(File.Exists)
.Do(f =>
{
if (Path.GetExtension(f) != ".meta" && !File.Exists($"{f}.meta") && ActiveArchives.Contains(Path.GetFileNameWithoutExtension(f)))
if (Path.GetExtension(f) != ".meta" && Path.GetExtension(f) != ".xxHash" && !File.Exists($"{f}.meta") && ActiveArchives.Contains(Path.GetFileNameWithoutExtension(f)))
{
Utils.Log($"Trying to create meta file for {Path.GetFileName(f)}");
var metaString = "[General]\n" +

View File

@ -1,8 +1,11 @@
using System.Diagnostics;
using System;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Windows;
using Wabbajack.Common;
using Directory = Alphaleonis.Win32.Filesystem.Directory;
using DirectoryInfo = Alphaleonis.Win32.Filesystem.DirectoryInfo;
using File = Alphaleonis.Win32.Filesystem.File;
using Path = Alphaleonis.Win32.Filesystem.Path;
@ -60,6 +63,7 @@ namespace Wabbajack.Lib
BuildFolderStructure();
InstallArchives();
InstallIncludedFiles();
InstallManualGameFiles();
InstallSteamWorkshopItems();
//InstallIncludedDownloadMetas();
@ -67,6 +71,57 @@ namespace Wabbajack.Lib
return true;
}
private void InstallManualGameFiles()
{
if (!ModList.Directives.Any(d => d.To.StartsWith(Consts.ManualGameFilesDir)))
return;
var result = MessageBox.Show("Some mods from this ModList must be installed directly into " +
"the game folder. Do you want to do this manually or do you want Wabbajack " +
"to do this for you?", "Question", MessageBoxButton.YesNo);
if (result != MessageBoxResult.Yes)
return;
var manualFilesDir = Path.Combine(OutputFolder, Consts.ManualGameFilesDir);
var gameFolder = GameInfo.GameLocation(SteamHandler.Instance.Games.Any(g => g.Game == GameInfo.Game));
Info($"Copying files from {manualFilesDir} " +
$"to the game folder at {gameFolder}");
if (!Directory.Exists(manualFilesDir))
{
Info($"{manualFilesDir} does not exist!");
return;
}
Directory.EnumerateDirectories(manualFilesDir).PMap(Queue, dir =>
{
var dirInfo = new DirectoryInfo(dir);
dirInfo.GetDirectories("*", SearchOption.AllDirectories).Do(d =>
{
var destPath = d.FullName.Replace(dir, gameFolder);
Status($"Creating directory {destPath}");
Directory.CreateDirectory(destPath);
});
dirInfo.GetFiles("*", SearchOption.AllDirectories).Do(f =>
{
var destPath = f.FullName.Replace(dir, gameFolder);
Status($"Copying file {f.FullName} to {destPath}");
try
{
File.Copy(f.FullName, destPath);
}
catch (Exception)
{
Info($"Could not copy file {f.FullName} to {destPath}. The file may already exist, skipping...");
}
});
});
}
private void InstallSteamWorkshopItems()
{
//var currentLib = "";