Vortex: Manual game files can be copied over

This commit is contained in:
erri120 2019-12-07 17:35:57 +01:00
parent 9d4325a5fe
commit c5858c51c3
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
3 changed files with 67 additions and 3 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

@ -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 = "";