From a82137eb15a92412d897d6a1472a7b6880376cc0 Mon Sep 17 00:00:00 2001 From: praxis <889+praxis@noreply.octowow.st> Date: Sun, 13 Sep 2026 09:52:14 +0000 Subject: [PATCH] Add modules/pixelperfect.lua --- modules/pixelperfect.lua | 45 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 modules/pixelperfect.lua diff --git a/modules/pixelperfect.lua b/modules/pixelperfect.lua new file mode 100644 index 0000000..ec4166d --- /dev/null +++ b/modules/pixelperfect.lua @@ -0,0 +1,45 @@ +pfUI:RegisterModule("pixelperfect", "vanilla:tbc", function () + -- pre-calculated min values + local statics = { + [4] = 1.4222222222222, + [5] = 1.1377777777778, + [6] = 0.94814814814815, + [7] = 0.81269841269841, + [8] = 0.71111111111111, + } + + -- pixel perfect + local function pixelperfect() + local conf = tonumber(C.global.pixelperfect) + if conf < 4 then + -- restore gamesettings + local scale = GetCVar("uiScale") + local use = GetCVar("useUiScale") + + if use == 1 then + UIParent:SetScale(tonumber(use)) + else + UIParent:SetScale(.9) + end + else + local scale = conf and statics[conf] or 1 + + SetCVar("uiScale", scale) + SetCVar("useUiScale", 1) + + UIParent:SetScale(scale) + end + end + + -- pixelperfect: native UIScale listener + if tonumber(C.global.pixelperfect) > 0 then + local f = CreateFrame("Frame") + f:RegisterEvent("PLAYER_ENTERING_WORLD") + f:SetScript("OnEvent", pixelperfect) + pixelperfect() + end + + pfUI.pixelperfect = { + UpdateConfig = pixelperfect + } +end)