From 87e0a59371da17aa9b989a3579aaa9984b063708 Mon Sep 17 00:00:00 2001 From: Timothy Baldridge Date: Thu, 20 Jan 2022 21:21:48 -0700 Subject: [PATCH] Move system startup info into the constructor class --- Wabbajack.App.Blazor/MainWindow.xaml.cs | 29 +------------------ .../Utility/SystemParametersConstructor.cs | 23 ++++++++++++++- .../Wabbajack.App.Blazor.csproj | 1 + 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/Wabbajack.App.Blazor/MainWindow.xaml.cs b/Wabbajack.App.Blazor/MainWindow.xaml.cs index 16d44579..fe4315dc 100644 --- a/Wabbajack.App.Blazor/MainWindow.xaml.cs +++ b/Wabbajack.App.Blazor/MainWindow.xaml.cs @@ -20,36 +20,9 @@ public partial class MainWindow _logger = logger; _loggerProvider = loggerProvider; _systemParams = systemParams; + InitializeComponent(); BlazorWebView.Services = serviceProvider; - - try - { - // TODO: [Low] Not sure how to set this up. - //_logger.LogInformation("Wabbajack Build - {Sha}", ThisAssembly.Git.Sha); - _logger.LogInformation("Running in {EntryPoint}", KnownFolders.EntryPoint); - - SystemParameters 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( - "Page file is disabled! Consider increasing to 20000MB. A disabled page file can cause crashes and poor in-game performance"); - else if (p.SystemPageSize < 2e+10) - _logger.LogInformation( - "Page file below recommended! Consider increasing to 20000MB. A suboptimal page file can cause crashes and poor in-game performance"); - } - catch (Exception ex) - { - _logger.LogError(ex, "Error during Main Window startup."); - Environment.Exit(-1); - } } } diff --git a/Wabbajack.App.Blazor/Utility/SystemParametersConstructor.cs b/Wabbajack.App.Blazor/Utility/SystemParametersConstructor.cs index ceccbc7f..172da1c7 100644 --- a/Wabbajack.App.Blazor/Utility/SystemParametersConstructor.cs +++ b/Wabbajack.App.Blazor/Utility/SystemParametersConstructor.cs @@ -11,6 +11,7 @@ using Silk.NET.DXGI; using Wabbajack.Common; using Wabbajack.Installer; using Wabbajack; +using Wabbajack.Paths.IO; using static PInvoke.User32; using UnmanagedType = System.Runtime.InteropServices.UnmanagedType; @@ -25,6 +26,12 @@ public class SystemParametersConstructor public SystemParametersConstructor(ILogger logger) { _logger = logger; + + _logger.LogInformation("Wabbajack Build - {Sha}", ThisAssembly.Git.Sha); + _logger.LogInformation("Running in {EntryPoint}", KnownFolders.EntryPoint); + + _logger.LogInformation("Detected Windows Version: {Version}", Environment.OSVersion.VersionString); + } private IEnumerable<(int Width, int Height, bool IsPrimary)> GetDisplays() @@ -111,7 +118,7 @@ public class SystemParametersConstructor } MEMORYSTATUSEX? memory = GetMemoryStatus(); - return new SystemParameters + var p = new SystemParameters { ScreenWidth = width, ScreenHeight = height, @@ -119,6 +126,20 @@ public class SystemParametersConstructor SystemMemorySize = (long)memory.ullTotalPhys, SystemPageSize = (long)memory.ullTotalPageFile - (long)memory.ullTotalPhys }; + + _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( + "Page file is disabled! Consider increasing to 20000MB. A disabled page file can cause crashes and poor in-game performance"); + else if (p.SystemPageSize < 2e+10) + _logger.LogInformation( + "Page file below recommended! Consider increasing to 20000MB. A suboptimal page file can cause crashes and poor in-game performance"); + + return p; } [return: MarshalAs(UnmanagedType.Bool)] diff --git a/Wabbajack.App.Blazor/Wabbajack.App.Blazor.csproj b/Wabbajack.App.Blazor/Wabbajack.App.Blazor.csproj index fcf6e622..ee422013 100644 --- a/Wabbajack.App.Blazor/Wabbajack.App.Blazor.csproj +++ b/Wabbajack.App.Blazor/Wabbajack.App.Blazor.csproj @@ -15,6 +15,7 @@ +