fixes #6 - users can now have a download folder outside of MO2

This commit is contained in:
Timothy Baldridge 2019-09-03 16:12:39 -06:00
parent 7acd964f48
commit 5edf454e16
6 changed files with 86 additions and 11 deletions

View File

@ -13,6 +13,8 @@ that is copied directly into a modfile (commonly used for `SSE Terrain Tamriel.e
* All `.json`, `.ini`, and `.yaml` files that contain remappable paths are now inlined and remapped.
* If Wabbajack finds a file called `otherprofiles.txt` inside the compile'd profile's folder. Then that file is assumed
to be a list of other profiles to be included in the install. This list should be the name of a profile, one name per line.
* Can now set the download folder both during compilation and installation.
* Any config files pointing to the download folder are remapped.
#### Version 0.8.1 - 8/29/2019
* Fixed a bug that was causing VFS temp folders not to be cleaned

View File

@ -42,6 +42,10 @@ namespace Wabbajack.Common
public static string MO2_PATH_MAGIC_DOUBLE_BACK = "{--||MO2_PATH_MAGIC_DOUBLE_BACK||--}";
public static string MO2_PATH_MAGIC_FORWARD = "{--||MO2_PATH_MAGIC_FORWARD||--}";
public static string DOWNLOAD_PATH_MAGIC_BACK = "{--||DOWNLOAD_PATH_MAGIC_BACK||--}";
public static string DOWNLOAD_PATH_MAGIC_DOUBLE_BACK = "{--||DOWNLOAD_PATH_MAGIC_DOUBLE_BACK||--}";
public static string DOWNLOAD_PATH_MAGIC_FORWARD = "{--||DOWNLOAD_PATH_MAGIC_FORWARD||--}";
public static String AppName = "Wabbajack";
public static string HashCacheName = "Wabbajack.hash_cache";

View File

@ -80,6 +80,7 @@ namespace Wabbajack
private string _modListName;
private ModList _modList;
private string _location;
private string _downloadLocation;
public string ModListName
{
@ -107,6 +108,19 @@ namespace Wabbajack
}
}
public string DownloadLocation
{
get
{
return _downloadLocation;
}
set
{
_downloadLocation = value;
OnPropertyChanged("DownloadLocation");
}
}
private string _htmlReport;
public Visibility ShowReportButton => _htmlReport == null ? Visibility.Collapsed : Visibility.Visible;
@ -243,6 +257,19 @@ namespace Wabbajack
}
}
private ICommand _changeDownloadPath;
public ICommand ChangeDownloadPath
{
get
{
if (_changeDownloadPath == null)
{
_changeDownloadPath = new LambdaCommand(() => true, () => this.ExecuteChangeDownloadPath());
}
return _changeDownloadPath;
}
}
private void ExecuteChangePath()
{
if (Mode == "Installing")
@ -268,6 +295,17 @@ namespace Wabbajack
}
}
private void ExecuteChangeDownloadPath()
{
var ofd = new Ookii.Dialogs.Wpf.VistaFolderBrowserDialog();
ofd.Description = "Select a location for MO2 downloads";
ofd.UseDescriptionForTitle = true;
if (ofd.ShowDialog() == true)
{
DownloadLocation = ofd.SelectedPath;
}
}
private void ConfigureForBuild()
{
var profile_folder = Path.GetDirectoryName(Location);
@ -278,6 +316,10 @@ namespace Wabbajack
var profile_name = Path.GetFileName(profile_folder);
ModListName = profile_name;
Mode = "Building";
var tmp_compiler = new Compiler(mo2folder, Utils.Log);
DownloadLocation = tmp_compiler.MO2DownloadsFolder;
_mo2Folder = mo2folder;
}
@ -323,6 +365,7 @@ namespace Wabbajack
{
var installer = new Installer(_modList, Location, msg => this.LogMsg(msg));
installer.IgnoreMissingFiles = IgnoreMissingFiles;
installer.DownloadFolder = DownloadLocation;
var th = new Thread(() =>
{
try

View File

@ -31,12 +31,19 @@ namespace Wabbajack
public bool IgnoreMissingFiles { get; set; }
private string _mo2DownloadsFolder;
public string MO2DownloadsFolder
{
get
{
if (_mo2DownloadsFolder != null) return _mo2DownloadsFolder;
if (MO2Ini != null)
if (MO2Ini.Settings != null)
if (MO2Ini.Settings.download_directory != null)
return MO2Ini.Settings.download_directory.Replace("/", "\\");
return Path.Combine(MO2Folder, "downloads");
}
set => _mo2DownloadsFolder = value;
}
@ -157,6 +164,9 @@ namespace Wabbajack
Info($"Indexing {GamePath}");
VFS.AddRoot(GamePath);
Info($"Indexing {MO2DownloadsFolder}");
VFS.AddRoot(MO2DownloadsFolder);
var mo2_files = Directory.EnumerateFiles(MO2Folder, "*", SearchOption.AllDirectories)
.Where(p => p.FileExists())
.Select(p => new RawSourceFile(VFS.Lookup(p)) { Path = p.RelativeTo(MO2Folder)});
@ -497,7 +507,7 @@ namespace Wabbajack
Info($"Checking link for {found.Name}");
var installer = new Installer(null, "", s=>Utils.Log(s));
var installer = new Installer(null, "", Utils.Log);
installer.NexusAPIKey = NexusKey;
if (!installer.DownloadArchive(result, false))
Error($"Unable to resolve link for {found.Name}. If this is hosted on the nexus the file may have been removed.");
@ -530,7 +540,7 @@ namespace Wabbajack
private IEnumerable<Func<RawSourceFile, Directive>> MakeStack()
{
Info("Generating compilation stack");
return new List<Func<RawSourceFile, Directive>>()
return new List<Func<RawSourceFile, Directive>>
{
IgnoreStartsWith("logs\\"),
IncludeRegex("^downloads\\\\.*\\.meta"),
@ -646,6 +656,11 @@ namespace Wabbajack
data = data.Replace(MO2Folder, Consts.MO2_PATH_MAGIC_BACK);
data = data.Replace(MO2Folder.Replace("\\", "\\\\"), Consts.MO2_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(MO2Folder.Replace("\\", "/"), Consts.MO2_PATH_MAGIC_FORWARD);
data = data.Replace(MO2DownloadsFolder, Consts.DOWNLOAD_PATH_MAGIC_BACK);
data = data.Replace(MO2DownloadsFolder.Replace("\\", "\\\\"), Consts.DOWNLOAD_PATH_MAGIC_DOUBLE_BACK);
data = data.Replace(MO2DownloadsFolder.Replace("\\", "/"), Consts.DOWNLOAD_PATH_MAGIC_FORWARD);
if (data == original_data)
return null;
var result = source.EvolveTo<RemappedInlineFile>();

View File

@ -18,6 +18,8 @@ namespace Wabbajack
{
public class Installer
{
private string _downloadsFolder;
public VirtualFileSystem VFS
{
get
@ -36,10 +38,8 @@ namespace Wabbajack
public string Outputfolder { get; }
public string DownloadFolder
{
get
{
return Path.Combine(Outputfolder, "downloads");
}
get => _downloadsFolder ?? Path.Combine(Outputfolder, "downloads");
set => _downloadsFolder = value;
}
public ModList ModList { get; }
public Action<string> Log_Fn { get; }
@ -309,8 +309,11 @@ namespace Wabbajack
data = data.Replace(Consts.MO2_PATH_MAGIC_DOUBLE_BACK, Outputfolder.Replace("\\", "\\\\"));
data = data.Replace(Consts.MO2_PATH_MAGIC_FORWARD, Outputfolder.Replace("\\", "/"));
data = data.Replace(Consts.DOWNLOAD_PATH_MAGIC_BACK, DownloadFolder);
data = data.Replace(Consts.DOWNLOAD_PATH_MAGIC_DOUBLE_BACK, DownloadFolder.Replace("\\", "\\\\"));
data = data.Replace(Consts.DOWNLOAD_PATH_MAGIC_FORWARD, DownloadFolder.Replace("\\", "/"));
File.WriteAllText(Path.Combine(Outputfolder, directive.To), data);
return;
}
private void BuildFolderStructure()

View File

@ -5,7 +5,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:Wabbajack"
mc:Ignorable="d"
Title="Wabbajack" Height="700" Width="800"
Title="Wabbajack" Height="800" Width="800"
Style="{StaticResource {x:Type Window}}" Icon="square_transparent_icon.ico" WindowStyle="ToolWindow" Closing="Window_Closing">
<Grid Margin="16">
<Grid.RowDefinitions>
@ -30,9 +30,17 @@
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="Auto"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Label Content="Location:" Grid.Column="0"></Label>
<TextBox Grid.Column="1" Text="{Binding Location}"></TextBox>
<Button Content="Select" MinWidth="80" Grid.Column="2" Command="{Binding ChangePath}"></Button>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition MinHeight="10"></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Label Grid.Row="0" Content="MO2 Location:" Grid.Column="0"></Label>
<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Location}"></TextBox>
<Button Grid.Row="0" Content="Select" MinWidth="80" Grid.Column="2" Command="{Binding ChangePath}"></Button>
<Label Grid.Row="2" Content="Download Location:" Grid.Column="0"></Label>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding DownloadLocation}"></TextBox>
<Button Grid.Row="2" Content="Select" MinWidth="80" Grid.Column="2" Command="{Binding ChangeDownloadPath}"></Button>
</Grid>
<ListBox Grid.Row ="2" ItemsSource="{Binding Status}" Width="Auto" HorizontalAlignment="Stretch">
<ListBox.ItemTemplate>