--[[ ############################################################################## _____/\\\\\\\\\\\____/\\\________/\\\__/\\\________/\\\__/\\\\\\\\\\\_ # ___/\\\/////////\\\_\/\\\_______\/\\\_\/\\\_______\/\\\_\/////\\\///__ # __\//\\\______\///__\//\\\______/\\\__\/\\\_______\/\\\_____\/\\\_____ # ___\////\\\__________\//\\\____/\\\___\/\\\_______\/\\\_____\/\\\_____ # ______\////\\\________\//\\\__/\\\____\/\\\_______\/\\\_____\/\\\_____ # _________\////\\\______\//\\\/\\\_____\/\\\_______\/\\\_____\/\\\_____ # __/\\\______\//\\\______\//\\\\\______\//\\\______/\\\______\/\\\_____ # _\///\\\\\\\\\\\/________\//\\\________\///\\\\\\\\\/____/\\\\\\\\\\\_# ___\///////////___________\///___________\/////////_____\///////////_# ############################################################################## S U P E R - V I L L A I N - U I By: Munglunch # ############################################################################## ########################################################## LOCALIZED LUA FUNCTIONS ########################################################## ]]-- --[[ GLOBALS ]]-- local _G = _G; local unpack = _G.unpack; local select = _G.select; local type = _G.type; local tonumber = _G.tonumber; local string = _G.string; local math = _G.math; --[[ STRING METHODS ]]-- local match = string.match; --[[ MATH METHODS ]]-- local floor, abs, min, max = math.floor, math.abs, math.min, math.max; local parsefloat = math.parsefloat; --[[ ########################################################## GET ADDON DATA ########################################################## ]]-- local SuperVillain, L = unpack(select(2, ...)); --[[ ########################################################## LOCAL VARS ########################################################## ]]-- local scale; local rez = GetCVar("gxResolution"); local gxHeight = tonumber(match(rez,"%d+x(%d+)")); local gxWidth = tonumber(match(rez,"(%d+)x%d+")); local evalwidth --[[ ########################################################## CORE FUNCTIONS ########################################################## ]]-- function SuperVillain:UIScale(event) self.ghettoMonitor = nil; if(IsMacClient() and SVUI_Cache and SVUI_Cache.screenheight and SVUI_Cache.screenwidth) then if(gxHeight ~= SVUI_Cache.screenheight or gxWidth ~= SVUI_Cache.screenwidth) then gxHeight = SVUI_Cache.screenheight; gxWidth = SVUI_Cache.screenwidth end end; if self.db.system.autoScale then scale = max(0.64, min(1.15, 768 / gxHeight)) else scale = max(0.64, min(1.15, GetCVar("uiScale") or UIParent:GetScale() or 768 / gxHeight)) end if gxWidth < 1600 then self.ghettoMonitor = true; elseif gxWidth >= 3840 then local width = gxWidth; local height = gxHeight; if(self.db.system.multiMonitor) then if width >= 9840 then width = 3280; end if width >= 7680 and width < 9840 then width = 2560; end if width >= 5760 and width < 7680 then width = 1920; end if width >= 5040 and width < 5760 then width = 1680; end if width >= 4800 and width < 5760 and height == 900 then width = 1600; end if width >= 4320 and width < 4800 then width = 1440; end if width >= 4080 and width < 4320 then width = 1360; end if width >= 3840 and width < 4080 then width = 1224; end if width < 1600 then self.ghettoMonitor = true; end else if width >= 9840 then width = 9840; end if width >= 7680 and width < 9840 then width = 7680; end if width >= 5760 and width < 7680 then width = 5760; end if width >= 5040 and width < 5760 then width = 5040; end if width >= 4800 and width < 5040 then width = 4800; end if width >= 4320 and width < 4800 then width = 4320; end if width >= 4080 and width < 4320 then width = 4080; end if width >= 3840 and width < 4080 then width = 3840; end end evalwidth = width; end self.mult = 768 / match(GetCVar("gxResolution"), "%d+x(%d+)") / scale; if(parsefloat(UIParent:GetScale(),5) ~= parsefloat(scale,5) and (event == 'PLAYER_LOGIN')) then SetCVar("useUiScale",1) SetCVar("uiScale",scale) WorldMapFrame.hasTaint = true; end; if(event == 'PLAYER_LOGIN' or event == 'UI_SCALE_CHANGED') then if IsMacClient() then SVUI_Cache.screenheight = floor(GetScreenHeight() * 100 + .5) / 100 SVUI_Cache.screenwidth = floor(GetScreenWidth() * 100 + .5) / 100 end; if evalwidth then local width = evalwidth local height = gxHeight; if not self.db.system.autoScale or height > 1200 then local h = UIParent:GetHeight(); local ratio = gxHeight / h; local w = evalwidth / ratio; width = w; height = h; end self.UIParent:SetSize(width, height); else self.UIParent:SetSize(UIParent:GetSize()); end self.UIParent:ClearAllPoints() self.UIParent:SetPoint("CENTER") local change = abs((parsefloat(UIParent:GetScale(),5) * 100) - (parsefloat(scale,5) * 100)) if(event == 'UI_SCALE_CHANGED' and change > 1 and self.db.system.autoScale) then SuperVillain:StaticPopup_Show('FAILED_UISCALE') elseif(event == 'UI_SCALE_CHANGED' and change > 1) then SuperVillain:StaticPopup_Show('RL_CLIENT') end; SVUISystemEventHandler:UnregisterEvent('PLAYER_LOGIN') end end; function SuperVillain:Scale(value) return self.mult * floor(value / self.mult + .5); end;