2021-05-17 16:49:54 +02:00
|
|
|
local CreateFrame = CreateFrame
|
|
|
|
local UIParent = UIParent
|
|
|
|
local InCombatLockdown = InCombatLockdown
|
2022-01-11 00:29:17 +01:00
|
|
|
local math_abs = math.abs
|
|
|
|
local pairs = pairs
|
|
|
|
local LibStub = LibStub
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
local Gladdy = LibStub("Gladdy")
|
|
|
|
local L = Gladdy.L
|
|
|
|
|
|
|
|
Gladdy.BUTTON_DEFAULTS = {
|
|
|
|
name = "",
|
|
|
|
guid = "",
|
|
|
|
raceLoc = "",
|
|
|
|
classLoc = "",
|
|
|
|
class = "",
|
|
|
|
health = "",
|
|
|
|
healthMax = 0,
|
|
|
|
power = 0,
|
|
|
|
powerMax = 0,
|
|
|
|
powerType = 0,
|
|
|
|
spec = "",
|
|
|
|
testSpec = "",
|
|
|
|
spells = {},
|
|
|
|
ns = false,
|
|
|
|
nf = false,
|
|
|
|
pom = false,
|
|
|
|
fd = false,
|
|
|
|
damaged = 0,
|
|
|
|
click = false,
|
|
|
|
stealthed = false,
|
2021-06-16 14:10:49 +02:00
|
|
|
classColors = {},
|
|
|
|
lastState = 0,
|
2021-05-17 16:49:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function Gladdy:CreateFrame()
|
|
|
|
self.frame = CreateFrame("Frame", "GladdyFrame", UIParent)
|
2021-07-26 17:30:46 +02:00
|
|
|
|
|
|
|
self.frame.background = CreateFrame("Frame", nil, self.frame, BackdropTemplateMixin and "BackdropTemplate")
|
|
|
|
self.frame.background:SetBackdrop({bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = false, tileSize = 16})
|
|
|
|
self.frame.background:SetFrameStrata("BACKGROUND")
|
2022-01-12 23:07:23 +01:00
|
|
|
self.frame.background:SetBackdropColor(Gladdy:SetColor(self.db.backgroundColor))
|
2021-07-26 17:30:46 +02:00
|
|
|
self.frame.background:SetAllPoints(self.frame)
|
2021-05-22 13:41:31 +02:00
|
|
|
--self.frame.texture = self.frame:CreateTexture(nil, "OVERLAY")
|
|
|
|
--self.frame.texture:SetAllPoints(self.frame)
|
|
|
|
--self.frame.texture:SetTexture("Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
self.frame:SetClampedToScreen(true)
|
2021-05-19 19:30:32 +02:00
|
|
|
self.frame:EnableMouse(false)
|
2021-05-17 16:49:54 +02:00
|
|
|
self.frame:SetMovable(true)
|
2022-01-11 00:29:17 +01:00
|
|
|
--self.frame:RegisterForDrag("LeftButton")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
self.frame:SetScript("OnDragStart", function(f)
|
|
|
|
if (not InCombatLockdown() and not self.db.locked) then
|
|
|
|
f:StartMoving()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
self.frame:SetScript("OnDragStop", function(f)
|
|
|
|
if (not InCombatLockdown()) then
|
|
|
|
f:StopMovingOrSizing()
|
|
|
|
|
|
|
|
local scale = f:GetEffectiveScale()
|
|
|
|
self.db.x = f:GetLeft() * scale
|
2022-01-11 00:02:10 +01:00
|
|
|
self.db.y = (self.db.growDirection == "TOP" and f:GetBottom() or f:GetTop()) * scale
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
self.anchor = CreateFrame("Button", "GladdyAnchor", self.frame, BackdropTemplateMixin and "BackdropTemplate")
|
|
|
|
self.anchor:SetHeight(20)
|
|
|
|
self.anchor:SetBackdrop({ bgFile = "Interface\\Tooltips\\UI-Tooltip-Background", tile = true, tileSize = 16 })
|
|
|
|
self.anchor:SetBackdropColor(0, 0, 0, 1)
|
|
|
|
self.anchor:SetClampedToScreen(true)
|
|
|
|
self.anchor:EnableMouse(true)
|
|
|
|
self.anchor:SetMovable(true)
|
|
|
|
self.anchor:RegisterForDrag("LeftButton")
|
|
|
|
self.anchor:RegisterForClicks("RightButtonUp")
|
|
|
|
self.anchor:SetScript("OnDragStart", function()
|
|
|
|
if (not InCombatLockdown() and not self.db.locked) then
|
|
|
|
self.frame:StartMoving()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
self.anchor:SetScript("OnDragStop", function()
|
|
|
|
if (not InCombatLockdown()) then
|
|
|
|
self.frame:StopMovingOrSizing()
|
|
|
|
|
|
|
|
local scale = self.frame:GetEffectiveScale()
|
|
|
|
self.db.x = self.frame:GetLeft() * scale
|
2022-01-11 00:02:10 +01:00
|
|
|
self.db.y = (self.db.growDirection == "TOP" and self.frame:GetBottom() or self.frame:GetTop()) * scale
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
self.anchor:SetScript("OnClick", function()
|
|
|
|
if (not InCombatLockdown()) then
|
|
|
|
self:ShowOptions()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
self.anchor.text = self.anchor:CreateFontString("GladdyAnchorText", "ARTWORK", "GameFontHighlightSmall")
|
|
|
|
self.anchor.text:SetText(L["Gladdy - drag to move"])
|
|
|
|
self.anchor.text:SetPoint("CENTER")
|
|
|
|
|
|
|
|
self.anchor.button = CreateFrame("Button", "GladdyAnchorButton", self.anchor, "UIPanelCloseButton")
|
|
|
|
self.anchor.button:SetWidth(20)
|
|
|
|
self.anchor.button:SetHeight(20)
|
|
|
|
self.anchor.button:SetPoint("RIGHT", self.anchor, "RIGHT", 2, 0)
|
|
|
|
self.anchor.button:SetScript("OnClick", function(_, _, down)
|
|
|
|
if (not down) then
|
|
|
|
self.db.locked = true
|
|
|
|
self:UpdateFrame()
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
|
|
|
if (self.db.locked) then
|
|
|
|
self.anchor:Hide()
|
|
|
|
end
|
|
|
|
|
2021-07-27 16:32:37 +02:00
|
|
|
self.frame:Hide()
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:UpdateFrame()
|
|
|
|
|
2021-06-20 02:27:27 +02:00
|
|
|
if (InCombatLockdown()) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
if (not self.frame) then
|
|
|
|
self:CreateFrame()
|
|
|
|
end
|
|
|
|
local teamSize = self.curBracket or 0
|
|
|
|
|
2021-05-22 13:41:31 +02:00
|
|
|
local highlightBorderSize = (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2)
|
2021-06-15 09:06:05 +02:00
|
|
|
local powerBarHeight = self.db.powerBarEnabled and (self.db.powerBarHeight + 1) or 0
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-06-15 09:06:05 +02:00
|
|
|
local margin = powerBarHeight
|
|
|
|
local height = (self.db.healthBarHeight + powerBarHeight) * teamSize
|
2021-05-22 13:41:31 +02:00
|
|
|
+ (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2 * teamSize)
|
|
|
|
+ self.db.bottomMargin * (teamSize - 1)
|
2022-03-25 16:36:27 +01:00
|
|
|
local singleFrameHeight = self.db.healthBarHeight + powerBarHeight +
|
|
|
|
(self.db.highlightInset and 0 or self.db.highlightBorderSize * 2) + self.db.bottomMargin
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-05-22 13:41:31 +02:00
|
|
|
-- Highlight
|
|
|
|
margin = margin + highlightBorderSize
|
2022-01-11 00:29:17 +01:00
|
|
|
margin, height = Gladdy:LegacyPositioning(margin, height, teamSize)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-05-22 13:41:31 +02:00
|
|
|
-- GrowDirection
|
|
|
|
if (self.db.growDirection == "LEFT" or self.db.growDirection == "RIGHT") then
|
2021-06-15 09:06:05 +02:00
|
|
|
height = self.db.healthBarHeight + powerBarHeight
|
2021-05-22 13:41:31 +02:00
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
self.frame:SetScale(self.db.frameScale)
|
2021-09-22 17:12:10 +02:00
|
|
|
self:PixelPerfectScale(false)
|
2022-01-11 00:29:17 +01:00
|
|
|
self.frame:SetWidth(self.db.barWidth + highlightBorderSize)
|
2021-05-17 16:49:54 +02:00
|
|
|
self.frame:SetHeight(height)
|
2021-07-26 17:30:46 +02:00
|
|
|
self.frame:ClearAllPoints()
|
2022-01-12 23:07:23 +01:00
|
|
|
self.frame.background:SetBackdropColor(Gladdy:SetColor(self.db.backgroundColor))
|
2021-05-17 16:49:54 +02:00
|
|
|
self.frame:ClearAllPoints()
|
|
|
|
if (self.db.x == 0 and self.db.y == 0) then
|
|
|
|
self.frame:SetPoint("CENTER")
|
|
|
|
else
|
|
|
|
local scale = self.frame:GetEffectiveScale()
|
2022-03-25 16:36:27 +01:00
|
|
|
local growMiddle = self.db.growMiddle and teamSize > 0 and teamSize / 2 >= 1 and (teamSize - 1) * (singleFrameHeight / 2) or 0
|
2021-05-22 13:41:31 +02:00
|
|
|
if (self.db.growDirection == "TOP") then
|
2022-03-25 16:36:27 +01:00
|
|
|
self.frame:SetPoint("BOTTOMLEFT", UIParent, "BOTTOMLEFT", self.db.x / scale, (self.db.y / scale) - growMiddle)
|
|
|
|
elseif self.db.growDirection == "BOTTOM" then
|
|
|
|
self.frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.db.x / scale, (self.db.y / scale) + growMiddle)
|
2021-05-17 16:49:54 +02:00
|
|
|
else
|
2022-03-25 16:36:27 +01:00
|
|
|
self.frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.db.x / scale, (self.db.y / scale))
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-22 13:41:31 +02:00
|
|
|
--Anchor
|
2022-01-11 00:29:17 +01:00
|
|
|
self.anchor:SetWidth(self.db.barWidth * 2 + highlightBorderSize)
|
2021-05-17 16:49:54 +02:00
|
|
|
self.anchor:ClearAllPoints()
|
2021-05-22 13:41:31 +02:00
|
|
|
if (self.db.growDirection == "TOP") then
|
2022-01-11 00:29:17 +01:00
|
|
|
self.anchor:SetPoint("TOP", self.frame, "BOTTOM")
|
2021-05-22 13:41:31 +02:00
|
|
|
elseif self.growDirection == "BOTTOM" or self.growDirection == "RIGHT" then
|
2022-01-11 00:29:17 +01:00
|
|
|
self.anchor:SetPoint("BOTTOM", self.frame, "TOP")
|
2021-05-22 13:41:31 +02:00
|
|
|
else
|
2022-01-11 00:29:17 +01:00
|
|
|
self.anchor:SetPoint("BOTTOM", self.frame, "TOP")
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
if (self.db.locked) then
|
|
|
|
self.anchor:Hide()
|
|
|
|
else
|
|
|
|
self.anchor:Show()
|
|
|
|
end
|
|
|
|
|
|
|
|
for i = 1, teamSize do
|
|
|
|
local button = self.buttons["arena" .. i]
|
2021-05-22 13:41:31 +02:00
|
|
|
button:SetWidth(self.db.barWidth)
|
2021-05-17 16:49:54 +02:00
|
|
|
button:SetHeight(self.db.healthBarHeight)
|
2021-05-19 19:30:32 +02:00
|
|
|
button.secure:SetWidth(self.db.barWidth)
|
2021-06-15 09:06:05 +02:00
|
|
|
button.secure:SetHeight(self.db.healthBarHeight + powerBarHeight)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
button:ClearAllPoints()
|
|
|
|
button.secure:ClearAllPoints()
|
2021-05-22 13:41:31 +02:00
|
|
|
if (self.db.growDirection == "TOP") then
|
2021-05-17 16:49:54 +02:00
|
|
|
if (i == 1) then
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", 0, powerBarHeight)
|
2021-06-20 13:15:27 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
2021-05-17 16:49:54 +02:00
|
|
|
else
|
|
|
|
button:SetPoint("BOTTOMLEFT", self.buttons["arena" .. (i - 1)], "TOPLEFT", 0, margin + self.db.bottomMargin)
|
2021-06-20 13:15:27 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
2021-05-22 13:41:31 +02:00
|
|
|
elseif (self.db.growDirection == "BOTTOM") then
|
2021-05-17 16:49:54 +02:00
|
|
|
if (i == 1) then
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, 0)
|
2021-05-19 19:30:32 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
2021-05-17 16:49:54 +02:00
|
|
|
else
|
|
|
|
button:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "BOTTOMLEFT", 0, -margin - self.db.bottomMargin)
|
2021-05-19 19:30:32 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
2021-05-22 13:41:31 +02:00
|
|
|
elseif (self.db.growDirection == "LEFT") then
|
|
|
|
if (i == 1) then
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -0, 0)
|
2021-05-22 13:41:31 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("TOPRIGHT", self.buttons["arena" .. (i - 1)], "TOPLEFT", - self.db.bottomMargin, 0)
|
2021-05-22 13:41:31 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
|
|
|
elseif (self.db.growDirection == "RIGHT") then
|
|
|
|
if (i == 1) then
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, 0)
|
2021-05-22 13:41:31 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
2022-01-11 00:29:17 +01:00
|
|
|
button:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "TOPRIGHT", self.db.bottomMargin, 0)
|
2021-05-22 13:41:31 +02:00
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
|
2021-05-19 19:33:22 +02:00
|
|
|
for _, v in self:IterModules() do
|
2021-06-16 01:14:11 +02:00
|
|
|
self:Call(v, "UpdateFrame", "arena" .. i)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
2021-05-19 19:33:22 +02:00
|
|
|
for _, v in self:IterModules() do
|
2021-05-17 16:49:54 +02:00
|
|
|
self:Call(v, "UpdateFrameOnce")
|
|
|
|
end
|
2021-07-29 14:06:15 +02:00
|
|
|
if Gladdy.db.hideBlizzard == "always" then
|
|
|
|
Gladdy:BlizzArenaSetAlpha(0)
|
|
|
|
elseif Gladdy.db.hideBlizzard == "arena" then
|
|
|
|
if Gladdy.curBracket then
|
|
|
|
Gladdy:BlizzArenaSetAlpha(0)
|
|
|
|
else
|
|
|
|
Gladdy:BlizzArenaSetAlpha(1)
|
|
|
|
end
|
|
|
|
elseif Gladdy.db.hideBlizzard == "never" then
|
|
|
|
Gladdy:BlizzArenaSetAlpha(1)
|
|
|
|
end
|
2022-01-11 00:29:17 +01:00
|
|
|
if (not Gladdy.db.newLayout) then
|
|
|
|
Gladdy.db.newLayout = true
|
|
|
|
--get margin
|
|
|
|
local arena1Bottom
|
|
|
|
local arena2Top
|
|
|
|
if (self.db.growDirection == "BOTTOM") then
|
|
|
|
arena1Bottom = self.buttons["arena1"].secure:GetBottom()
|
|
|
|
arena2Top = self.buttons["arena2"].secure:GetTop()
|
|
|
|
elseif (self.db.growDirection == "TOP") then
|
|
|
|
arena1Bottom = self.buttons["arena1"].secure:GetTop()
|
|
|
|
arena2Top = self.buttons["arena2"].secure:GetBottom()
|
|
|
|
elseif (self.db.growDirection == "LEFT") then
|
|
|
|
arena1Bottom = self.buttons["arena1"].secure:GetLeft()
|
|
|
|
arena2Top = self.buttons["arena2"].secure:GetRight()
|
|
|
|
elseif (self.db.growDirection == "RIGHT") then
|
|
|
|
arena1Bottom = self.buttons["arena1"].secure:GetRight()
|
|
|
|
arena2Top = self.buttons["arena2"].secure:GetLeft()
|
|
|
|
end
|
|
|
|
Gladdy.db.bottomMargin = math_abs(arena1Bottom - arena2Top)
|
|
|
|
Gladdy:UpdateFrame()
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:HideFrame()
|
|
|
|
if (self.frame) then
|
2021-07-27 16:32:37 +02:00
|
|
|
if InCombatLockdown() then
|
|
|
|
self.startTest = nil
|
|
|
|
self.hideFrame = true
|
|
|
|
else
|
2022-01-13 23:37:09 +01:00
|
|
|
self:Reset()
|
2021-07-27 16:32:37 +02:00
|
|
|
self.frame:Hide()
|
|
|
|
end
|
|
|
|
|
2021-05-17 16:49:54 +02:00
|
|
|
self.frame.testing = nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:ToggleFrame(i)
|
|
|
|
self:Reset()
|
|
|
|
if (self.frame and self.frame:IsShown() and i == self.curBracket) then
|
2021-09-25 14:03:57 +02:00
|
|
|
self.frame.testing = nil
|
2021-05-17 16:49:54 +02:00
|
|
|
self:HideFrame()
|
|
|
|
else
|
|
|
|
self.curBracket = i
|
|
|
|
|
|
|
|
if (not self.frame) then
|
|
|
|
self:CreateFrame()
|
|
|
|
end
|
2021-09-25 14:03:57 +02:00
|
|
|
self.frame.testing = true
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
for o = 1, self.curBracket do
|
|
|
|
local unit = "arena" .. o
|
|
|
|
if (not self.buttons[unit]) then
|
|
|
|
self:CreateButton(o)
|
|
|
|
end
|
|
|
|
end
|
2021-06-16 14:10:49 +02:00
|
|
|
self:Reset()
|
|
|
|
self.curBracket = i
|
2021-05-17 16:49:54 +02:00
|
|
|
self:UpdateFrame()
|
2021-07-27 16:32:37 +02:00
|
|
|
if InCombatLockdown() then
|
|
|
|
Gladdy:Print("Gladdy frames show as soon as you leave combat")
|
|
|
|
self.showFrame = true
|
|
|
|
self.startTest = true
|
|
|
|
else
|
|
|
|
self:Test()
|
|
|
|
self.frame:Show()
|
|
|
|
end
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:CreateButton(i)
|
|
|
|
if (not self.frame) then
|
|
|
|
self:CreateFrame()
|
|
|
|
end
|
|
|
|
|
|
|
|
local button = CreateFrame("Frame", "GladdyButtonFrame" .. i, self.frame)
|
2021-05-19 19:30:32 +02:00
|
|
|
button:EnableMouse(false)
|
2021-05-22 13:41:31 +02:00
|
|
|
--button:SetAlpha(0)
|
|
|
|
--button.texture = button:CreateTexture(nil, "OVERLAY")
|
|
|
|
--button.texture:SetAllPoints(button)
|
|
|
|
--button.texture:SetTexture("Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-06-15 17:10:31 +02:00
|
|
|
local secure = CreateFrame("Button", "GladdyButton" .. i, button, "SecureActionButtonTemplate, SecureHandlerEnterLeaveTemplate")
|
2021-05-17 16:49:54 +02:00
|
|
|
secure:RegisterForClicks("AnyUp")
|
2021-06-20 00:55:06 +02:00
|
|
|
secure:RegisterForClicks("AnyDown")
|
2021-06-20 02:27:27 +02:00
|
|
|
|
|
|
|
secure:SetAttribute("target", "arena" .. i)
|
|
|
|
secure:SetAttribute("focus", "arena" .. i)
|
2021-05-17 16:49:54 +02:00
|
|
|
secure:SetAttribute("unit", "arena" .. i)
|
2021-06-20 02:27:27 +02:00
|
|
|
|
|
|
|
--[[
|
|
|
|
secure:SetAttribute("target", i == 1 and "player" or "focus")
|
|
|
|
secure:SetAttribute("focus", i == 1 and "player" or "focus")
|
|
|
|
secure:SetAttribute("unit", i == 1 and "player" or "focus")
|
|
|
|
--]]
|
|
|
|
|
2021-05-19 19:30:32 +02:00
|
|
|
--secure.texture = secure:CreateTexture(nil, "OVERLAY")
|
|
|
|
--secure.texture:SetAllPoints(secure)
|
|
|
|
--secure.texture:SetTexture("Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp")
|
2021-05-17 16:49:54 +02:00
|
|
|
|
|
|
|
button.id = i
|
2021-06-20 00:55:06 +02:00
|
|
|
--button.unit = i == 1 and "player" or "focus"
|
2021-05-17 16:49:54 +02:00
|
|
|
button.unit = "arena" .. i
|
|
|
|
button.secure = secure
|
|
|
|
|
|
|
|
|
2021-06-16 01:14:11 +02:00
|
|
|
self:ResetButton("arena" .. i)
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-06-16 01:14:11 +02:00
|
|
|
self.buttons["arena" .. i] = button
|
2021-05-17 16:49:54 +02:00
|
|
|
|
2021-05-19 19:33:22 +02:00
|
|
|
for _, v in self:IterModules() do
|
2021-06-16 01:14:11 +02:00
|
|
|
self:Call(v, "CreateFrame", "arena" .. i)
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|
2021-06-17 16:43:28 +02:00
|
|
|
self:ResetButton("arena" .. i)
|
2021-05-18 16:39:43 +02:00
|
|
|
end
|
|
|
|
|
2022-01-11 00:29:17 +01:00
|
|
|
|
|
|
|
|
|
|
|
function Gladdy:SetPosition(frame, unit, xOffsetDB, yOffsetDB, newLayout, module)
|
|
|
|
local button = self.buttons[unit]
|
|
|
|
if not button or not frame or not xOffsetDB or not yOffsetDB then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
if (not newLayout) then
|
|
|
|
--Gladdy:Debug("INFO", name, "old X/Y:", frame:GetCenter())
|
|
|
|
local xOffset, yOffset = frame:GetLeft(), frame:GetTop()
|
2022-01-25 20:01:42 +01:00
|
|
|
if not xOffset or not yOffset then
|
2022-01-25 20:42:33 +01:00
|
|
|
xOffset = frame:GetCenter()-- - frame:GetWidth()/2
|
|
|
|
yOffset = select(2, frame:GetCenter())-- + frame:GetHeight()/2
|
2022-01-25 20:01:42 +01:00
|
|
|
end
|
2022-01-11 00:29:17 +01:00
|
|
|
local x,y = button.healthBar:GetLeft(), button.healthBar:GetTop()
|
|
|
|
local newXOffset = math_abs(x - xOffset) * (x > xOffset and -1 or 1)
|
|
|
|
local newYOffset = math_abs(y - yOffset) * (y > yOffset and -1 or 1)
|
|
|
|
frame:ClearAllPoints()
|
|
|
|
frame:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", newXOffset, newYOffset)
|
|
|
|
--Gladdy:Debug("INFO", name, "new X/Y:", frame:GetCenter())
|
|
|
|
if unit == "arena1" then
|
|
|
|
Gladdy.db[xOffsetDB] = newXOffset
|
|
|
|
Gladdy.db[yOffsetDB] = newYOffset
|
|
|
|
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
frame:ClearAllPoints()
|
|
|
|
frame:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT", Gladdy.db[xOffsetDB], Gladdy.db[yOffsetDB])
|
|
|
|
end
|
|
|
|
if (self.newDefaults[module.name]) then
|
|
|
|
for k,v in pairs(self.newDefaults[module.name]) do
|
|
|
|
module.defaults[k] = v
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:CreateMover(frame, xConfig, yConfig, name, points, width, height, xOffset, yOffset, activated)
|
|
|
|
if not frame.mover then
|
|
|
|
frame:EnableMouse(false)
|
|
|
|
frame:SetMovable(true)
|
|
|
|
frame.mover = CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate")
|
2022-01-12 20:21:53 +01:00
|
|
|
frame.mover:SetFrameStrata("TOOLTIP")
|
2022-01-11 00:29:17 +01:00
|
|
|
frame.mover:SetPoint(points[1], frame, points[2], xOffset or 0, yOffset or 0)
|
|
|
|
frame.mover:SetHeight(height or frame:GetHeight())
|
|
|
|
frame.mover:SetWidth(width or frame:GetWidth())
|
|
|
|
|
|
|
|
local backdrop = {
|
|
|
|
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
|
|
|
|
edgeFile = "",
|
|
|
|
tile = true, tileSize = 16, edgeSize = 10,
|
|
|
|
insets = {left = 0, right = 0, top = 0, bottom = 0}
|
|
|
|
}
|
|
|
|
frame.mover:SetBackdrop(backdrop)
|
|
|
|
frame.mover:SetBackdropColor(0,1,0,0.5)
|
|
|
|
frame.mover.border = CreateFrame("Frame", nil, frame.mover, BackdropTemplateMixin and "BackdropTemplate")
|
|
|
|
frame.mover.border:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "highlightBorderStyle"), edgeSize = 2 })
|
|
|
|
frame.mover.border:SetAllPoints(frame.mover)
|
|
|
|
frame.mover.border:SetBackdropBorderColor(0,1,0,1)
|
2022-01-12 20:21:53 +01:00
|
|
|
frame.mover.border:SetFrameStrata("TOOLTIP")
|
2022-01-11 00:29:17 +01:00
|
|
|
|
|
|
|
frame.mover.text = frame.mover.border:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
|
|
|
|
frame.mover.text:SetText(name)
|
|
|
|
frame.mover.text:SetPoint("CENTER")
|
|
|
|
|
|
|
|
frame.mover:SetMovable(true)
|
|
|
|
frame.mover:EnableMouse(true)
|
|
|
|
|
|
|
|
frame.mover:SetScript("OnMouseDown", function(self)
|
|
|
|
self.point = { frame:GetPoint() }
|
|
|
|
self.start = { frame:GetCenter() }
|
|
|
|
frame:StartMoving()
|
|
|
|
self:StartMoving()
|
|
|
|
end)
|
|
|
|
frame.mover:SetScript("OnMouseUp", function(self)
|
|
|
|
frame:StopMovingOrSizing()
|
|
|
|
self:StopMovingOrSizing()
|
|
|
|
self.stop = { frame:GetCenter() }
|
|
|
|
local diffX = math_abs(self.start[1] - self.stop[1])
|
|
|
|
diffX = self.start[1] > self.stop[1] and -diffX or diffX
|
|
|
|
local diffY = math_abs(self.start[2] - self.stop[2])
|
|
|
|
diffY = self.start[2] > self.stop[2] and -diffY or diffY
|
|
|
|
frame:ClearAllPoints()
|
|
|
|
frame:SetPoint(self.point[1], self.point[2], self.point[3], self.point[4] + diffX, self.point[5] + diffY)
|
|
|
|
Gladdy.db[xConfig] = self.point[4] + diffX
|
|
|
|
Gladdy.db[yConfig] = self.point[5] + diffY
|
|
|
|
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
|
|
|
|
Gladdy:UpdateFrame()
|
|
|
|
end)
|
|
|
|
else
|
|
|
|
frame.mover:ClearAllPoints()
|
|
|
|
frame.mover:SetPoint(points[1], frame, points[2], xOffset or 0, yOffset or 0)
|
|
|
|
frame.mover:SetHeight(height or frame:GetHeight())
|
|
|
|
frame.mover:SetWidth(width or frame:GetWidth())
|
|
|
|
end
|
|
|
|
if self.frame and self.frame.testing and self.db.showMover then
|
2022-01-13 23:11:33 +01:00
|
|
|
if (activated ~= nil and not Gladdy.db[activated]) then
|
|
|
|
frame.mover:Hide()
|
|
|
|
else
|
|
|
|
frame.mover:Show()
|
|
|
|
end
|
2022-01-11 00:29:17 +01:00
|
|
|
else
|
|
|
|
frame.mover:Hide()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
-- LAGACY SUPPORT
|
|
|
|
|
|
|
|
---------------------------
|
|
|
|
|
|
|
|
function Gladdy:LegacyPositioning(margin, height, teamSize)
|
|
|
|
if not Gladdy.db.newLayout then
|
|
|
|
for k,v in pairs(Gladdy.legacy) do
|
|
|
|
if Gladdy.db[k] == nil then
|
|
|
|
Gladdy:Debug("INFO", "Gladdy:LegacyPositioning write", k,v)
|
|
|
|
Gladdy.db[k] = v
|
|
|
|
else
|
|
|
|
Gladdy:Debug("INFO", "Gladdy:LegacyPositioning found", k,v)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if (self.db.cooldownYPos == "TOP" or self.db.cooldownYPos == "BOTTOM") and self.db.cooldown then
|
|
|
|
margin = margin + self.db.cooldownSize
|
|
|
|
height = height + self.db.cooldownSize * (teamSize - 1)
|
|
|
|
end
|
|
|
|
if (self.db.buffsCooldownPos == "TOP" or self.db.buffsCooldownPos == "BOTTOM") and self.db.buffsEnabled then
|
|
|
|
margin = margin + self.db.buffsIconSize
|
|
|
|
height = height + self.db.buffsIconSize * (teamSize - 1)
|
|
|
|
end
|
|
|
|
if (self.db.buffsBuffsCooldownPos == "TOP" or self.db.buffsBuffsCooldownPos == "BOTTOM") and self.db.buffsEnabled then
|
|
|
|
margin = margin + self.db.buffsBuffsIconSize
|
|
|
|
height = height + self.db.buffsBuffsIconSize * (teamSize - 1)
|
|
|
|
end
|
|
|
|
if self.db.buffsCooldownPos == "TOP" and self.db.cooldownYPos == "TOP" and self.db.cooldown and self.db.buffsEnabled then
|
|
|
|
margin = margin + 1
|
|
|
|
height = height + (teamSize - 1)
|
|
|
|
end
|
|
|
|
if self.db.buffsCooldownPos == "BOTTOM" and self.db.cooldownYPos == "BOTTOM" and self.db.cooldown and self.db.buffsEnabled then
|
|
|
|
margin = margin + 1
|
|
|
|
height = height + (teamSize - 1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return margin, height
|
|
|
|
end
|
|
|
|
|
|
|
|
function Gladdy:PositionButton(button, i, leftSize, rightSize, powerBarHeight, margin)
|
|
|
|
if (self.db.growDirection == "TOP") then
|
|
|
|
if (i == 1) then
|
|
|
|
button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", leftSize, powerBarHeight)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
|
|
|
button:SetPoint("BOTTOMLEFT", self.buttons["arena" .. (i - 1)], "TOPLEFT", 0, margin + self.db.bottomMargin)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
|
|
|
elseif (self.db.growDirection == "BOTTOM") then
|
|
|
|
if (i == 1) then
|
|
|
|
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", leftSize, 0)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
|
|
|
button:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "BOTTOMLEFT", 0, -margin - self.db.bottomMargin)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
|
|
|
elseif (self.db.growDirection == "LEFT") then
|
|
|
|
if (i == 1) then
|
|
|
|
button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -rightSize, 0)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
|
|
|
button:SetPoint("TOPRIGHT", self.buttons["arena" .. (i - 1)], "TOPLEFT", -rightSize - leftSize - self.db.bottomMargin, 0)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
|
|
|
elseif (self.db.growDirection == "RIGHT") then
|
|
|
|
if (i == 1) then
|
|
|
|
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", leftSize, 0)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
else
|
|
|
|
button:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "TOPRIGHT", leftSize + rightSize + self.db.bottomMargin, 0)
|
|
|
|
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2021-05-18 16:39:43 +02:00
|
|
|
function Gladdy:GetAnchor(unit, position)
|
|
|
|
local anchor = "healthBar"
|
|
|
|
if Gladdy.db.classIconPos == position then
|
|
|
|
anchor = "classIcon"
|
|
|
|
end
|
|
|
|
if Gladdy.db.trinketPos == position then
|
|
|
|
anchor = "trinket"
|
|
|
|
end
|
|
|
|
if anchor == Gladdy.db.racialAnchor and Gladdy.db.racialPos == position then
|
|
|
|
anchor = "racial"
|
|
|
|
end
|
|
|
|
return Gladdy.buttons[unit][anchor]
|
2021-05-17 16:49:54 +02:00
|
|
|
end
|