mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
Move logs/downloaded modlists into the launcher folder
This commit is contained in:
parent
c1d5f9771f
commit
22b7782578
@ -127,7 +127,7 @@ namespace Wabbajack.Common
|
|||||||
public static AbsolutePath PatchCacheFolder => LocalAppDataPath.Combine("patch_cache");
|
public static AbsolutePath PatchCacheFolder => LocalAppDataPath.Combine("patch_cache");
|
||||||
public static int MaxConnectionsPerServer = 4;
|
public static int MaxConnectionsPerServer = 4;
|
||||||
|
|
||||||
public static AbsolutePath LogsFolder => ((RelativePath)"logs").RelativeToEntryPoint();
|
public static AbsolutePath LogsFolder { get; set; } = ((RelativePath)"logs").RelativeToEntryPoint();
|
||||||
public static AbsolutePath EntryPoint => (AbsolutePath)(Assembly.GetEntryAssembly()?.Location ?? (string)((RelativePath)"Unknown").RelativeToWorkingDirectory());
|
public static AbsolutePath EntryPoint => (AbsolutePath)(Assembly.GetEntryAssembly()?.Location ?? (string)((RelativePath)"Unknown").RelativeToWorkingDirectory());
|
||||||
public static AbsolutePath LogFile => LogsFolder.Combine(EntryPoint.FileNameWithoutExtension + ".current.log");
|
public static AbsolutePath LogFile => LogsFolder.Combine(EntryPoint.FileNameWithoutExtension + ".current.log");
|
||||||
public static int MaxOldLogs = 50;
|
public static int MaxOldLogs = 50;
|
||||||
|
@ -30,7 +30,7 @@ namespace Wabbajack.Common
|
|||||||
private static readonly Subject<IStatusMessage> LoggerSubj = new Subject<IStatusMessage>();
|
private static readonly Subject<IStatusMessage> LoggerSubj = new Subject<IStatusMessage>();
|
||||||
public static IObservable<IStatusMessage> LogMessages => LoggerSubj;
|
public static IObservable<IStatusMessage> LogMessages => LoggerSubj;
|
||||||
|
|
||||||
private static async Task InitalizeLogging()
|
public static async Task InitalizeLogging()
|
||||||
{
|
{
|
||||||
_startTime = DateTime.Now;
|
_startTime = DateTime.Now;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Alphaleonis.Win32.Filesystem;
|
using Alphaleonis.Win32.Filesystem;
|
||||||
|
using Wabbajack.Common.IO;
|
||||||
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
using Directory = Alphaleonis.Win32.Filesystem.Directory;
|
||||||
using DriveInfo = Alphaleonis.Win32.Filesystem.DriveInfo;
|
using DriveInfo = Alphaleonis.Win32.Filesystem.DriveInfo;
|
||||||
using File = Alphaleonis.Win32.Filesystem.File;
|
using File = Alphaleonis.Win32.Filesystem.File;
|
||||||
@ -164,6 +165,11 @@ namespace Wabbajack.Common
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Returns the path to the Windows folder, most often c:\Windows
|
||||||
|
/// </summary>
|
||||||
|
public static AbsolutePath WindowsFolder => (AbsolutePath)KnownFolders.Windows.Path;
|
||||||
|
|
||||||
public AbsolutePath Root => (AbsolutePath)Path.GetPathRoot(_path);
|
public AbsolutePath Root => (AbsolutePath)Path.GetPathRoot(_path);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -863,6 +863,14 @@ namespace Wabbajack.Common
|
|||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void OpenFolder(AbsolutePath path)
|
||||||
|
{
|
||||||
|
Process.Start(new ProcessStartInfo(AbsolutePath.WindowsFolder.Combine("explorer.exe").ToString(), path.ToString())
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsInPath(this string path, string parent)
|
public static bool IsInPath(this string path, string parent)
|
||||||
{
|
{
|
||||||
|
@ -10,25 +10,37 @@ namespace Wabbajack.Lib
|
|||||||
{
|
{
|
||||||
public class LauncherUpdater
|
public class LauncherUpdater
|
||||||
{
|
{
|
||||||
public static async Task Run()
|
public static Lazy<AbsolutePath> CommonFolder = new (() =>
|
||||||
{
|
{
|
||||||
var entryPoint = AbsolutePath.EntryPoint;
|
var entryPoint = AbsolutePath.EntryPoint;
|
||||||
|
|
||||||
// If we're not in a folder that looks like a version, abort
|
// If we're not in a folder that looks like a version, abort
|
||||||
if (!Version.TryParse(entryPoint.FileName.ToString(), out var version))
|
if (!Version.TryParse(entryPoint.FileName.ToString(), out var version))
|
||||||
{
|
{
|
||||||
Utils.Log($"Not in a version folder, not attempting update. Got {entryPoint.Parent}");
|
return entryPoint;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're not in a folder that has Wabbajack.exe in the parent folder, abort
|
// If we're not in a folder that has Wabbajack.exe in the parent folder, abort
|
||||||
if (!entryPoint.Parent.Parent.Combine(Consts.AppName).WithExtension(new Extension(".exe")).IsFile)
|
if (!entryPoint.Parent.Combine(Consts.AppName).WithExtension(new Extension(".exe")).IsFile)
|
||||||
{
|
{
|
||||||
Utils.Log("Parent folder does not contain launcher, not updating");
|
return entryPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
return entryPoint.Parent;
|
||||||
|
});
|
||||||
|
|
||||||
|
public static async Task Run()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (CommonFolder.Value == AbsolutePath.EntryPoint)
|
||||||
|
{
|
||||||
|
Utils.Log("Outside of standard install folder, not updating");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var oldVersions = entryPoint.Parent
|
var version = Version.Parse(AbsolutePath.EntryPoint.FileName.ToString());
|
||||||
|
|
||||||
|
var oldVersions = CommonFolder.Value
|
||||||
.EnumerateDirectories()
|
.EnumerateDirectories()
|
||||||
.Select(f => Version.TryParse(f.FileName.ToString(), out var ver) ? (ver, f) : default)
|
.Select(f => Version.TryParse(f.FileName.ToString(), out var ver) ? (ver, f) : default)
|
||||||
.Where(f => f != default)
|
.Where(f => f != default)
|
||||||
|
@ -12,7 +12,10 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
public App()
|
public App()
|
||||||
{
|
{
|
||||||
|
Consts.LogsFolder = LauncherUpdater.CommonFolder.Value.Combine("logs");
|
||||||
|
|
||||||
LoggingSettings.LogToFile = true;
|
LoggingSettings.LogToFile = true;
|
||||||
|
Utils.InitalizeLogging().Wait();
|
||||||
|
|
||||||
CLIOld.ParseOptions(Environment.GetCommandLineArgs());
|
CLIOld.ParseOptions(Environment.GetCommandLineArgs());
|
||||||
if (CLIArguments.Help)
|
if (CLIArguments.Help)
|
||||||
|
@ -75,7 +75,7 @@ namespace Wabbajack
|
|||||||
{
|
{
|
||||||
_parent = parent;
|
_parent = parent;
|
||||||
Metadata = metadata;
|
Metadata = metadata;
|
||||||
Location = Consts.ModListDownloadFolder.Combine(Metadata.Links.MachineURL + (string)Consts.ModListExtension);
|
Location = LauncherUpdater.CommonFolder.Value.Combine("downloaded_mod_lists", Metadata.Links.MachineURL + (string)Consts.ModListExtension);
|
||||||
ModListTagList = new List<ModListTag>();
|
ModListTagList = new List<ModListTag>();
|
||||||
Metadata.tags.ForEach(tag =>
|
Metadata.tags.ForEach(tag =>
|
||||||
{
|
{
|
||||||
|
@ -91,6 +91,7 @@ namespace Wabbajack
|
|||||||
public ReactiveCommand<Unit, Unit> VisitModListWebsiteCommand { get; }
|
public ReactiveCommand<Unit, Unit> VisitModListWebsiteCommand { get; }
|
||||||
|
|
||||||
public ReactiveCommand<Unit, Unit> CloseWhenCompleteCommand { get; }
|
public ReactiveCommand<Unit, Unit> CloseWhenCompleteCommand { get; }
|
||||||
|
public ReactiveCommand<Unit, Unit> OpenLogsCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> GoToInstallCommand { get; }
|
public ReactiveCommand<Unit, Unit> GoToInstallCommand { get; }
|
||||||
public ReactiveCommand<Unit, Unit> BeginCommand { get; }
|
public ReactiveCommand<Unit, Unit> BeginCommand { get; }
|
||||||
|
|
||||||
@ -319,6 +320,9 @@ namespace Wabbajack
|
|||||||
canExecute: this.WhenAny(x => x.ModList)
|
canExecute: this.WhenAny(x => x.ModList)
|
||||||
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
.Select(modList => !string.IsNullOrEmpty(modList?.Readme))
|
||||||
.ObserveOnGuiThread());
|
.ObserveOnGuiThread());
|
||||||
|
|
||||||
|
OpenLogsCommand = ReactiveCommand.Create(
|
||||||
|
execute: () => Utils.OpenFolder(Consts.LogsFolder));
|
||||||
VisitModListWebsiteCommand = ReactiveCommand.Create(
|
VisitModListWebsiteCommand = ReactiveCommand.Create(
|
||||||
execute: () =>
|
execute: () =>
|
||||||
{
|
{
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
<ColumnDefinition Width="*" />
|
<ColumnDefinition Width="*" />
|
||||||
|
<ColumnDefinition Width="*" />
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"
|
<TextBlock Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="4"
|
||||||
x:Name="TitleText"
|
x:Name="TitleText"
|
||||||
@ -80,6 +81,29 @@
|
|||||||
Text="Install Folder" />
|
Text="Install Folder" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="1" Grid.Column="2"
|
<Grid Grid.Row="1" Grid.Column="2"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Background="Transparent">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
<RowDefinition Height="Auto" />
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
<Button
|
||||||
|
x:Name="OpenLogsButton"
|
||||||
|
Width="50"
|
||||||
|
Height="50"
|
||||||
|
Style="{StaticResource CircleButtonStyle}">
|
||||||
|
<icon:PackIconFontAwesome
|
||||||
|
Width="25"
|
||||||
|
Height="25"
|
||||||
|
Foreground="{Binding Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
|
||||||
|
Kind="ListAltRegular" />
|
||||||
|
</Button>
|
||||||
|
<TextBlock Grid.Row="1"
|
||||||
|
Margin="0,10,0,0"
|
||||||
|
HorizontalAlignment="Center"
|
||||||
|
Text="Log Files" />
|
||||||
|
</Grid>
|
||||||
|
<Grid Grid.Row="1" Grid.Column="3"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Background="Transparent">
|
Background="Transparent">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
@ -102,9 +126,9 @@
|
|||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
Text="Readme" />
|
Text="Readme" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="1" Grid.Column="3"
|
<Grid Grid.Row="1" Grid.Column="4"
|
||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Background="Transparent">
|
Background="Transparent">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
<RowDefinition Height="Auto" />
|
<RowDefinition Height="Auto" />
|
||||||
|
@ -52,6 +52,9 @@ namespace Wabbajack
|
|||||||
this.WhenAny(x => x.ViewModel.CloseWhenCompleteCommand)
|
this.WhenAny(x => x.ViewModel.CloseWhenCompleteCommand)
|
||||||
.BindToStrict(this, x => x.CloseButton.Command)
|
.BindToStrict(this, x => x.CloseButton.Command)
|
||||||
.DisposeWith(dispose);
|
.DisposeWith(dispose);
|
||||||
|
this.WhenAny(x => x.ViewModel.OpenLogsCommand)
|
||||||
|
.BindToStrict(this, x => x.OpenLogsButton.Command)
|
||||||
|
.DisposeWith(dispose);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user