View Single Post
12-15-18, 08:40 PM   #4
Lyak
A Cyclonian
Join Date: Jul 2018
Posts: 46
Originally Posted by d87 View Post
WoW screen is using these sort of floating point virtual pixels, they go up to 768 in height and proportionally for aspect ratio in width, and they map onto your real resolution. And then there's possibly global UI scale in the mix. In the end the line that you wanted to be 2 virtual pixels wide ends up snapping to either 2 or 3 real pixels depending on where it is
So you need to reverse this process and find out what amount of virtual pixels is corresponding to real pixels

Here's what i use to find it:
Code:
local res = GetCVar("gxWindowedResolution")
if res then
    local w,h = string.match(res, "(%d+)x(%d+)")
    pmult = (768/h) / UIParent:GetScale()
end
Not sure if consistently using whole number of real pixels guarantees perfection, but in my experience it makes it better at least. Also ideally you don't want to use UI scale
So, basically what wow does is it take the real value, goes through some calculation then converts the real value to wow sepcific virtual value. Am I getting it right?

And after all what I'll have to do is multiply pmult whenever I'm setting the position or the size?

Like:
Lua Code:
  1. frame:SetSize(width * pmult, height * pmult);
  2. frame:SetPoint("CENTER", UIParent, "CENTER", oX * pmult, oY * pmult);

Originally Posted by myrroddin View Post
If your display, or if writing a public addon, the user's display, is greater than 1920x1080, you need to do two things:
  1. Set the CVar scale to 768/height
  2. Set UIParent's scale to 768/height
This is because WoW won't let you set a CVar scale lower than 0.64 which won't look correct on monitors with a resolution greater than 1080p.

If the height is equal to or less than 1920, only do the first thing. Now here are the hard parts:
  1. Scale your frame initially by the above scale, in which it will look tiny with unreadable text.
  2. Increase the height and/or width of the frame until it looks good, but leave the scale alone.
  3. As mentioned, you need to place your newly scaled frame on an even pixel, unless that isn't centered. You'll have to figure that out frame by frame.
  4. Assuming you let the user set a scale, which is a bad idea at this point, wrap your "user scale" instead in height or width adjustments providing the illusion of scaling up or down. A better idea is to not provide a scaling option and go straight for height or width.
  5. Place the adjusted frame again so it sits evenly.
Let me get things one by one.

If the screen size is greater than 1920x1080, I'll have to set both UIScale CVar and UIParent's scale to 768/height as you have advised. However, if I switch UIParent's scale to such, wouldn't that affect all other frames having UIParent as a parent frame? If the answer is yes, would it be okay to use my own UIParent like the following to avoid such issues?

Lua Code:
  1. local uiParent = CreateFrame("Frame", nil, UIParent);
  2. uiParent:SetAllPoints(true);
  3. uiParent:SetScale(xxxx);
  4.  
  5. addon.UIParent = uiParent;
  6.  
  7. local frame = CreateFrame("Frame", nil, addon.UIParent);
  8. -- Continue positioning, sizing and etc.

Last edited by Lyak : 12-15-18 at 08:43 PM.
  Reply With Quote