Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Commit

Permalink
Fixed resolution detection for Game Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravo92 committed Aug 24, 2024
1 parent 2773e06 commit 9b7f558
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion AllInOneLauncher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public partial class App : Application
internal static string[] Args = [];
private const string PipeName = Constants.C_NAMED_PIPE_NAME;

public static CoreWebView2Environment GlobalWebView2Environment { get; private set; }
public static CoreWebView2Environment? GlobalWebView2Environment { get; private set; }

protected override async void OnStartup(StartupEventArgs e)
{
Expand Down
1 change: 0 additions & 1 deletion AllInOneLauncher/Logic/BfmeLaunchManager.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
using AllInOneLauncher.Data;
using BfmeFoundationProject.BfmeRegistryManagement;
using BfmeFoundationProject.BfmeRegistryManagement.Data;
Expand Down
16 changes: 13 additions & 3 deletions AllInOneLauncher/Logic/SystemDisplayManager.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows.Forms;

Expand Down Expand Up @@ -45,19 +46,28 @@ public struct DEVMODE
public static List<string> GetAllSupportedResolutions()
{
List<string> allResolutions = [];

DEVMODE vDevMode = new();
int i = 0;

while (EnumDisplaySettings(null, i, ref vDevMode))
{
if (vDevMode.dmDisplayFrequency == 60 && vDevMode.dmBitsPerPel == 32 && vDevMode.dmDisplayFixedOutput == 0)
allResolutions.Add(vDevMode.dmPelsWidth.ToString() + " " + vDevMode.dmPelsHeight.ToString());
{
string resolution = vDevMode.dmPelsWidth + " " + vDevMode.dmPelsHeight;
allResolutions.Add(resolution);
}

i++;
}

allResolutions = allResolutions
.Select(r => new { Resolution = r, Width = int.Parse(r.Split(' ')[0]), Height = int.Parse(r.Split(' ')[1]) })
.OrderBy(r => r.Width)
.ThenBy(r => r.Height)
.Select(r => r.Resolution)
.ToList();

allResolutions.RemoveRange(0, Math.Min(3, allResolutions.Count));
allResolutions[^1] = allResolutions[^1];

return allResolutions;
}
Expand Down

0 comments on commit 9b7f558

Please # to comment.