pixel perfect option added

This commit is contained in:
Sumsebrum 2021-09-22 17:12:10 +02:00
parent 069ca47210
commit 1010d59bd3
3 changed files with 40 additions and 5 deletions

View File

@ -190,6 +190,7 @@ function Gladdy:UpdateFrame()
end
self.frame:SetScale(self.db.frameScale)
self:PixelPerfectScale(false)
self.frame:SetWidth(width)
self.frame:SetHeight(height)
self.frame:ClearAllPoints()

View File

@ -5,6 +5,7 @@ local select = select
local pairs = pairs
local tinsert = table.insert
local tsort = table.sort
local str_lower = string.lower
local GetTime = GetTime
local CreateFrame = CreateFrame
local DEFAULT_CHAT_FRAME = DEFAULT_CHAT_FRAME
@ -66,10 +67,20 @@ end
Gladdy.events = CreateFrame("Frame")
Gladdy.events.registered = {}
Gladdy.events:RegisterEvent("PLAYER_LOGIN")
Gladdy.events:RegisterEvent("CVAR_UPDATE")
hooksecurefunc("VideoOptionsFrameOkay_OnClick", function(self, button, down, apply)
if (self:GetName() == "VideoOptionsFrameApply") then
Gladdy:PixelPerfectScale(true)
end
end)
Gladdy.events:SetScript("OnEvent", function(self, event, ...)
if (event == "PLAYER_LOGIN") then
Gladdy:OnInitialize()
Gladdy:OnEnable()
elseif (event == "CVAR_UPDATE") then
if (str_lower(select(1, ...)) == "uiscale") then
Gladdy:PixelPerfectScale(true)
end
else
local func = self.registered[event]
@ -186,6 +197,21 @@ function Gladdy:DeleteUnknownOptions(tbl, refTbl, str)
end
end
function Gladdy:PixelPerfectScale(update)
local physicalWidth, physicalHeight = GetPhysicalScreenSize()
local perfectUIScale = 768/physicalHeight--768/select(2, strsplit("x",({ GetScreenResolutions()})[GetCurrentResolution()]))
if self.db and self.db.pixelPerfect and self.frame then
self.frame:SetIgnoreParentScale(true)
self.frame:SetScale(perfectUIScale)
--self.db.frameScale = perfectUIScale --(GetCVar("useUiScale") == "1" and 1 + perfectUIScale - GetCVar("UIScale") or perfectUIScale)
if update then
self:UpdateFrame()
end
elseif self.frame then
self.frame:SetIgnoreParentScale(false)
end
end
function Gladdy:OnInitialize()
self.dbi = LibStub("AceDB-3.0"):New("GladdyXZ", self.defaults)
self.dbi.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")

View File

@ -50,6 +50,7 @@ Gladdy.defaults = {
growUp = false,
growDirection = "BOTTOM",
frameScale = 1,
pixelPerfect = false,
padding = 1,
barWidth = 180,
bottomMargin = 2,
@ -298,11 +299,18 @@ function Gladdy:SetupOptions()
name = L["Frame General"],
order = 3,
},
pixelPerfect = {
type = "toggle",
name = L["Pixel Perfect Scale"],
desc = L["Enables Pixel Perfect Scale - disables manual "].. L["Frame scale"],
order = 4,
},
frameScale = {
type = "range",
name = L["Frame scale"],
desc = L["Scale of the frame"],
order = 4,
disabled = function() return Gladdy.db.pixelPerfect end,
order = 5,
min = .1,
max = 2,
step = .01,
@ -311,7 +319,7 @@ function Gladdy:SetupOptions()
type = "range",
name = L["Frame padding"],
desc = L["Padding of the frame"],
order = 5,
order = 6,
min = 0,
max = 20,
step = 1,
@ -320,7 +328,7 @@ function Gladdy:SetupOptions()
type = "range",
name = L["Frame width"],
desc = L["Width of the bars"],
order = 6,
order = 7,
min = 10,
max = 500,
step = 5,
@ -329,7 +337,7 @@ function Gladdy:SetupOptions()
type = "range",
name = L["Margin"],
desc = L["Margin between each button"],
order = 7,
order = 8,
min = -200,
max = 200,
step = 1,
@ -338,7 +346,7 @@ function Gladdy:SetupOptions()
type = "color",
name = L["Background color"],
desc = L["Background Color of the frame"],
order = 8,
order = 9,
hasAlpha = true,
get = getColorOpt,
set = setColorOpt,