-
Notifications
You must be signed in to change notification settings - Fork 0
/
NameplateScaling.lua
62 lines (51 loc) · 2.1 KB
/
NameplateScaling.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local feature = ns.Register({
identifier = "NameplateScaling",
description = "Nameplates should respect global UI scale.",
category = "interface",
config = {
nameplate = {
base = 115,
notch = 25,
height = 35,
scaleTweak = 0.05,
}
}
})
local frame = CreateFrame("Frame")
frame:RegisterEvent("ADDON_LOADED")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
local function IsNamePlateFrame(frame)
local overlayRegion = frame:GetRegions()
if not overlayRegion or overlayRegion:GetObjectType() ~= "Texture" or overlayRegion:GetTexture() ~= "Interface\\Tooltips\\Nameplate-Border" then
return false
end
return true
end
frame:SetScript("OnEvent", function()
if not ns.IsEnabled(feature.identifier) then return end
end)
frame:SetScript("OnUpdate", function()
if not ns.IsEnabled(feature.identifier) then return end
local frames = {WorldFrame:GetChildren()}
local scale = UIParent:GetScale() - feature.config.nameplate.scaleTweak
for _, nameplate in ipairs(frames) do
if IsNamePlateFrame(nameplate) then
local HealthBar = nameplate:GetChildren()
local Border, Glow, Name, Level = nameplate:GetRegions()
nameplate:SetWidth((feature.config.nameplate.base + feature.config.nameplate.notch) * scale)
nameplate:SetHeight(feature.config.nameplate.height * scale)
HealthBar:ClearAllPoints()
HealthBar:SetWidth(feature.config.nameplate.base * scale)
HealthBar:SetHeight(((feature.config.nameplate.height / 2) - (5 * scale)) * scale)
HealthBar:SetPoint("BOTTOM", nameplate, "BOTTOM", -(8 * scale), (2 * scale))
Name:ClearAllPoints()
Name:SetFont(STANDARD_TEXT_FONT, (12 * scale), "OUTLINE")
Name:SetPoint("BOTTOM", nameplate, "BOTTOM", 0, (16 * scale) + (3 * scale))
Name:SetShadowColor(0, 0, 0, .3)
Level:ClearAllPoints()
Level:SetPoint("BOTTOM", nameplate, "BOTTOM", (((feature.config.nameplate.base / 2)) * scale), ((feature.config.nameplate.height / 2) * scale) - (12 * scale))
Level:SetFont(UNIT_NAME_FONT, (9 * scale), "OUTLINE")
Level:SetShadowColor(0, 0, 0, .3)
end
end
end)