test pixelperfect

This commit is contained in:
Crum
2018-08-14 00:46:33 -05:00
parent 2dc86cee33
commit 77a50a3fc0
+37 -52
View File
@@ -5,40 +5,34 @@ local E, L, V, P, G = unpack(ElvUI); --Import: Engine, Locales, PrivateDB, Profi
local abs, floor, min, max = math.abs, math.floor, math.min, math.max local abs, floor, min, max = math.abs, math.floor, math.min, math.max
local match = string.match local match = string.match
--WoW API / Variables --WoW API / Variables
local IsMacClient = IsMacClient
local GetCVar, SetCVar = GetCVar, SetCVar local GetCVar, SetCVar = GetCVar, SetCVar
local GetScreenHeight, GetScreenWidth = GetScreenHeight, GetScreenWidth
local scale local scale
function E:UIScale(event) function E:UIScale(event)
-- if IsMacClient() and self.global.screenheight and self.global.screenwidth and (self.screenheight ~= self.global.screenheight or self.screenwidth ~= self.global.screenwidth) then local width = E.screenwidth
-- self.screenheight = self.global.screenheight local height = E.screenheight
-- self.screenwidth = self.global.screenwidth
-- end
if GetCVar("UIScale") then local uiScaleCVar = GetCVar("uiScale")
self.global.uiScale = GetCVar("UIScale") if uiScaleCVar then
E.global.uiScale = uiScaleCVar
end end
local minScale = self.global.general.minUiScale or 0.64 local minScale = E.global.general.minUiScale or 0.64
if self.global.general.autoScale then if E.global.general.autoScale then
scale = max(minScale, min(1.00, 768/self.screenheight)) scale = max(minScale, min(1.15, 768/height))
else else
scale = max(minScale, min(1.00, self.global.uiScale or (self.screenheight > 0 and (768/self.screenheight)) or UIParent:GetScale())) scale = max(minScale, min(1.15, E.global.uiScale or (height > 0 and (768/height)) or UIParent:GetScale()))
end end
if self.screenwidth < 1600 then if width < 1600 then
self.lowversion = true E.lowversion = true
elseif self.screenwidth >= 3840 and self.global.general.eyefinity then elseif width >= 3840 and E.global.general.eyefinity then
local width = self.screenwidth
local height = self.screenheight
-- because some user enable bezel compensation, we need to find the real width of a single monitor. -- because some user enable bezel compensation, we need to find the real width of a single monitor.
-- I don't know how it really work, but i'm assuming they add pixel to width to compensate the bezel. :P -- I don't know how it really work, but i'm assuming they add pixel to width to compensate the bezel. :P
-- HQ resolution -- HQ resolution
if width >= 9840 then width = 3280; end -- WQSXGA if width >= 9840 then width = 3280 end -- WQSXGA
if width >= 7680 and width < 9840 then width = 2560 end -- WQXGA if width >= 7680 and width < 9840 then width = 2560 end -- WQXGA
if width >= 5760 and width < 7680 then width = 1920 end -- WUXGA & HDTV if width >= 5760 and width < 7680 then width = 1920 end -- WUXGA & HDTV
if width >= 5040 and width < 5760 then width = 1680 end -- WSXGA+ if width >= 5040 and width < 5760 then width = 1680 end -- WSXGA+
@@ -53,16 +47,16 @@ function E:UIScale(event)
-- yep, now set ElvUI to lower resolution if screen #1 width < 1600 -- yep, now set ElvUI to lower resolution if screen #1 width < 1600
if width < 1600 then if width < 1600 then
self.lowversion = true E.lowversion = true
end end
-- register a constant, we will need it later for launch.lua -- register a constant, we will need it later for launch.lua
self.eyefinity = width E.eyefinity = width
end end
self.mult = 768/self.screenheight/scale E.mult = 768/height/scale
self.Spacing = self.PixelMode and 0 or self.mult E.Spacing = E.PixelMode and 0 or E.mult
self.Border = (self.PixelMode and self.mult or self.mult*2) E.Border = (E.PixelMode and E.mult or E.mult*2)
if E.global.general.autoScale then if E.global.general.autoScale then
--Set UIScale, NOTE: SetCVar for UIScale can cause taints so only do this when we need to.. --Set UIScale, NOTE: SetCVar for UIScale can cause taints so only do this when we need to..
@@ -78,44 +72,35 @@ function E:UIScale(event)
end end
if event == "PLAYER_LOGIN" or (event == "CVAR_UPDATE" and arg1 == "USE_UISCALE") then if event == "PLAYER_LOGIN" or (event == "CVAR_UPDATE" and arg1 == "USE_UISCALE") then
if IsMacClient() then --Resize E.UIParent if Eyefinity is on.
self.global.screenheight = floor(GetScreenHeight()*100+.5)/100 if E.eyefinity then
self.global.screenwidth = floor(GetScreenWidth()*100+.5)/100 -- if autoscale is off, find a new width value of E.UIParent for screen #1.
end if not E.global.general.autoScale or height > 1200 then
self.UIParent:ClearAllPoints()
--Resize self.UIParent if Eyefinity is on.
if self.eyefinity then
local width = self.eyefinity
local height = self.screenheight
-- if autoscale is off, find a new width value of self.UIParent for screen #1.
if not self.global.general.autoScale or height > 1200 then
local h = UIParent:GetHeight() local h = UIParent:GetHeight()
local ratio = self.screenheight / h local ratio = height / h
local w = self.eyefinity / ratio local w = width / ratio
width = w width = w
height = h height = h
end end
self.UIParent:SetPoint("CENTER", UIParent)
E:Size(self.UIParent, width, height)
else
--[[Eyefinity Test mode --[[Eyefinity Test mode
Resize the E.UIParent to be smaller than it should be, all objects inside should relocate. Resize the E.UIParent to be smaller than it should be, all objects inside should relocate.
Dragging moveable frames outside the box and reloading the UI ensures that they are saving position correctly. Dragging moveable frames outside the box and reloading the UI ensures that they are saving position correctly.
]] ]]
--self.UIParent:SetSize(UIParent:GetWidth() - 250, UIParent:GetHeight() - 250); else
width = UIParent:GetWidth()
--E:Size(self.UIParent, GetScreenWidth(), GetScreenHeight()) height = UIParent:GetHeight()
self.UIParent:SetAllPoints(UIParent)
end end
self.diffGetLeft = E:Round(abs(UIParent:GetLeft() - self.UIParent:GetLeft())) E.UIParent:SetWidth(width)
self.diffGetRight = E:Round(abs(UIParent:GetRight() - self.UIParent:GetRight())) E.UIParent:SetHeight(height)
self.diffGetTop = E:Round(abs(UIParent:GetTop() - self.UIParent:GetTop())) E.UIParent:ClearAllPoints()
self.diffGetBottom = E:Round(abs(UIParent:GetBottom() - self.UIParent:GetBottom())) E.UIParent:SetAllPoints(UIParent)
E.diffGetLeft = E:Round(abs(UIParent:GetLeft() - E.UIParent:GetLeft()))
E.diffGetRight = E:Round(abs(UIParent:GetRight() - E.UIParent:GetRight()))
E.diffGetTop = E:Round(abs(UIParent:GetTop() - E.UIParent:GetTop()))
E.diffGetBottom = E:Round(abs(UIParent:GetBottom() - E.UIParent:GetBottom()))
local change local change
if E.Round then if E.Round then
@@ -136,5 +121,5 @@ end
-- pixel perfect script of custom ui scale. -- pixel perfect script of custom ui scale.
function E:Scale(x) function E:Scale(x)
return self.mult*floor(x/self.mult+.5) return E.mult*floor(x/E.mult+.5)
end end