Accurately determine the selected screen resolution

I am currently trying to write an addon which switching my Edit Mode profile depending on the screen size (as my Steam Deck has more than one depending on if I use the built in or external screen).

However whenever I use the following code (even with 100% UI and render scale):

local width = math.floor(GetScreenWidth())
local height = math.floor(GetScreenHeight())
local uiScale = 100

if GetCVar("useUiScale") == "1" then
   uiScale = math.floor(UIParent:GetEffectiveScale() * 100)
end

print (width .. "x" .. height .. " " .. uiScale .. "%")

2560x1440 native returns ā€œ2133x1200 100%ā€.

My plan is to have it match resolution by name either strictly ā€œ2560x1440ā€ or losely ā€œ1440pā€ and the actual profile selection already works, but it is kinda counter intuitive to need to create a profile ā€œ1200pā€ for use on a 1440p display. :expressionless:

Can anyone assist?

Managed to resolve this with some help from the guys on Discord.

The solution was to instead use:

local width, height = GetPhysicalScreenSize()

This returns the true display size as set in the graphics menu, my first addon is complete!

2 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.