Move system startup info into the constructor class

This commit is contained in:
Timothy Baldridge 2022-01-20 21:21:48 -07:00
parent 9beafe8da4
commit 87e0a59371
3 changed files with 24 additions and 29 deletions

View File

@ -20,36 +20,9 @@ public partial class MainWindow
_logger = logger; _logger = logger;
_loggerProvider = loggerProvider; _loggerProvider = loggerProvider;
_systemParams = systemParams; _systemParams = systemParams;
InitializeComponent(); InitializeComponent();
BlazorWebView.Services = serviceProvider; 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);
}
} }
} }

View File

@ -11,6 +11,7 @@ using Silk.NET.DXGI;
using Wabbajack.Common; using Wabbajack.Common;
using Wabbajack.Installer; using Wabbajack.Installer;
using Wabbajack; using Wabbajack;
using Wabbajack.Paths.IO;
using static PInvoke.User32; using static PInvoke.User32;
using UnmanagedType = System.Runtime.InteropServices.UnmanagedType; using UnmanagedType = System.Runtime.InteropServices.UnmanagedType;
@ -25,6 +26,12 @@ public class SystemParametersConstructor
public SystemParametersConstructor(ILogger<SystemParametersConstructor> logger) public SystemParametersConstructor(ILogger<SystemParametersConstructor> logger)
{ {
_logger = 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() private IEnumerable<(int Width, int Height, bool IsPrimary)> GetDisplays()
@ -111,7 +118,7 @@ public class SystemParametersConstructor
} }
MEMORYSTATUSEX? memory = GetMemoryStatus(); MEMORYSTATUSEX? memory = GetMemoryStatus();
return new SystemParameters var p = new SystemParameters
{ {
ScreenWidth = width, ScreenWidth = width,
ScreenHeight = height, ScreenHeight = height,
@ -119,6 +126,20 @@ public class SystemParametersConstructor
SystemMemorySize = (long)memory.ullTotalPhys, SystemMemorySize = (long)memory.ullTotalPhys,
SystemPageSize = (long)memory.ullTotalPageFile - (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)] [return: MarshalAs(UnmanagedType.Bool)]

View File

@ -15,6 +15,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="DynamicData" Version="7.4.9" /> <PackageReference Include="DynamicData" Version="7.4.9" />
<PackageReference Include="GitInfo" Version="2.2.0" />
<PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" /> <PackageReference Include="Microsoft-WindowsAPICodePack-Shell" Version="1.1.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.101-preview.11.2349" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="6.0.101-preview.11.2349" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="6.0.0" />