mirror of
https://github.com/4sval/FModel.git
synced 2026-03-28 12:45:36 -05:00
dpi scaling
This commit is contained in:
parent
0343ee3577
commit
e44a6a032f
|
|
@ -3,11 +3,14 @@ using System.Collections.Generic;
|
|||
using System.Diagnostics;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using ImGuiNET;
|
||||
using OpenTK.Graphics.OpenGL4;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using OpenTK.Windowing.GraphicsLibraryFramework;
|
||||
using ErrorCode = OpenTK.Graphics.OpenGL4.ErrorCode;
|
||||
using Keys = OpenTK.Windowing.GraphicsLibraryFramework.Keys;
|
||||
|
||||
namespace FModel.Framework;
|
||||
|
||||
|
|
@ -38,6 +41,7 @@ public class ImGuiController : IDisposable
|
|||
public ImFontPtr FontSemiBold;
|
||||
|
||||
private readonly Vector2 _scaleFactor = Vector2.One;
|
||||
public readonly float DpiScale = GetDpiScale();
|
||||
|
||||
private static bool KHRDebugAvailable = false;
|
||||
|
||||
|
|
@ -57,9 +61,9 @@ public class ImGuiController : IDisposable
|
|||
// ImGui.LoadIniSettingsFromDisk(_iniPath);
|
||||
|
||||
var io = ImGui.GetIO();
|
||||
FontNormal = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeui.ttf", 16);
|
||||
FontBold = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeuib.ttf", 16);
|
||||
FontSemiBold = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\seguisb.ttf", 16);
|
||||
FontNormal = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeui.ttf", 16*DpiScale);
|
||||
FontBold = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\segoeuib.ttf", 16*DpiScale);
|
||||
FontSemiBold = io.Fonts.AddFontFromFileTTF("C:\\Windows\\Fonts\\seguisb.ttf", 16*DpiScale);
|
||||
|
||||
io.BackendFlags |= ImGuiBackendFlags.RendererHasVtxOffset;
|
||||
io.ConfigFlags |= ImGuiConfigFlags.NavEnableKeyboard;
|
||||
|
|
@ -634,4 +638,9 @@ outputColor = color * texture(in_fontTexture, texCoord);
|
|||
Debug.Print($"{title} ({i++}): {error}");
|
||||
}
|
||||
}
|
||||
|
||||
public static float GetDpiScale()
|
||||
{
|
||||
return Math.Max((float)(Screen.PrimaryScreen.Bounds.Width / SystemParameters.PrimaryScreenWidth), (float)(Screen.PrimaryScreen.Bounds.Height / SystemParameters.PrimaryScreenHeight));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.Text.RegularExpressions;
|
|||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Forms;
|
||||
using AdonisUI.Controls;
|
||||
using CUE4Parse.Encryption.Aes;
|
||||
using CUE4Parse.FileProvider;
|
||||
|
|
@ -40,12 +41,14 @@ using FModel.Settings;
|
|||
using FModel.Views;
|
||||
using FModel.Views.Resources.Controls;
|
||||
using FModel.Views.Snooper;
|
||||
using ImGuiNET;
|
||||
using Newtonsoft.Json;
|
||||
using Ookii.Dialogs.Wpf;
|
||||
using OpenTK.Windowing.Common;
|
||||
using OpenTK.Windowing.Desktop;
|
||||
using Serilog;
|
||||
using SkiaSharp;
|
||||
using Application = System.Windows.Application;
|
||||
|
||||
namespace FModel.ViewModels;
|
||||
|
||||
|
|
@ -87,13 +90,14 @@ public class CUE4ParseViewModel : ViewModel
|
|||
{
|
||||
return Application.Current.Dispatcher.Invoke(delegate
|
||||
{
|
||||
float dpiScale = ImGuiController.GetDpiScale();
|
||||
return _snooper ??= new Snooper(
|
||||
new GameWindowSettings { RenderFrequency = Snooper.GetMaxRefreshFrequency() },
|
||||
new NativeWindowSettings
|
||||
{
|
||||
Size = new OpenTK.Mathematics.Vector2i(
|
||||
Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenWidth * .75),
|
||||
Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenHeight * .85)),
|
||||
Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenWidth * .75 * dpiScale),
|
||||
Convert.ToInt32(SystemParameters.MaximizedPrimaryScreenHeight * .85 * dpiScale)),
|
||||
NumberOfSamples = Constants.SAMPLES_COUNT,
|
||||
WindowBorder = WindowBorder.Resizable,
|
||||
Flags = ContextFlags.ForwardCompatible,
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user