You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

118 lines
3.7 KiB

4 years ago
local E, L, V, P, G = unpack(ElvUI)
5 years ago
local min, max, format = min, max, format
4 years ago
local _G = _G
5 years ago
local UIParent = UIParent
local GetScreenWidth = GetScreenWidth
4 years ago
local GetScreenHeight = GetScreenHeight
local InCombatLockdown = InCombatLockdown
4 years ago
local GetPhysicalScreenSize = GetPhysicalScreenSize
function E:RefreshGlobalFX() -- using RefreshModelScene will taint
_G.GlobalFXDialogModelScene:Hide()
_G.GlobalFXDialogModelScene:Show()
_G.GlobalFXMediumModelScene:Hide()
_G.GlobalFXMediumModelScene:Show()
_G.GlobalFXBackgroundModelScene:Hide()
_G.GlobalFXBackgroundModelScene:Show()
end
5 years ago
function E:IsEyefinity(width, height)
if E.global.general.eyefinity and width >= 3840 then
--HQ resolution
if width >= 9840 then return 3280 end --WQSXGA
if width >= 7680 and width < 9840 then return 2560 end --WQXGA
if width >= 5760 and width < 7680 then return 1920 end --WUXGA & HDTV
if width >= 5040 and width < 5760 then return 1680 end --WSXGA+
--Adding height condition here to be sure it work with bezel compensation because WSXGA+ and UXGA/HD+ got approx same width
if width >= 4800 and width < 5760 and height == 900 then return 1600 end --UXGA & HD+
--Low resolution screen
if width >= 4320 and width < 4800 then return 1440 end --WSXGA
if width >= 4080 and width < 4320 then return 1360 end --WXGA
if width >= 3840 and width < 4080 then return 1224 end --SXGA & SXGA (UVGA) & WXGA & HDTV
end
end
function E:IsUltrawide(width, height)
if E.global.general.ultrawide and width >= 2560 then
--HQ Resolution
if width >= 3440 and (height == 1440 or height == 1600) then return 2560 end --DQHD, DQHD+, WQHD & WQHD+
5 years ago
--Low resolution
if width >= 2560 and (height == 1080 or height == 1200) then return 1920 end --WFHD, DFHD & WUXGA
5 years ago
end
end
4 years ago
function E:UIMult()
E.mult = E.perfect / E.global.general.UIScale
end
function E:UIScale()
if InCombatLockdown() then
5 years ago
E:RegisterEventForObject('PLAYER_REGEN_ENABLED', E.UIScale, E.UIScale)
else -- E.Initialize
UIParent:SetScale(E.global.general.UIScale)
4 years ago
E.uiscale = UIParent:GetScale()
E.screenWidth, E.screenHeight = GetScreenWidth(), GetScreenHeight()
5 years ago
local width, height = E.physicalWidth, E.physicalHeight
5 years ago
E.eyefinity = E:IsEyefinity(width, height)
E.ultrawide = E:IsUltrawide(width, height)
local testing, newWidth = false, E.eyefinity or E.ultrawide
if testing then -- Resize E.UIParent if Eyefinity or UltraWide is on.
-- Eyefinity / UltraWide Test: 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.
width, height = E.screenWidth-250, E.screenHeight-250
5 years ago
elseif newWidth then -- Center E.UIParent
width, height = newWidth / (height / E.screenHeight), E.screenHeight
5 years ago
else
width, height = E.screenWidth, E.screenHeight
5 years ago
end
E.UIParent:SetSize(width, height)
E.UIParent.origHeight = E.UIParent:GetHeight()
4 years ago
if E.Retail then
E:RefreshGlobalFX()
end
5 years ago
if E:IsEventRegisteredForObject('PLAYER_REGEN_ENABLED', E.UIScale) then
E:UnregisterEventForObject('PLAYER_REGEN_ENABLED', E.UIScale, E.UIScale)
end
end
end
function E:PixelBestSize()
4 years ago
return max(0.4, min(1.15, E.perfect))
5 years ago
end
function E:PixelScaleChanged(event)
if event == 'UI_SCALE_CHANGED' then
E.physicalWidth, E.physicalHeight = GetPhysicalScreenSize()
E.resolution = format('%dx%d', E.physicalWidth, E.physicalHeight)
4 years ago
E.perfect = 768 / E.physicalHeight
5 years ago
end
4 years ago
E:UIMult()
E:UIScale()
5 years ago
E:Config_UpdateSize(true) -- Reposition config
end
4 years ago
function E:Scale(x)
5 years ago
local m = E.mult
4 years ago
if m == 1 or x == 0 then
return x
else
local y = m > 1 and m or -m
return x - x % (x < 0 and y or -y)
end
5 years ago
end