mirror of
https://github.com/bloxstraplabs/bloxstrap.git
synced 2025-04-21 10:01:27 -07:00
Set default FPS limit as main display refresh rate
https: //cdn.discordapp.com/attachments/377894067712950275/1136002569660014653/image.png Co-Authored-By: $wag Messiah <135360571+sahelantrophus@users.noreply.github.com>
This commit is contained in:
parent
48afdd7036
commit
04dda07620
@ -1,5 +1,7 @@
|
|||||||
using System.Windows.Input;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media.Animation;
|
|
||||||
|
using Windows.Win32;
|
||||||
|
using Windows.Win32.Graphics.Gdi;
|
||||||
|
|
||||||
namespace Bloxstrap
|
namespace Bloxstrap
|
||||||
{
|
{
|
||||||
@ -152,12 +154,6 @@ namespace Bloxstrap
|
|||||||
SetValue(pair.Value, value);
|
SetValue(pair.Value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPresetOnce(string key, object? value)
|
|
||||||
{
|
|
||||||
if (GetPreset(key) is null)
|
|
||||||
SetPreset(key, value);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void SetPresetEnum(string prefix, string target, object? value)
|
public void SetPresetEnum(string prefix, string target, object? value)
|
||||||
{
|
{
|
||||||
foreach (var pair in PresetFlags.Where(x => x.Key.StartsWith(prefix)))
|
foreach (var pair in PresetFlags.Where(x => x.Key.StartsWith(prefix)))
|
||||||
@ -207,8 +203,24 @@ namespace Bloxstrap
|
|||||||
{
|
{
|
||||||
base.Load();
|
base.Load();
|
||||||
|
|
||||||
SetPresetOnce("Rendering.Framerate", 9999);
|
|
||||||
CheckManualFullscreenPreset();
|
CheckManualFullscreenPreset();
|
||||||
|
|
||||||
|
if (GetPreset("Rendering.Framerate") is not null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// set it to be the framerate of the primary display by default
|
||||||
|
|
||||||
|
var screen = Screen.AllScreens.Where(x => x.Primary).Single();
|
||||||
|
var devmode = new DEVMODEW();
|
||||||
|
|
||||||
|
PInvoke.EnumDisplaySettings(screen.DeviceName, ENUM_DISPLAY_SETTINGS_MODE.ENUM_CURRENT_SETTINGS, ref devmode);
|
||||||
|
|
||||||
|
uint framerate = devmode.dmDisplayFrequency;
|
||||||
|
|
||||||
|
if (framerate <= 100)
|
||||||
|
framerate *= 2;
|
||||||
|
|
||||||
|
SetPreset("Rendering.Framerate", framerate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,3 +2,4 @@
|
|||||||
FlashWindow
|
FlashWindow
|
||||||
GetWindowLong
|
GetWindowLong
|
||||||
SetWindowLong
|
SetWindowLong
|
||||||
|
EnumDisplaySettings
|
||||||
|
Loading…
Reference in New Issue
Block a user