-- ForeverScale: re-applies a fixed UIParent scale on every login/reload, -- so values below Blizzard's 0.64 slider floor stick. -- /fscale 0.5333 set a scale (0.30 - 1.50), saved account-wide -- /fscale pixel pixel-perfect: 768 / your vertical resolution, worked out -- again whenever the resolution changes. Not limited to -- 0.30 - 1.50, so on 5K/6K screens it goes below 0.30. -- /fscale reset stop overriding (then /reload) local ADDON = ... local f = CreateFrame("Frame") -- the scale to enforce, or nil if there is no override local function target() local db = ForeverScaleDB if not db then return end if db.pixel then local _, h = GetPhysicalScreenSize() if h and h > 0 then return 768 / h end return end return db.scale end local function apply() local s = target() if not s then return end if InCombatLockdown() then -- UIParent has protected children; wait until combat ends f:RegisterEvent("PLAYER_REGEN_ENABLED") return end if math.abs(UIParent:GetScale() - s) > 0.0001 then UIParent:SetScale(s) end end f:RegisterEvent("ADDON_LOADED") f:RegisterEvent("PLAYER_LOGIN") f:RegisterEvent("PLAYER_ENTERING_WORLD") f:RegisterEvent("UI_SCALE_CHANGED") f:RegisterEvent("DISPLAY_SIZE_CHANGED") f:SetScript("OnEvent", function(self, event, arg1) if event == "ADDON_LOADED" then if arg1 == ADDON then ForeverScaleDB = ForeverScaleDB or {} self:UnregisterEvent("ADDON_LOADED") end return end if event == "PLAYER_REGEN_ENABLED" then self:UnregisterEvent("PLAYER_REGEN_ENABLED") end -- Blizzard may re-apply its own scale during these events; go after it C_Timer.After(0, apply) end) SLASH_FOREVERSCALE1 = "/fscale" SlashCmdList.FOREVERSCALE = function(msg) msg = strtrim(msg or ""):lower() if msg == "reset" then ForeverScaleDB.scale, ForeverScaleDB.pixel = nil, nil print("ForeverScale: override cleared. /reload to return to Blizzard's scale.") return elseif msg == "pixel" then ForeverScaleDB.scale, ForeverScaleDB.pixel = nil, true else local v = tonumber(msg) if not v or v < 0.3 or v > 1.5 then print(string.format( "ForeverScale: /fscale <0.30-1.50> | pixel | reset (current %.4f)", UIParent:GetScale())) return end ForeverScaleDB.scale, ForeverScaleDB.pixel = v, nil end apply() print(string.format("ForeverScale: scale set to %.4f%s%s", target() or UIParent:GetScale(), ForeverScaleDB.pixel and " (pixel, follows your resolution)" or "", InCombatLockdown() and " (applies after combat)" or "")) end