mirror of
https://github.com/wabbajack-tools/wabbajack.git
synced 2024-08-30 18:42:17 +00:00
b8fe48178b
* added more visible error messages to avoid user confusion added hard drive free space detection, added red error message text, removed overwrite checkbox, added wiki button link extended the error text for starting wabbajack in protected location removed debug code shortened error message to fit in text box * restored warning removed in error, updated changelog, removed debug includes * Update InstallerVM.cs * Update InstallerVM.cs * Update MainWindowViewModel.cs * added json optional flag to only show version number over modlist image in installer view, if the modlist image already contains the title removed debug code change to pascal case and match existing code style update changelog * Fix manual downloads sometimes launching in browser * Fix manual downloads from secure servers * Remove duplicate user agent code * Create configuration project and performance settings * Bind new performance settings to UI * Use performance settings to limit maximum memory per download * Remove unused settings and related classes * Updated CHANGELOG.md * update CHANGELOG.md * moved the existing files popup to an error message , heralding the return of the overwrite install checkbox * added newline * reverted erroneous edit * gogID for fallout4 added * update CHANGELOG.md * Fix deadlock when loading new settings * change folder/directory check logic * update CHANGELOG.md * revert unnecessary change * update CHANGELOG.md * Bump Wabbajack to .NET 7 * Bump ReactiveUI packages & deps * Update GameFinder to 4.0.0 * Update CHANGELOG.md * Update CHANGELOG.md * Don't try to add cookies if array is empty * Start download from scratch if .download_package can't be parsed * Log when application is shutting down * update CHANGELOG.md * exclude the "SP Consent Message" on nexus from the cleared iframes * Actually use the --outputPath compile option if the user provides one It was just not being used, defaulting to the parent of installPath. it still does, if the user does not specify a directory using --outputPath * update Wabbajack.Compression.BSA dependencies * improve log message to include storage space reference * clearing temp folder when the app closes * update logging message * update CHANGELOG.md * update CHANGELOG.md * update logging for possible exceptions thrown when clearing temp folder * fix cloudflare captcha * update Final Fantasy VII: RI metadata * Update CHANGELOG.md * fix error * Update GameRegistry.cs * Updated GameFinder, Added EADesktop module * updated version number in CHANGELOG.md * updated logging code * update CHANGELOG.md * Fix Nexus login (#2476) * Fix Nexus login handler after API keys web page changes * Automatically press request button * Automatically press request API key button * Fix BG3 being named badlursgate3 in Game enum instead of baldursgate3 * Fix WebView2 taking up tons of memory, use single WebView window - still needs refactoring * Remove commented WebView * Add changelog, fix Wabbajack CLI bat pointing to the wrong directory --------- Co-authored-by: JanuarySnow <bobfordiscord12@gmail.com> Co-authored-by: JanuarySnow <85711747+JanuarySnow@users.noreply.github.com> Co-authored-by: UrbanCMC <UrbanCMC@web.de> Co-authored-by: EzioTheDeadPoet <52624146+EzioTheDeadPoet@users.noreply.github.com> Co-authored-by: Marco Antonio Jaguaribe Costa <marco.antonio.costa@gmail.com>
152 lines
6.0 KiB
C#
152 lines
6.0 KiB
C#
using System;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.IO;
|
|
using System.Reactive.Linq;
|
|
using System.Windows;
|
|
using System.Windows.Input;
|
|
using DynamicData.Binding;
|
|
using MahApps.Metro.Controls;
|
|
using Microsoft.Extensions.Logging;
|
|
using ReactiveUI;
|
|
using Wabbajack.Common;
|
|
using Wabbajack.Messages;
|
|
using Wabbajack.Paths.IO;
|
|
using Wabbajack.Util;
|
|
|
|
namespace Wabbajack
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for MainWindow.xaml
|
|
/// </summary>
|
|
public partial class MainWindow : MetroWindow
|
|
{
|
|
private MainWindowVM _mwvm;
|
|
private readonly ILogger<MainWindow> _logger;
|
|
private readonly SystemParametersConstructor _systemParams;
|
|
|
|
private ObservableCollection<ViewModel> TabVMs = new ObservableCollectionExtended<ViewModel>();
|
|
|
|
public MainWindow(ILogger<MainWindow> logger, SystemParametersConstructor systemParams, LauncherUpdater updater, MainWindowVM vm)
|
|
{
|
|
InitializeComponent();
|
|
_mwvm = vm;
|
|
DataContext = vm;
|
|
_logger = logger;
|
|
_systemParams = systemParams;
|
|
try
|
|
{
|
|
// Wire any unhandled crashing exceptions to log before exiting
|
|
AppDomain.CurrentDomain.UnhandledException += (sender, e) =>
|
|
{
|
|
// Don't do any special logging side effects
|
|
_logger.LogError((Exception)e.ExceptionObject, "Uncaught error");
|
|
Environment.Exit(-1);
|
|
};
|
|
|
|
Closed += (s, e) =>
|
|
{
|
|
_logger.LogInformation("Beginning shutdown...");
|
|
_mwvm.CancelRunningTasks(TimeSpan.FromSeconds(10));
|
|
|
|
// Cleaning the temp folder when the app closes since it can take up multiple Gigabytes of Storage
|
|
var tempDirectory = Environment.CurrentDirectory + "\\temp";
|
|
_logger.LogInformation("Clearing {TempDir}",tempDirectory);
|
|
var directoryInfo = new DirectoryInfo(tempDirectory);
|
|
try
|
|
{
|
|
foreach (var file in directoryInfo.EnumerateFiles())
|
|
{
|
|
file.Delete();
|
|
}
|
|
|
|
foreach (var dir in directoryInfo.EnumerateDirectories())
|
|
{
|
|
dir.Delete(true);
|
|
}
|
|
|
|
_logger.LogInformation("Finished clearing {TempDir}", tempDirectory);
|
|
}
|
|
catch (DirectoryNotFoundException)
|
|
{
|
|
_logger.LogInformation("Unable to find {TempDir}", tempDirectory);
|
|
}
|
|
|
|
Application.Current.Shutdown();
|
|
};
|
|
|
|
MessageBus.Current.Listen<TaskBarUpdate>()
|
|
.ObserveOnGuiThread()
|
|
.Subscribe(u =>
|
|
{
|
|
TaskbarItemInfoControl.Description = u.Description;
|
|
TaskbarItemInfoControl.ProgressValue = u.ProgressValue;
|
|
TaskbarItemInfoControl.ProgressState = u.State;
|
|
});
|
|
|
|
|
|
_logger.LogInformation("Wabbajack Build - {Sha}",ThisAssembly.Git.Sha);
|
|
_logger.LogInformation("Running in {EntryPoint}", KnownFolders.EntryPoint);
|
|
|
|
var p = _systemParams.Create();
|
|
|
|
_logger.LogInformation("Detected Windows Version: {Version}", Environment.OSVersion.VersionString);
|
|
|
|
_logger.LogInformation(
|
|
"System settings - ({MemorySize} RAM) ({PageSize} Page), Display: {ScreenWidth} x {ScreenHeight} ({Vram} VRAM - VideoMemorySizeMb={ENBVRam})",
|
|
p.SystemMemorySize.ToFileSizeString(), p.SystemPageSize.ToFileSizeString(), p.ScreenWidth, p.ScreenHeight, p.VideoMemorySize.ToFileSizeString(), p.EnbLEVRAMSize);
|
|
|
|
if (p.SystemPageSize == 0)
|
|
_logger.LogInformation( "Pagefile is disabled! Consider increasing to 20000MB. A disabled pagefile can cause crashes and poor in-game performance");
|
|
else if (p.SystemPageSize < 2e+10)
|
|
_logger.LogInformation("Pagefile below recommended! Consider increasing to 20000MB. A suboptimal pagefile can cause crashes and poor in-game performance");
|
|
|
|
var _ = updater.Run();
|
|
|
|
// Bring window to the front if it isn't already
|
|
this.Initialized += (s, e) =>
|
|
{
|
|
this.Activate();
|
|
this.Topmost = true;
|
|
this.Focus();
|
|
};
|
|
this.ContentRendered += (s, e) =>
|
|
{
|
|
this.Topmost = false;
|
|
};
|
|
|
|
((MainWindowVM) DataContext).WhenAnyValue(vm => vm.OpenSettingsCommand)
|
|
.BindTo(this, view => view.SettingsButton.Command);
|
|
|
|
((MainWindowVM)DataContext).WhenAnyValue(vm => vm.Installer.InstallState)
|
|
.ObserveOn(RxApp.MainThreadScheduler)
|
|
.Select(v => v == InstallState.Installing ? Visibility.Collapsed : Visibility.Visible)
|
|
.BindTo(this, view => view.SettingsButton.Visibility);
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
_logger.LogError(ex, "During Main Window Startup");
|
|
Environment.Exit(-1);
|
|
}
|
|
|
|
vm.WhenAnyValue(vm => vm.ResourceStatus)
|
|
.BindToStrict(this, view => view.ResourceUsage.Text);
|
|
vm.WhenAnyValue(vm => vm.AppName)
|
|
.BindToStrict(this, view => view.AppName.Text);
|
|
|
|
}
|
|
|
|
private void Window_Closing(object sender, CancelEventArgs e)
|
|
{
|
|
_mwvm.ShutdownApplication().Wait();
|
|
}
|
|
|
|
private void UIElement_OnMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
this.DragMove();
|
|
}
|
|
|
|
}
|
|
}
|