movable frames

This commit is contained in:
Sumsebrum 2022-01-11 00:29:17 +01:00
parent adb06d0c7f
commit 59da6f34c6
14 changed files with 881 additions and 608 deletions

View File

@ -1180,3 +1180,58 @@ function Gladdy:GetArenaTimer()
end
end
Gladdy.legacy = {
castBarPos = "LEFT",
buffsCooldownPos = "TOP",
buffsBuffsCooldownPos = "BOTTOM",
classIconPos = "LEFT",
ciAnchor = "healthBar",
ciPos = "TOP",
cooldownYPos = "TOP",
cooldownXPos = "LEFT",
drCooldownPos = "RIGHT",
racialAnchor = "trinket",
racialPos = "RIGHT",
trinketPos = "RIGHT",
padding = 1,
growUp = false,
}
Gladdy.newDefaults = {
["bottomMargin"] = 94.99996948242188,
["newLayout"] = true,
Pets = {
["petYOffset"] = -81.99993896484375,
["petXOffset"] = 181,
},
ClassIcon = {
["classIconXOffset"] = -74.90008544921875,
},
Racial = {
["racialXOffset"] = 255.9000244140625,
},
Trinket = {
["trinketXOffset"] = 182,
},
["Combat Indicator"] = {
["ciXOffset"] = 79.99993896484375,
["ciYOffset"] = -10.99993896484375,
},
Cooldowns = {
["cooldownYOffset"] = 31,
},
["Buffs and Debuffs"] = {
["buffsBuffsXOffset"] = 29,
["buffsBuffsYOffset"] = -82.99993896484375,
["buffsXOffset"] = 29,
["buffsYOffset"] = 62.00006103515625,
},
Diminishings = {
["drXOffset"] = 329.7999877929688,
["drYOffset"] = -22.5,
},
["Cast Bar"] = {
["castBarXOffset"] = -235.900146484375,
["castBarYOffset"] = -30.5,
},
}

271
Frame.lua
View File

@ -1,6 +1,9 @@
local CreateFrame = CreateFrame
local UIParent = UIParent
local InCombatLockdown = InCombatLockdown
local math_abs = math.abs
local pairs = pairs
local LibStub = LibStub
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
@ -45,7 +48,7 @@ function Gladdy:CreateFrame()
self.frame:SetClampedToScreen(true)
self.frame:EnableMouse(false)
self.frame:SetMovable(true)
self.frame:RegisterForDrag("LeftButton")
--self.frame:RegisterForDrag("LeftButton")
self.frame:SetScript("OnDragStart", function(f)
if (not InCombatLockdown() and not self.db.locked) then
@ -126,72 +129,24 @@ function Gladdy:UpdateFrame()
local highlightBorderSize = (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2)
local powerBarHeight = self.db.powerBarEnabled and (self.db.powerBarHeight + 1) or 0
local leftSize = 0
local rightSize = 0
--Trinket + Racial
if self.db.trinketEnabled and self.db.trinketPos == "LEFT" then
leftSize = leftSize + self.db.trinketSize * self.db.trinketWidthFactor + self.db.padding
if self.db.racialEnabled and self.db.racialAnchor == "trinket" and self.db.racialPos == "LEFT" then
leftSize = leftSize + self.db.racialSize * self.db.racialWidthFactor + self.db.padding
end
end
if self.db.trinketEnabled and self.db.trinketPos == "RIGHT" then
rightSize = rightSize + self.db.trinketSize * self.db.trinketWidthFactor + self.db.padding
if self.db.racialEnabled and self.db.racialAnchor == "trinket" and self.db.racialPos == "RIGHT" then
rightSize = rightSize + self.db.racialSize * self.db.racialWidthFactor + self.db.padding
end
end
--ClassIcon
if self.db.classIconPos == "LEFT" then
leftSize = leftSize + self.db.classIconSize * self.db.classIconWidthFactor + self.db.padding
else
rightSize = rightSize + self.db.classIconSize * self.db.classIconWidthFactor + self.db.padding
end
--Highlight
if not self.db.highlightInset then
leftSize = leftSize + self.db.highlightBorderSize
rightSize = rightSize + self.db.highlightBorderSize
end
local margin = powerBarHeight
local width = self.db.barWidth + leftSize + rightSize
local height = (self.db.healthBarHeight + powerBarHeight) * teamSize
+ (self.db.highlightInset and 0 or self.db.highlightBorderSize * 2 * teamSize)
+ self.db.bottomMargin * (teamSize - 1)
-- Highlight
margin = margin + highlightBorderSize
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
margin, height = Gladdy:LegacyPositioning(margin, height, teamSize)
-- GrowDirection
if (self.db.growDirection == "LEFT" or self.db.growDirection == "RIGHT") then
width = self.db.barWidth * teamSize + (leftSize + rightSize) * teamSize + self.db.bottomMargin * (teamSize - 1)
height = self.db.healthBarHeight + powerBarHeight
end
self.frame:SetScale(self.db.frameScale)
self:PixelPerfectScale(false)
self.frame:SetWidth(width)
self.frame:SetWidth(self.db.barWidth + highlightBorderSize)
self.frame:SetHeight(height)
self.frame:ClearAllPoints()
self.frame.background:SetBackdropColor(self.db.backgroundColor.r, self.db.backgroundColor.g, self.db.backgroundColor.b, self.db.backgroundColor.a)
@ -209,14 +164,14 @@ function Gladdy:UpdateFrame()
end
--Anchor
self.anchor:SetWidth(width)
self.anchor:SetWidth(self.db.barWidth * 2 + highlightBorderSize)
self.anchor:ClearAllPoints()
if (self.db.growDirection == "TOP") then
self.anchor:SetPoint("TOPLEFT", self.frame, "BOTTOMLEFT")
self.anchor:SetPoint("TOP", self.frame, "BOTTOM")
elseif self.growDirection == "BOTTOM" or self.growDirection == "RIGHT" then
self.anchor:SetPoint("BOTTOMLEFT", self.frame, "TOPLEFT")
self.anchor:SetPoint("BOTTOM", self.frame, "TOP")
else
self.anchor:SetPoint("BOTTOMRIGHT", self.frame, "TOPRIGHT")
self.anchor:SetPoint("BOTTOM", self.frame, "TOP")
end
if (self.db.locked) then
@ -236,7 +191,7 @@ function Gladdy:UpdateFrame()
button.secure:ClearAllPoints()
if (self.db.growDirection == "TOP") then
if (i == 1) then
button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", leftSize, powerBarHeight)
button:SetPoint("BOTTOMLEFT", self.frame, "BOTTOMLEFT", 0, powerBarHeight)
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
else
button:SetPoint("BOTTOMLEFT", self.buttons["arena" .. (i - 1)], "TOPLEFT", 0, margin + self.db.bottomMargin)
@ -244,7 +199,7 @@ function Gladdy:UpdateFrame()
end
elseif (self.db.growDirection == "BOTTOM") then
if (i == 1) then
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", leftSize, 0)
button:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, 0)
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
else
button:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "BOTTOMLEFT", 0, -margin - self.db.bottomMargin)
@ -252,18 +207,18 @@ function Gladdy:UpdateFrame()
end
elseif (self.db.growDirection == "LEFT") then
if (i == 1) then
button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -rightSize, 0)
button:SetPoint("TOPRIGHT", self.frame, "TOPRIGHT", -0, 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:SetPoint("TOPRIGHT", self.buttons["arena" .. (i - 1)], "TOPLEFT", - 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:SetPoint("TOPLEFT", self.frame, "TOPLEFT", 0, 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:SetPoint("TOPLEFT", self.buttons["arena" .. (i - 1)], "TOPRIGHT", self.db.bottomMargin, 0)
button.secure:SetPoint("TOPLEFT", button.healthBar, "TOPLEFT")
end
end
@ -287,6 +242,27 @@ function Gladdy:UpdateFrame()
elseif Gladdy.db.hideBlizzard == "never" then
Gladdy:BlizzArenaSetAlpha(1)
end
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
end
function Gladdy:HideFrame()
@ -381,6 +357,179 @@ function Gladdy:CreateButton(i)
self:ResetButton("arena" .. i)
end
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()
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")
frame.mover:SetFrameStrata("DIALOG")
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)
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
frame.mover:Show()
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
function Gladdy:GetAnchor(unit, position)
local anchor = "healthBar"
if Gladdy.db.classIconPos == position then

View File

@ -6,7 +6,6 @@ local pairs = pairs
local tinsert = table.insert
local tsort = table.sort
local str_lower = string.lower
local math_abs = math.abs
local GetTime = GetTime
local GetPhysicalScreenSize = GetPhysicalScreenSize
local InCombatLockdown = InCombatLockdown
@ -97,6 +96,7 @@ end
Gladdy.events = CreateFrame("Frame")
Gladdy.events.registered = {}
Gladdy.events:RegisterEvent("PLAYER_LOGIN")
Gladdy.events:RegisterEvent("PLAYER_LOGOUT")
Gladdy.events:RegisterEvent("CVAR_UPDATE")
hooksecurefunc("VideoOptionsFrameOkay_OnClick", function(self, button, down, apply)
if (self:GetName() == "VideoOptionsFrameApply") then
@ -111,6 +111,8 @@ Gladdy.events:SetScript("OnEvent", function(self, event, ...)
if (str_lower(select(1, ...)) == "uiscale") then
Gladdy:PixelPerfectScale(true)
end
elseif (event == "PLAYER_LOGOUT") then
Gladdy:DeleteUnknownOptions(Gladdy.db, Gladdy.defaults.profile)
else
local func = self.registered[event]
@ -202,68 +204,6 @@ function Gladdy:NewModule(name, priority, defaults)
return module
end
function Gladdy:CreateMover(frame, xConfig, yConfig, name, points, width, height, xOffset, yOffset)
if not frame.mover then
frame.mover = CreateFrame("Frame", nil, frame, BackdropTemplateMixin and "BackdropTemplate")
frame.mover:SetFrameStrata("DIALOG")
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)
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 then
frame.mover:Show()
else
frame.mover:Hide()
end
end
---------------------------
-- INIT
@ -310,7 +250,7 @@ function Gladdy:OnInitialize()
self.dbi = LibStub("AceDB-3.0"):New("GladdyXZ", self.defaults)
self.dbi.RegisterCallback(self, "OnProfileChanged", "OnProfileChanged")
self.dbi.RegisterCallback(self, "OnProfileCopied", "OnProfileChanged")
self.dbi.RegisterCallback(self, "OnProfileReset", "OnProfileChanged")
self.dbi.RegisterCallback(self, "OnProfileReset", "OnProfileReset")
self.db = self.dbi.profile
self.LSM = LibStub("LibSharedMedia-3.0")
@ -347,18 +287,32 @@ function Gladdy:OnInitialize()
for _, module in self:IterModules() do
self:Call(module, "Initialize") -- B.E > A.E :D
end
self:DeleteUnknownOptions(self.db, self.defaults.profile)
if Gladdy.db.hideBlizzard == "always" then
Gladdy:BlizzArenaSetAlpha(0)
end
if not self.db.newLayout then
self:ToggleFrame(3)
self:HideFrame()
end
end
function Gladdy:OnProfileReset()
self.db = self.dbi.profile
Gladdy:Debug("INFO", "OnProfileReset")
self:HideFrame()
self:ToggleFrame(3)
Gladdy.options.args.lock.name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"]
Gladdy.options.args.showMover.name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"]
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
end
function Gladdy:OnProfileChanged()
self.db = self.dbi.profile
self:DeleteUnknownOptions(self.db, self.defaults.profile)
self:HideFrame()
self:ToggleFrame(3)
Gladdy.options.args.lock.name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"]
Gladdy.options.args.showMover.name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"]
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
end
function Gladdy:OnEnable()

View File

@ -31,11 +31,9 @@ local BuffsDebuffs = Gladdy:NewModule("Buffs and Debuffs", nil, {
buffsFontScale = 1,
buffsFontColor = {r = 1, g = 1, b = 0, a = 1},
buffsDynamicColor = true,
buffsCooldownPos = "TOP",
buffsCooldownGrowDirection = "RIGHT",
buffsXOffset = 0,
buffsYOffset = 0,
buffsBuffsCooldownPos = "BOTTOM",
buffsBuffsCooldownGrowDirection = "RIGHT",
buffsBuffsXOffset = 0,
buffsBuffsYOffset = 0,
@ -51,7 +49,7 @@ local BuffsDebuffs = Gladdy:NewModule("Buffs and Debuffs", nil, {
buffsBorderColorImmune = Gladdy:GetAuraTypeColor()["immune"],
buffsBorderColorDisease = Gladdy:GetAuraTypeColor()["disease"],
buffsBorderColorForm = Gladdy:GetAuraTypeColor()["form"],
buffsBorderColorAura = Gladdy:GetAuraTypeColor()["aura"]
buffsBorderColorAura = Gladdy:GetAuraTypeColor()["aura"],
})
local spellSchoolToOptionValueTable
@ -233,18 +231,15 @@ end
---------------------------
function BuffsDebuffs:CreateFrame(unit)
local verticalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
local debuffFrame = CreateFrame("Frame", "GladdyDebuffs" .. unit, Gladdy.buttons[unit])
debuffFrame:SetMovable(true)
debuffFrame:SetHeight(Gladdy.db.buffsIconSize)
debuffFrame:SetWidth(1)
debuffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin)
debuffFrame.unit = unit
local buffFrame = CreateFrame("Frame", "GladdyBuffs" .. unit, Gladdy.buttons[unit])
buffFrame:SetMovable(true)
buffFrame:SetHeight(Gladdy.db.buffsIconSize)
buffFrame:SetWidth(1)
buffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPLEFT", 0, verticalMargin)
buffFrame.unit = unit
self.frames[unit] = {}
self.frames[unit].buffFrame = buffFrame
@ -285,156 +280,30 @@ local function styleIcon(aura, auraType)
end
function BuffsDebuffs:UpdateFrame(unit)
self.frames[unit].debuffFrame:SetHeight(Gladdy.db.buffsIconSize)
self.frames[unit].debuffFrame:ClearAllPoints()
--DEBUFFS
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
if Gladdy.db.buffsCooldownPos == "TOP" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "TOP" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].debuffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset + verticalMargin)
else
self.frames[unit].debuffFrame:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset + verticalMargin)
end
elseif Gladdy.db.buffsCooldownPos == "BOTTOM" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "BOTTOM" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].debuffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
else
self.frames[unit].debuffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
end
elseif Gladdy.db.buffsCooldownPos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].debuffFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset)
else
self.frames[unit].debuffFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset)
end
elseif Gladdy.db.buffsCooldownPos == "RIGHT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset)
else
self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset, Gladdy.db.buffsYOffset)
end
end
self.frames[unit].debuffFrame:SetHeight(Gladdy.db.buffsIconSize)
Gladdy:SetPosition(self.frames[unit].debuffFrame, unit, "buffsXOffset", "buffsYOffset", BuffsDebuffs:LegacySetPositionDebuffs(unit), BuffsDebuffs)
if (unit == "arena1") then
Gladdy:CreateMover(self.frames[unit].debuffFrame, "buffsXOffset", "buffsYOffset", L["Debuffs"],
Gladdy.db.buffsCooldownGrowDirection == "LEFT" and {"TOPRIGHT", "TOPRIGHT"} or {"TOPLEFT", "TOPLEFT"},
{"TOPRIGHT", "TOPRIGHT"},
Gladdy.db.buffsIconSize * Gladdy.db.buffsWidthFactor,
Gladdy.db.buffsIconSize, Gladdy.db.buffsCooldownGrowDirection == "LEFT"and -1 or 1, 0)
Gladdy.db.buffsIconSize, 0, 0)
if not Gladdy.db.buffsEnabled then
self.frames[unit].debuffFrame.mover:Hide()
end
end
--BUFFS
self.frames[unit].buffFrame:SetHeight(Gladdy.db.buffsBuffsIconSize)
self.frames[unit].buffFrame:ClearAllPoints()
horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
verticalMargin = -(Gladdy.db.powerBarHeight)/2
if Gladdy.db.buffsBuffsCooldownPos == "TOP" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "TOP" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].buffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", Gladdy.db.buffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
else
self.frames[unit].buffFrame:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", Gladdy.db.buffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
end
elseif Gladdy.db.buffsBuffsCooldownPos == "BOTTOM" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "BOTTOM" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].buffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
else
self.frames[unit].buffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
end
elseif Gladdy.db.buffsBuffsCooldownPos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "LEFT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "LEFT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "LEFT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.buffsBuffsIconSize/2 + Gladdy.db.padding/2)
end
--self.frames[unit].buffFrame:SetPoint("RIGHT", Gladdy.buttons[unit].healthBar, "LEFT", -horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
local anchor = Gladdy:GetAnchor(unit, "LEFT")
horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) - 1 + Gladdy.db.padding
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].buffFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset)
else
self.frames[unit].buffFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset)
end
elseif Gladdy.db.buffsBuffsCooldownPos == "RIGHT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "RIGHT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "RIGHT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "RIGHT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.buffsBuffsIconSize/2 + Gladdy.db.padding/2)
end
--self.frames[unit].buffFrame:SetPoint("LEFT", Gladdy.buttons[unit].healthBar, "RIGHT", horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) - 1 + Gladdy.db.padding
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset)
else
self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset)
end
end
Gladdy:SetPosition(self.frames[unit].buffFrame, unit, "buffsBuffsXOffset", "buffsBuffsYOffset", BuffsDebuffs:LegacySetPositionBuffs(unit), BuffsDebuffs)
if (unit == "arena1") then
Gladdy:CreateMover(self.frames[unit].buffFrame, "buffsBuffsXOffset", "buffsBuffsYOffset", L["Buffs"],
Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" and {"TOPRIGHT", "TOPRIGHT"} or {"TOPLEFT", "TOPLEFT"},
{"TOPRIGHT", "TOPRIGHT"},
Gladdy.db.buffsBuffsIconSize * Gladdy.db.buffsBuffsWidthFactor,
Gladdy.db.buffsBuffsIconSize, Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT"and -1 or 1, 0)
Gladdy.db.buffsBuffsIconSize, 0, 0)
if not Gladdy.db.buffsEnabled then
self.frames[unit].buffFrame.mover:Hide()
end
end
for i=1, #self.frames[unit].auras[AURA_TYPE_BUFF] do
@ -456,13 +325,8 @@ end
function BuffsDebuffs:UpdateAurasOnUnit(unit)
for i=1, #self.frames[unit].auras[AURA_TYPE_BUFF] do
if i == 1 then
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].auras[AURA_TYPE_BUFF][i]:ClearAllPoints()
self.frames[unit].auras[AURA_TYPE_BUFF][i]:SetPoint("RIGHT", self.frames[unit].buffFrame, "LEFT")
else
self.frames[unit].auras[AURA_TYPE_BUFF][i]:ClearAllPoints()
self.frames[unit].auras[AURA_TYPE_BUFF][i]:SetPoint("LEFT", self.frames[unit].buffFrame, "RIGHT")
end
else
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].auras[AURA_TYPE_BUFF][i]:ClearAllPoints()
@ -475,13 +339,8 @@ function BuffsDebuffs:UpdateAurasOnUnit(unit)
end
for i=1, #self.frames[unit].auras[AURA_TYPE_DEBUFF] do
if i == 1 then
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].auras[AURA_TYPE_DEBUFF][i]:ClearAllPoints()
self.frames[unit].auras[AURA_TYPE_DEBUFF][i]:SetPoint("RIGHT", self.frames[unit].debuffFrame, "LEFT")
else
self.frames[unit].auras[AURA_TYPE_DEBUFF][i]:ClearAllPoints()
self.frames[unit].auras[AURA_TYPE_DEBUFF][i]:SetPoint("LEFT", self.frames[unit].debuffFrame, "RIGHT")
end
else
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].auras[AURA_TYPE_DEBUFF][i]:ClearAllPoints()
@ -602,36 +461,6 @@ end
-- OPTIONS
------------
local function option(params)
local defaults = {
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key]
end,
set = function(info, value)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key] = value
if Gladdy.db.buffsCooldownPos == "LEFT" then
Gladdy.db.buffsCooldownGrowDirection = "LEFT"
elseif Gladdy.db.buffsCooldownPos == "RIGHT" then
Gladdy.db.buffsCooldownGrowDirection = "RIGHT"
end
if Gladdy.db.buffsBuffsCooldownPos == "LEFT" then
Gladdy.db.buffsBuffsCooldownGrowDirection = "LEFT"
elseif Gladdy.db.buffsBuffsCooldownPos == "RIGHT" then
Gladdy.db.buffsBuffsCooldownGrowDirection = "RIGHT"
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function BuffsDebuffs:GetOptions()
return {
headerBuffs = {
@ -714,18 +543,6 @@ function BuffsDebuffs:GetOptions()
name = L["Position"],
order = 5,
},
buffsBuffsCooldownPos = option({
type = "select",
name = L["Aura Position"],
desc = L["Position of the aura icons"],
order = 21,
values = {
["TOP"] = L["Top"],
["BOTTOM"] = L["Bottom"],
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
buffsBuffsCooldownGrowDirection = Gladdy:option({
type = "select",
name = L["Grow Direction"],
@ -836,18 +653,6 @@ function BuffsDebuffs:GetOptions()
name = L["Position"],
order = 5,
},
buffsCooldownPos = option({
type = "select",
name = L["Aura Position"],
desc = L["Position of the aura icons"],
order = 21,
values = {
["TOP"] = L["Top"],
["BOTTOM"] = L["Bottom"],
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
buffsCooldownGrowDirection = Gladdy:option({
type = "select",
name = L["Grow Direction"],
@ -1108,3 +913,168 @@ function BuffsDebuffs:GetOptions()
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function BuffsDebuffs:LegacySetPositionDebuffs(unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
self.frames[unit].debuffFrame:ClearAllPoints()
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
local offset = 0
if (Gladdy.db.buffsCooldownGrowDirection == "RIGHT") then
offset = Gladdy.db.buffsIconSize * Gladdy.db.buffsWidthFactor
end
local pos = Gladdy.db.buffsCooldownPos
if pos == "TOP" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "TOP" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].debuffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset + verticalMargin)
else
self.frames[unit].debuffFrame:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset + verticalMargin)
end
elseif pos == "BOTTOM" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "BOTTOM" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsCooldownGrowDirection == "LEFT" then
self.frames[unit].debuffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
else
self.frames[unit].debuffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset -verticalMargin - powerBarHeight)
end
elseif pos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].debuffFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset)
else
self.frames[unit].debuffFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset)
end
elseif pos == "RIGHT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset)
else
self.frames[unit].debuffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsYOffset)
end
end
return Gladdy.db.newLayout
end
function BuffsDebuffs:LegacySetPositionBuffs(unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
self.frames[unit].buffFrame:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
local verticalMargin = -(Gladdy.db.powerBarHeight)/2
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local offset = 0
if (Gladdy.db.buffsBuffsCooldownGrowDirection == "RIGHT") then
offset = Gladdy.db.buffsBuffsIconSize * Gladdy.db.buffsBuffsWidthFactor
end
local pos = Gladdy.db.buffsBuffsCooldownPos
if pos == "TOP" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "TOP" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].buffFrame:SetPoint("BOTTOMLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
else
self.frames[unit].buffFrame:SetPoint("BOTTOMRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", Gladdy.db.buffsXOffset + offset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
end
elseif pos == "BOTTOM" then
verticalMargin = horizontalMargin + 1
if Gladdy.db.cooldownYPos == "BOTTOM" and Gladdy.db.cooldown then
verticalMargin = verticalMargin + Gladdy.db.cooldownSize
end
if Gladdy.db.buffsBuffsCooldownGrowDirection == "LEFT" then
self.frames[unit].buffFrame:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "BOTTOMRIGHT", Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
else
self.frames[unit].buffFrame:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "BOTTOMLEFT", Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset -verticalMargin - powerBarHeight)
end
elseif pos == "LEFT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "LEFT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "LEFT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "LEFT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "LEFT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "LEFT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.buffsBuffsIconSize/2 + Gladdy.db.padding/2)
end
--self.frames[unit].buffFrame:SetPoint("RIGHT", Gladdy.buttons[unit].healthBar, "LEFT", -horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
local anchor = Gladdy:GetAnchor(unit, "LEFT")
horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) - 1 + Gladdy.db.padding
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].buffFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset)
else
self.frames[unit].buffFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset)
end
elseif pos == "RIGHT" then
horizontalMargin = horizontalMargin - 1 + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
end
elseif (Gladdy.db.classIconPos == "RIGHT") then
horizontalMargin = horizontalMargin + (Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor) + Gladdy.db.padding
if (Gladdy.db.trinketPos == "RIGHT" and Gladdy.db.trinketEnabled) then
horizontalMargin = horizontalMargin + (Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor) + Gladdy.db.padding
end
end
if (Gladdy.db.drCooldownPos == "RIGHT" and Gladdy.db.drEnabled) then
verticalMargin = verticalMargin + Gladdy.db.drIconSize/2 + Gladdy.db.padding/2
end
if (Gladdy.db.castBarPos == "RIGHT") then
verticalMargin = verticalMargin -
(((Gladdy.db.castBarHeight < Gladdy.db.castBarIconSize) and Gladdy.db.castBarIconSize
or Gladdy.db.castBarHeight)/2 + Gladdy.db.padding/2)
end
if (Gladdy.db.cooldownYPos == "RIGHT" and Gladdy.db.cooldown) then
verticalMargin = verticalMargin + (Gladdy.db.buffsBuffsIconSize/2 + Gladdy.db.padding/2)
end
--self.frames[unit].buffFrame:SetPoint("LEFT", Gladdy.buttons[unit].healthBar, "RIGHT", horizontalMargin + Gladdy.db.buffsBuffsXOffset, Gladdy.db.buffsBuffsYOffset + verticalMargin)
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) - 1 + Gladdy.db.padding
if anchor == Gladdy.buttons[unit].healthBar then
self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset)
else
self.frames[unit].buffFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.buffsBuffsXOffset + offset, Gladdy.db.buffsBuffsYOffset)
end
end
return Gladdy.db.newLayout
end

View File

@ -34,7 +34,6 @@ local Castbar = Gladdy:NewModule("Cast Bar", 70, {
castBarBorderColor = { r = 0, g = 0, b = 0, a = 1 },
castBarFontColor = { r = 1, g = 1, b = 1, a = 1 },
castBarGuesses = true,
castBarPos = "LEFT",
castBarXOffset = 0,
castBarYOffset = 0,
castBarIconPos = "LEFT",
@ -57,15 +56,17 @@ end
---------------------------
function Castbar:CreateFrame(unit)
local castBar = CreateFrame("Frame", nil, Gladdy.buttons[unit], BackdropTemplateMixin and "BackdropTemplate")
local castBar = CreateFrame("Frame", nil, Gladdy.buttons[unit])
castBar:EnableMouse(false)
castBar:SetMovable(true)
castBar.unit = unit
castBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"),
castBar.backdrop = CreateFrame("Frame", nil, castBar, BackdropTemplateMixin and "BackdropTemplate")
castBar.backdrop:SetAllPoints(castBar)
castBar.backdrop:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"),
edgeSize = Gladdy.db.castBarBorderSize })
castBar:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar:SetFrameLevel(1)
castBar.backdrop:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar.backdrop:SetFrameLevel(1)
castBar.bar = CreateFrame("StatusBar", nil, castBar)
castBar.bar:SetStatusBarTexture(Gladdy:SMFetch("statusbar", "castBarTexture"))
@ -130,9 +131,9 @@ function Castbar:UpdateFrame(unit)
castBar:SetWidth(Gladdy.db.castBarWidth)
castBar:SetHeight(Gladdy.db.castBarHeight)
castBar:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"),
castBar.backdrop:SetBackdrop({ edgeFile = Gladdy:SMFetch("border", "castBarBorderStyle"),
edgeSize = Gladdy.db.castBarBorderSize })
castBar:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar.backdrop:SetBackdropBorderColor(Gladdy.db.castBarBorderColor.r, Gladdy.db.castBarBorderColor.g, Gladdy.db.castBarBorderColor.b, Gladdy.db.castBarBorderColor.a)
castBar.bar:SetStatusBarTexture(Gladdy:SMFetch("statusbar", "castBarTexture"))
castBar.bar:ClearAllPoints()
@ -165,24 +166,7 @@ function Castbar:UpdateFrame(unit)
leftMargin = Gladdy.db.castBarIconSize + 1
end
castBar:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.castBarPos == "LEFT") then
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
castBar:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin - leftMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
else
castBar:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding - leftMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
end
end
if (Gladdy.db.castBarPos == "RIGHT") then
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
castBar:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + rightMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
else
castBar:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + rightMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
end
end
Gladdy:SetPosition(castBar, unit, "castBarXOffset", "castBarYOffset", Castbar:LegacySetPosition(castBar, unit, leftMargin, rightMargin), Castbar)
castBar.spellText:SetFont(Gladdy:SMFetch("font", "castBarFont"), Gladdy.db.castBarFontSize)
castBar.spellText:SetTextColor(Gladdy.db.castBarFontColor.r, Gladdy.db.castBarFontColor.g, Gladdy.db.castBarFontColor.b, Gladdy.db.castBarFontColor.a)
@ -410,7 +394,10 @@ function Castbar:CAST_START(unit, spell, icon, value, maxValue, test)
castBar.spellText:SetText(spell)
castBar.timeText:SetText(maxValue)
castBar.bg:Show()
castBar:Show()
castBar.backdrop:Show()
if Gladdy.db.castBarSparkEnabled then
castBar.spark:Show()
end
castBar:SetAlpha(1)
castBar.icon:Show()
end
@ -430,7 +417,8 @@ function Castbar:CAST_STOP(unit, ...)
castBar.timeText:SetText("")
castBar.bar:SetValue(0)
castBar.bg:Hide()
castBar:Hide()
castBar.backdrop:Hide()
castBar.spark:Hide()
castBar.icon:Hide()
else
castBar.bar:SetStatusBarColor(...)
@ -771,15 +759,6 @@ function Castbar:GetOptions()
name = L["Position"],
order = 1,
},
castBarPos = option({
type = "select",
name = L["Castbar position"],
order = 2,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
castBarIconPos = option( {
type = "select",
name = L["Icon position"],
@ -818,3 +797,34 @@ function Castbar:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Castbar:LegacySetPosition(castBar, unit, leftMargin, rightMargin)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
castBar:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.castBarPos == "LEFT") then
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
castBar:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin - leftMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
else
castBar:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding - leftMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
end
end
if (Gladdy.db.castBarPos == "RIGHT") then
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
castBar:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + rightMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
else
castBar:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + rightMargin + Gladdy.db.castBarXOffset, Gladdy.db.castBarYOffset)
end
end
return Gladdy.db.newLayout
end

View File

@ -4,13 +4,14 @@ local Gladdy = LibStub("Gladdy")
local CreateFrame = CreateFrame
local GetSpellInfo = GetSpellInfo
local L = Gladdy.L
local Classicon = Gladdy:NewModule("Class Icon", 80, {
classIconPos = "LEFT",
local Classicon = Gladdy:NewModule("Class Icon", 81, {
classIconSize = 60 + 20 + 1,
classIconWidthFactor = 0.9,
classIconBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
classIconBorderColor = { r = 0, g = 0, b = 0, a = 1 },
classIconSpecIcon = false,
classIconXOffset = 0,
classIconYOffset = 0,
})
local classIconPath = "Interface\\Addons\\Gladdy\\Images\\Classes\\"
@ -99,13 +100,6 @@ function Classicon:CreateFrame(unit)
classIcon:SetFrameStrata("MEDIUM")
classIcon:SetFrameLevel(2)
classIcon:ClearAllPoints()
if (Gladdy.db.classIconPos == "RIGHT") then
classIcon:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", 2, 2)
else
classIcon:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -2, 2)
end
Gladdy.buttons[unit].classIcon = classIcon
self.frames[unit] = classIcon
end
@ -119,12 +113,15 @@ function Classicon:UpdateFrame(unit)
classIcon:SetWidth(Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor)
classIcon:SetHeight(Gladdy.db.classIconSize)
classIcon:ClearAllPoints()
local margin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
classIcon:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
else
classIcon:SetPoint("TOPLEFT", Gladdy.buttons[unit], "TOPRIGHT", margin, 0)
Gladdy:SetPosition(classIcon, unit, "classIconXOffset", "classIconYOffset", Classicon:LegacySetPosition(classIcon, unit), Classicon)
if (unit == "arena1") then
Gladdy:CreateMover(classIcon, "classIconXOffset", "classIconYOffset", L["Class Icon"],
{"TOPLEFT", "TOPLEFT"},
Gladdy.db.classIconSize * Gladdy.db.classIconWidthFactor,
Gladdy.db.classIconSize,
0,
0)
end
classIcon.texture:ClearAllPoints()
@ -279,3 +276,22 @@ function Classicon:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Classicon:LegacySetPosition(classIcon, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
classIcon:ClearAllPoints()
local margin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
classIcon:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
else
classIcon:SetPoint("TOPLEFT", Gladdy.buttons[unit], "TOPRIGHT", margin, 0)
end
end

View File

@ -1,7 +1,6 @@
local select = select
local UnitExists, UnitAffectingCombat, GetSpellInfo = UnitExists, UnitAffectingCombat, GetSpellInfo
local CreateFrame = CreateFrame
local ANCHORS = { ["LEFT"] = "RIGHT", ["RIGHT"] = "LEFT", ["BOTTOM"] = "TOP", ["TOP"] = "BOTTOM"}
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
@ -11,8 +10,6 @@ local CombatIndicator = Gladdy:NewModule("Combat Indicator", nil, {
ciSize = 20,
ciAlpha = 1,
ciWidthFactor = 1,
ciAnchor = "healthBar",
ciPos = "TOP",
ciXOffset = 0,
ciYOffset = -31,
ciBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
@ -68,8 +65,7 @@ function CombatIndicator:UpdateFrame(unit)
ciFrame.border:SetTexture(Gladdy.db.ciBorderStyle)
ciFrame.border:SetVertexColor(Gladdy.db.ciBorderColor.r, Gladdy.db.ciBorderColor.g, Gladdy.db.ciBorderColor.b, Gladdy.db.ciBorderColor.a)
ciFrame:ClearAllPoints()
ciFrame:SetPoint(ANCHORS[Gladdy.db.ciPos], Gladdy.buttons[unit][Gladdy.db.ciAnchor], Gladdy.db.ciPos, Gladdy.db.ciXOffset, Gladdy.db.ciYOffset)
Gladdy:SetPosition(ciFrame, unit, "ciXOffset", "ciYOffset", CombatIndicator:LegacySetPosition(ciFrame, unit), CombatIndicator)
ciFrame:SetAlpha(Gladdy.db.ciAlpha)
@ -177,30 +173,6 @@ function CombatIndicator:GetOptions()
name = L["Position"],
order = 4,
},
ciAnchor = Gladdy:option({
type = "select",
name = L["Anchor"],
desc = L["This changes the anchor of the ci icon"],
order = 20,
values = {
["trinket"] = L["Trinket"],
["classIcon"] = L["Class Icon"],
["healthBar"] = L["Health Bar"],
["powerBar"] = L["Power Bar"],
},
}),
ciPos = Gladdy:option({
type = "select",
name = L["Position"],
desc = L["This changes position relative to its anchor of the ci icon"],
order = 21,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
["TOP"] = L["Top"],
["BOTTOM"] = L["Bottom"],
},
}),
ciXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
@ -250,3 +222,23 @@ function CombatIndicator:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function CombatIndicator:LegacySetPosition(ciFrame, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
-- LEGACY options
local ANCHORS = { ["LEFT"] = "RIGHT", ["RIGHT"] = "LEFT", ["BOTTOM"] = "TOP", ["TOP"] = "BOTTOM"}
local ciAnchor = Gladdy.db.ciAnchor or Gladdy.legacy.ciAnchor
local ciPos = Gladdy.db.ciPos
ciFrame:ClearAllPoints()
ciFrame:SetPoint(ANCHORS[ciPos], Gladdy.buttons[unit][ciAnchor], ciPos, Gladdy.db.ciXOffset, Gladdy.db.ciYOffset)
return Gladdy.db.newLayout
end

View File

@ -1,4 +1,4 @@
local type, pairs, ceil, tonumber, mod, tostring, upper, select = type, pairs, ceil, tonumber, mod, tostring, string.upper, select
local type, pairs, ipairs, ceil, tonumber, mod, tostring, upper, select = type, pairs, ipairs, ceil, tonumber, mod, tostring, string.upper, select
local GetTime = GetTime
local CreateFrame = CreateFrame
local RACE_ICON_TCOORDS = {
@ -54,8 +54,8 @@ local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
cooldownFontScale = 1,
cooldownFontColor = { r = 1, g = 1, b = 0, a = 1 },
cooldown = true,
cooldownYPos = "TOP",
cooldownXPos = "LEFT",
cooldownYGrowDirection = "UP",
cooldownXGrowDirection = "RIGHT",
cooldownYOffset = 0,
cooldownXOffset = 0,
cooldownSize = 30,
@ -66,7 +66,7 @@ local Cooldowns = Gladdy:NewModule("Cooldowns", nil, {
cooldownBorderColor = { r = 1, g = 1, b = 1, a = 1 },
cooldownDisableCircle = false,
cooldownCooldownAlpha = 1,
cooldownCooldowns = getDefaultCooldown()
cooldownCooldowns = getDefaultCooldown(),
})
function Cooldowns:Initialize()
@ -134,42 +134,15 @@ function Cooldowns:UpdateFrame(unit)
local button = Gladdy.buttons[unit]
-- Cooldown frame
if (Gladdy.db.cooldown) then
button.spellCooldownFrame:ClearAllPoints()
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
if Gladdy.db.cooldownYPos == "TOP" then
if Gladdy.db.cooldownXPos == "RIGHT" then
button.spellCooldownFrame:SetPoint("BOTTOMRIGHT", button.healthBar, "TOPRIGHT", Gladdy.db.cooldownXOffset, horizontalMargin + Gladdy.db.cooldownYOffset)
else
button.spellCooldownFrame:SetPoint("BOTTOMLEFT", button.healthBar, "TOPLEFT", Gladdy.db.cooldownXOffset, horizontalMargin + Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "BOTTOM" then
if Gladdy.db.cooldownXPos == "RIGHT" then
button.spellCooldownFrame:SetPoint("TOPRIGHT", button.healthBar, "BOTTOMRIGHT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
else
button.spellCooldownFrame:SetPoint("TOPLEFT", button.healthBar, "BOTTOMLEFT", Gladdy.db.cooldownXOffset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
end
elseif Gladdy.db.cooldownYPos == "LEFT" then
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
button.spellCooldownFrame:SetPoint("RIGHT", anchor, "LEFT", -(horizontalMargin + Gladdy.db.padding) + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset)
else
button.spellCooldownFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "RIGHT" then
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
button.spellCooldownFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.padding + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset)
else
button.spellCooldownFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.cooldownXOffset, Gladdy.db.cooldownYOffset)
end
end
button.spellCooldownFrame:SetHeight(Gladdy.db.cooldownSize)
button.spellCooldownFrame:SetWidth(1)
button.spellCooldownFrame:Show()
Gladdy:SetPosition(button.spellCooldownFrame, unit, "cooldownXOffset", "cooldownYOffset", Cooldowns:LegacySetPosition(button, unit), Cooldowns)
if (unit == "arena1") then
Gladdy:CreateMover(button.spellCooldownFrame,"cooldownXOffset", "cooldownYOffset", L["Cooldown"],
Gladdy.db.cooldownXPos == "RIGHT" and {"TOPRIGHT", "TOPRIGHT"} or {"TOPLEFT", "TOPLEFT"},
{"TOPLEFT", "TOPLEFT"},
Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor, Gladdy.db.cooldownSize)
end
-- Update each cooldown icon
@ -181,11 +154,11 @@ function Cooldowns:UpdateFrame(unit)
icon.cooldownFont:SetFont(Gladdy:SMFetch("font", "cooldownFont"), Gladdy.db.cooldownSize / 2 * Gladdy.db.cooldownFontScale, "OUTLINE")
icon.cooldownFont:SetTextColor(Gladdy.db.cooldownFontColor.r, Gladdy.db.cooldownFontColor.g, Gladdy.db.cooldownFontColor.b, Gladdy.db.cooldownFontColor.a)
icon:ClearAllPoints()
if (Gladdy.db.cooldownXPos == "RIGHT") then
if (Gladdy.db.cooldownXGrowDirection == "LEFT") then
if (j == 1) then
icon:SetPoint("RIGHT", button.spellCooldownFrame, "RIGHT", 0, 0)
icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0)
elseif (mod(j-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYPos == "BOTTOM" or Gladdy.db.cooldownYPos == "LEFT" or Gladdy.db.cooldownYPos == "RIGHT") then
if (Gladdy.db.cooldownYGrowDirection == "DOWN") then
icon:SetPoint("TOP", button.spellCooldownFrame["icon" .. o], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else
icon:SetPoint("BOTTOM", button.spellCooldownFrame["icon" .. o], "TOP", 0, Gladdy.db.cooldownIconPadding)
@ -195,11 +168,11 @@ function Cooldowns:UpdateFrame(unit)
icon:SetPoint("RIGHT", button.spellCooldownFrame["icon" .. j - 1], "LEFT", -Gladdy.db.cooldownIconPadding, 0)
end
end
if (Gladdy.db.cooldownXPos == "LEFT") then
if (Gladdy.db.cooldownXGrowDirection == "RIGHT") then
if (j == 1) then
icon:SetPoint("LEFT", button.spellCooldownFrame, "LEFT", 0, 0)
elseif (mod(j-1,Gladdy.db.cooldownMaxIconsPerLine) == 0) then
if (Gladdy.db.cooldownYPos == "BOTTOM" or Gladdy.db.cooldownYPos == "LEFT" or Gladdy.db.cooldownYPos == "RIGHT") then
if (Gladdy.db.cooldownYGrowDirection == "DOWN") then
icon:SetPoint("TOP", button.spellCooldownFrame["icon" .. o], "BOTTOM", 0, -Gladdy.db.cooldownIconPadding)
else
icon:SetPoint("BOTTOM", button.spellCooldownFrame["icon" .. o], "TOP", 0, Gladdy.db.cooldownIconPadding)
@ -561,31 +534,6 @@ function Cooldowns:CooldownUsed(unit, unitClass, spellId, expirationTimeInSecond
end ]]
end
local function option(params)
local defaults = {
get = function(info)
local key = info.arg or info[#info]
return Gladdy.dbi.profile[key]
end,
set = function(info, value)
local key = info.arg or info[#info]
Gladdy.dbi.profile[key] = value
if Gladdy.db.cooldownYPos == "LEFT" then
Gladdy.db.cooldownXPos = "RIGHT"
elseif Gladdy.db.cooldownYPos == "RIGHT" then
Gladdy.db.cooldownXPos = "LEFT"
end
Gladdy:UpdateFrame()
end,
}
for k, v in pairs(params) do
defaults[k] = v
end
return defaults
end
function Cooldowns:GetOptions()
return {
headerCooldown = {
@ -644,15 +592,6 @@ function Cooldowns:GetOptions()
step = 0.1,
width = "full",
}),
cooldownMaxIconsPerLine = Gladdy:option({
type = "range",
name = L["Max Icons per row"],
order = 7,
min = 3,
max = 14,
step = 1,
width = "full",
}),
},
},
cooldown = {
@ -745,37 +684,44 @@ function Cooldowns:GetOptions()
name = L["Position"],
order = 2,
},
cooldownYPos = option({
cooldownYGrowDirection = Gladdy:option({
type = "select",
name = L["Anchor"],
desc = L["Anchor of the cooldown icons"],
name = L["Vertical Grow Direction"],
desc = L["Vertical Grow Direction of the cooldown icons"],
order = 3,
values = {
["TOP"] = L["Top"],
["BOTTOM"] = L["Bottom"],
["UP"] = L["Up"],
["DOWN"] = L["Down"],
},
}),
cooldownXGrowDirection = Gladdy:option({
type = "select",
name = L["Horizontal Grow Direction"],
desc = L["Horizontal Grow Direction of the cooldown icons"],
order = 4,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
cooldownXPos = Gladdy:option({
type = "select",
name = L["Grow Direction"],
desc = L["Grow Direction of the cooldown icons"],
order = 4,
values = {
["LEFT"] = L["Right"],
["RIGHT"] = L["Left"],
},
cooldownMaxIconsPerLine = Gladdy:option({
type = "range",
name = L["Max Icons per row"],
order = 5,
min = 3,
max = 14,
step = 1,
width = "full",
}),
headerOffset = {
type = "header",
name = L["Offset"],
order = 5,
order = 10,
},
cooldownXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
order = 6,
order = 11,
min = -400,
max = 400,
step = 0.1,
@ -784,7 +730,7 @@ function Cooldowns:GetOptions()
cooldownYOffset = Gladdy:option({
type = "range",
name = L["Vertical offset"],
order = 7,
order = 12,
min = -400,
max = 400,
step = 0.1,
@ -914,3 +860,66 @@ function Gladdy:UpdateTestCooldowns(i)
end
end
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Cooldowns:LegacySetPosition(button, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
button.spellCooldownFrame:ClearAllPoints()
local powerBarHeight = Gladdy.db.powerBarEnabled and (Gladdy.db.powerBarHeight + 1) or 0
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize)
local offset = 0
if (Gladdy.db.cooldownXPos == "RIGHT") then
offset = -(Gladdy.db.cooldownSize * Gladdy.db.cooldownWidthFactor)
end
if Gladdy.db.cooldownYPos == "TOP" then
Gladdy.db.cooldownYGrowDirection = "UP"
if Gladdy.db.cooldownXPos == "RIGHT" then
Gladdy.db.cooldownXGrowDirection = "LEFT"
button.spellCooldownFrame:SetPoint("BOTTOMRIGHT", button.healthBar, "TOPRIGHT", Gladdy.db.cooldownXOffset + offset, horizontalMargin + Gladdy.db.cooldownYOffset)
else
Gladdy.db.cooldownXGrowDirection = "RIGHT"
button.spellCooldownFrame:SetPoint("BOTTOMLEFT", button.healthBar, "TOPLEFT", Gladdy.db.cooldownXOffset + offset, horizontalMargin + Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "BOTTOM" then
Gladdy.db.cooldownYGrowDirection = "DOWN"
if Gladdy.db.cooldownXPos == "RIGHT" then
Gladdy.db.cooldownXGrowDirection = "LEFT"
button.spellCooldownFrame:SetPoint("TOPRIGHT", button.healthBar, "BOTTOMRIGHT", Gladdy.db.cooldownXOffset + offset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
else
Gladdy.db.cooldownXGrowDirection = "RIGHT"
button.spellCooldownFrame:SetPoint("TOPLEFT", button.healthBar, "BOTTOMLEFT", Gladdy.db.cooldownXOffset + offset, -horizontalMargin + Gladdy.db.cooldownYOffset - powerBarHeight)
end
elseif Gladdy.db.cooldownYPos == "LEFT" then
Gladdy.db.cooldownYGrowDirection = "DOWN"
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
Gladdy.db.cooldownXGrowDirection = "LEFT"
button.spellCooldownFrame:SetPoint("RIGHT", anchor, "LEFT", -(horizontalMargin + Gladdy.db.padding) + Gladdy.db.cooldownXOffset + offset, Gladdy.db.cooldownYOffset)
else
Gladdy.db.cooldownXGrowDirection = "LEFT"
button.spellCooldownFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.cooldownXOffset + offset, Gladdy.db.cooldownYOffset)
end
elseif Gladdy.db.cooldownYPos == "RIGHT" then
Gladdy.db.cooldownYGrowDirection = "DOWN"
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
Gladdy.db.cooldownXGrowDirection = "RIGHT"
button.spellCooldownFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.padding + Gladdy.db.cooldownXOffset + offset, Gladdy.db.cooldownYOffset)
else
Gladdy.db.cooldownXGrowDirection = "RIGHT"
button.spellCooldownFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.cooldownXOffset + offset, Gladdy.db.cooldownYOffset)
end
end
LibStub("AceConfigRegistry-3.0"):NotifyChange("Gladdy")
return Gladdy.db.newLayout
end

View File

@ -30,7 +30,7 @@ local Diminishings = Gladdy:NewModule("Diminishings", nil, {
drFont = "DorisPP",
drFontColor = { r = 1, g = 1, b = 0, a = 1 },
drFontScale = 1,
drCooldownPos = "RIGHT",
drGrowDirection = "RIGHT",
drXOffset = 0,
drYOffset = 0,
drIconSize = 36,
@ -49,7 +49,7 @@ local Diminishings = Gladdy:NewModule("Diminishings", nil, {
drLevelTextFontScale = 1,
drWidthFactor = 1,
drCategories = defaultCategories(),
drDuration = 18
drDuration = 18,
})
local function getDiminishColor(dr)
@ -179,34 +179,18 @@ function Diminishings:UpdateFrame(unit)
drFrame:Show()
end
drFrame:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.drCooldownPos == "LEFT") then
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
if (Gladdy.db.drCooldownPos == "RIGHT") then
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
drFrame:SetWidth(Gladdy.db.drIconSize * 16)
drFrame:SetWidth(Gladdy.db.drIconSize)
drFrame:SetHeight(Gladdy.db.drIconSize)
Gladdy:SetPosition(drFrame, unit, "drXOffset", "drYOffset", Diminishings:LegacySetPosition(drFrame, unit), Diminishings)
if (unit == "arena1") then
Gladdy:CreateMover(drFrame,"drXOffset", "drYOffset", L["Diminishings"],
Gladdy.db.drCooldownPos == "RIGHT" and {"TOPLEFT", "TOPLEFT"} or {"TOPRIGHT", "TOPRIGHT"}, --point
Gladdy.db.drIconSize * Gladdy.db.drWidthFactor, -- width
Gladdy.db.drGrowDirection == "RIGHT" and {"TOPLEFT", "TOPLEFT"} or {"TOPRIGHT", "TOPRIGHT"},
Gladdy.db.drIconSize * Gladdy.db.drWidthFactor,
Gladdy.db.drIconSize,
0, --xoffset
0) --yoffset
0,
0)
end
for i = 1, 16 do
@ -245,15 +229,15 @@ function Diminishings:UpdateFrame(unit)
end
icon:ClearAllPoints()
if (Gladdy.db.drCooldownPos == "LEFT") then
if (Gladdy.db.drGrowDirection == "LEFT") then
if (i == 1) then
icon:SetPoint("TOPRIGHT")
icon:SetPoint("TOPRIGHT", drFrame, "TOPRIGHT")
else
icon:SetPoint("RIGHT", drFrame["icon" .. (i - 1)], "LEFT", -Gladdy.db.drIconPadding, 0)
end
else
if (i == 1) then
icon:SetPoint("TOPLEFT")
icon:SetPoint("TOPLEFT", drFrame, "TOPLEFT")
else
icon:SetPoint("LEFT", drFrame["icon" .. (i - 1)], "RIGHT", Gladdy.db.drIconPadding, 0)
end
@ -383,13 +367,15 @@ function Diminishings:Positionate(unit)
if (icon.active) then
icon:ClearAllPoints()
if (Gladdy.db.drCooldownPos == "LEFT") then
if (Gladdy.db.newLayout and Gladdy.db.drGrowDirection == "LEFT"
or not Gladdy.db.newLayout and Gladdy.db.drCooldownPos == "LEFT") then
if (not lastIcon) then
icon:SetPoint("TOPRIGHT")
else
icon:SetPoint("RIGHT", lastIcon, "LEFT", -Gladdy.db.drIconPadding, 0)
end
else
elseif (Gladdy.db.newLayout and Gladdy.db.drGrowDirection == "RIGHT"
or not Gladdy.db.newLayout and Gladdy.db.drCooldownPos == "RIGHT") then
if (not lastIcon) then
icon:SetPoint("TOPLEFT")
else
@ -562,21 +548,16 @@ function Diminishings:GetOptions()
name = L["Position"],
order = 20,
},
drCooldownPos = Gladdy:option({
drGrowDirection = Gladdy:option({
type = "select",
name = L["DR Cooldown position"],
desc = L["Position of the cooldown icons"],
name = L["DR Grow Direction"],
desc = L["Grow Direction of the dr icons"],
order = 21,
values = {
["LEFT"] = L["Left"],
["RIGHT"] = L["Right"],
},
}),
headerOffset = {
type = "header",
name = L["Offset"],
order = 22,
},
drXOffset = Gladdy:option({
type = "range",
name = L["Horizontal offset"],
@ -791,3 +772,36 @@ function Diminishings:GetDRIcons(category)
end
return icons
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Diminishings:LegacySetPosition(drFrame, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
drFrame:ClearAllPoints()
local horizontalMargin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.drCooldownPos == "LEFT") then
Gladdy.db.drGrowDirection = "LEFT"
local anchor = Gladdy:GetAnchor(unit, "LEFT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("RIGHT", anchor, "LEFT", -horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("RIGHT", anchor, "LEFT", -Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
if (Gladdy.db.drCooldownPos == "RIGHT") then
Gladdy.db.drGrowDirection = "RIGHT"
local anchor = Gladdy:GetAnchor(unit, "RIGHT")
if anchor == Gladdy.buttons[unit].healthBar then
drFrame:SetPoint("LEFT", anchor, "RIGHT", horizontalMargin + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
else
drFrame:SetPoint("LEFT", anchor, "RIGHT", Gladdy.db.padding + Gladdy.db.drXOffset, Gladdy.db.drYOffset)
end
end
return Gladdy.db.newLayout
end

View File

@ -95,7 +95,21 @@ local deletedOptions = { -- backwards compatibility
impconc = true,
dragonsbreath = true,
freezetrap = true,
repentance = true
--deleted db options
castBarPos = true,
buffsCooldownPos = true,
buffsBuffsCooldownPos = true,
classIconPos = true,
ciAnchor = true,
ciPos = true,
cooldownYPos = true,
cooldownXPos = true,
drCooldownPos = true,
racialAnchor = true,
racialPos = true,
trinketPos = true,
padding = true,
growUp = true,
}
local function checkIsDeletedOption(k, str, msg, errorFound, errorMsg)
@ -208,6 +222,9 @@ end
function ExportImport:ApplyImport(t, table, str)
if str == nil then
str = "Gladdy.db"
if (not t.newLayout) then
table.newLayout = false
end
end
for k,v in pairs(t) do
if type(v) == "table" then

View File

@ -253,10 +253,13 @@ function Pets:UpdateFrame(unitId)
self.frames[unit]:SetWidth(Gladdy.db.petWidth)
self.frames[unit]:SetHeight(Gladdy.db.petHeight)
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
Gladdy:SetPosition(self.frames[unit], unitId, "petXOffset", "petYOffset", Pets:LegacySetPosition(unit, unitId), Pets)
if (Gladdy.db.petGroup) then
if (unit == "arenapet1") then
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("TOPLEFT", Gladdy.buttons[unitId].healthBar, "TOPLEFT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
else
local previousPet = "arenapet" .. string_gsub(unit, "arenapet", "") - 1
self.frames[unit]:ClearAllPoints()
@ -264,7 +267,7 @@ function Pets:UpdateFrame(unitId)
end
else
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
self.frames[unit]:SetPoint("TOPLEFT", Gladdy.buttons[unitId].healthBar, "TOPLEFT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
end
healthBar.portrait:SetHeight(Gladdy.db.petHeight)
@ -588,3 +591,30 @@ function Pets:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Pets:LegacySetPosition(unit, unitId)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
if (Gladdy.db.petGroup) then
if (unit == "arenapet1") then
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
else
local previousPet = "arenapet" .. string_gsub(unit, "arenapet", "") - 1
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("TOPLEFT", self.frames[previousPet], "BOTTOMLEFT", 0, - Gladdy.db.petMargin)
end
else
self.frames[unit]:ClearAllPoints()
self.frames[unit]:SetPoint("LEFT", Gladdy.buttons[unitId].healthBar, "RIGHT", Gladdy.db.petXOffset, Gladdy.db.petYOffset)
end
return Gladdy.db.newLayout
end

View File

@ -5,14 +5,12 @@ local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Racial = Gladdy:NewModule("Racial", nil, {
local Racial = Gladdy:NewModule("Racial", 79, {
racialFont = "DorisPP",
racialFontScale = 1,
racialEnabled = true,
racialSize = 60 + 20 + 1,
racialWidthFactor = 0.9,
racialAnchor = "trinket",
racialPos = "RIGHT",
racialXOffset = 0,
racialYOffset = 0,
racialBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
@ -22,7 +20,6 @@ local Racial = Gladdy:NewModule("Racial", nil, {
racialCooldownNumberAlpha = 1,
})
local ANCHORS = { ["LEFT"] = "RIGHT", ["RIGHT"] = "LEFT", ["BOTTOM"] = "TOP", ["TOP"] = "BOTTOM"}
function Racial:Initialize()
self.frames = {}
@ -121,16 +118,15 @@ function Racial:UpdateFrame(unit)
racial.texture.overlay:SetTexture(Gladdy.db.racialBorderStyle)
racial.texture.overlay:SetVertexColor(Gladdy.db.racialBorderColor.r, Gladdy.db.racialBorderColor.g, Gladdy.db.racialBorderColor.b, Gladdy.db.racialBorderColor.a)
racial:ClearAllPoints()
local parent = Gladdy.buttons[unit][Gladdy.db.racialAnchor]
if (Gladdy.db.racialPos == "RIGHT") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.padding + Gladdy.db.racialXOffset, Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "LEFT") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, -Gladdy.db.padding + Gladdy.db.racialXOffset, Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "TOP") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.racialXOffset, Gladdy.db.padding + Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "BOTTOM") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.racialXOffset, -Gladdy.db.padding + Gladdy.db.racialYOffset)
Gladdy:SetPosition(racial, unit, "racialXOffset", "racialYOffset", Racial:LegacySetPosition(racial, unit), Racial)
if (unit == "arena1") then
Gladdy:CreateMover(racial,"racialXOffset", "racialYOffset", L["Racial"],
{"TOPLEFT", "TOPLEFT"},
Gladdy.db.racialSize * Gladdy.db.racialWidthFactor,
Gladdy.db.racialSize,
0,
0)
end
if (Gladdy.db.racialEnabled == false) then
@ -395,3 +391,29 @@ function Racial:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Racial:LegacySetPosition(racial, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
local ANCHORS = { ["LEFT"] = "RIGHT", ["RIGHT"] = "LEFT", ["BOTTOM"] = "TOP", ["TOP"] = "BOTTOM"}
racial:ClearAllPoints()
local parent = Gladdy.buttons[unit][Gladdy.db.racialAnchor]
if (Gladdy.db.racialPos == "RIGHT") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.padding + Gladdy.db.racialXOffset, Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "LEFT") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, -Gladdy.db.padding + Gladdy.db.racialXOffset, Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "TOP") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.racialXOffset, Gladdy.db.padding + Gladdy.db.racialYOffset)
elseif (Gladdy.db.racialPos == "BOTTOM") then
racial:SetPoint(ANCHORS[Gladdy.db.racialPos], parent, Gladdy.db.racialPos, Gladdy.db.racialXOffset, -Gladdy.db.padding + Gladdy.db.racialYOffset)
end
return Gladdy.db.newLayout
end

View File

@ -6,18 +6,19 @@ local GetTime = GetTime
local Gladdy = LibStub("Gladdy")
local L = Gladdy.L
local Trinket = Gladdy:NewModule("Trinket", nil, {
local Trinket = Gladdy:NewModule("Trinket", 80, {
trinketFont = "DorisPP",
trinketFontScale = 1,
trinketEnabled = true,
trinketSize = 60 + 20 + 1,
trinketWidthFactor = 0.9,
trinketPos = "RIGHT",
trinketBorderStyle = "Interface\\AddOns\\Gladdy\\Images\\Border_rounded_blp",
trinketBorderColor = { r = 0, g = 0, b = 0, a = 1 },
trinketDisableCircle = false,
trinketCooldownAlpha = 1,
trinketCooldownNumberAlpha = 1,
trinketXOffset = 0,
trinketYOffset = 0,
})
LibStub("AceComm-3.0"):Embed(Trinket)
@ -119,20 +120,15 @@ function Trinket:UpdateFrame(unit)
trinket.texture.overlay:SetTexture(Gladdy.db.trinketBorderStyle)
trinket.texture.overlay:SetVertexColor(Gladdy.db.trinketBorderColor.r, Gladdy.db.trinketBorderColor.g, Gladdy.db.trinketBorderColor.b, Gladdy.db.trinketBorderColor.a)
trinket:ClearAllPoints()
local margin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", margin, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].classIcon, "TOPLEFT", -Gladdy.db.padding, 0)
end
else
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].classIcon, "TOPRIGHT", Gladdy.db.padding, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
end
Gladdy:SetPosition(trinket, unit, "trinketXOffset", "trinketYOffset", Trinket:LegacySetPosition(trinket, unit), Trinket)
if (unit == "arena1") then
Gladdy:CreateMover(trinket,"trinketXOffset", "trinketYOffset", L["Trinket"],
{"TOPLEFT", "TOPLEFT"},
Gladdy.db.trinketSize * Gladdy.db.trinketWidthFactor,
Gladdy.db.trinketSize,
0,
0)
end
if (Gladdy.db.trinketEnabled == false) then
@ -369,3 +365,30 @@ function Trinket:GetOptions()
},
}
end
---------------------------
-- LAGACY HANDLER
---------------------------
function Trinket:LegacySetPosition(trinket, unit)
if Gladdy.db.newLayout then
return Gladdy.db.newLayout
end
trinket:ClearAllPoints()
local margin = (Gladdy.db.highlightInset and 0 or Gladdy.db.highlightBorderSize) + Gladdy.db.padding
if (Gladdy.db.classIconPos == "LEFT") then
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].healthBar, "TOPRIGHT", margin, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].classIcon, "TOPLEFT", -Gladdy.db.padding, 0)
end
else
if (Gladdy.db.trinketPos == "RIGHT") then
trinket:SetPoint("TOPLEFT", Gladdy.buttons[unit].classIcon, "TOPRIGHT", Gladdy.db.padding, 0)
else
trinket:SetPoint("TOPRIGHT", Gladdy.buttons[unit].healthBar, "TOPLEFT", -margin, 0)
end
end
end

View File

@ -47,16 +47,16 @@ Gladdy.defaults = {
hideBlizzard = "arena",
x = 0,
y = 0,
growUp = false,
growDirection = "BOTTOM",
frameScale = 1,
pixelPerfect = false,
padding = 1,
barWidth = 180,
bottomMargin = 2,
statusbarBorderOffset = 6,
timerFormat = Gladdy.TIMER_FORMAT.tenths,
backgroundColor = {r = 0, g = 0, b = 0, a = 0},
newLayout = false,
showMover = true,
},
}
@ -215,19 +215,45 @@ function Gladdy:SetupOptions()
get = getOpt,
set = setOpt,
args = {
test = {
lock = {
order = 1,
width = 0.7,
name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"],
desc = L["Toggle if frame can be moved"],
type = "execute",
func = function()
Gladdy.db.locked = not Gladdy.db.locked
Gladdy:UpdateFrame()
self.options.args.lock.name = Gladdy.db.locked and L["Unlock frame"] or L["Lock frame"]
end,
},
showMover = {
order = 2,
width = 0.7,
name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"],
desc = L["Toggle to show Mover Frames"],
type = "execute",
func = function()
Gladdy.db.showMover = not Gladdy.db.showMover
Gladdy:UpdateFrame()
self.options.args.showMover.name = Gladdy.db.showMover and L["Hide Mover"] or L["Show Mover"]
end,
},
test = {
order = 2,
width = 0.7,
name = L["Test"],
desc = L["Show Test frames"],
type = "execute",
func = function()
Gladdy:ToggleFrame(3)
end,
},
hide = {
order = 2,
order = 3,
width = 0.7,
name = L["Hide"],
desc = L["Hide frames"],
type = "execute",
func = function()
Gladdy:Reset()
@ -235,16 +261,17 @@ function Gladdy:SetupOptions()
end,
},
reload = {
order = 3,
order = 4,
width = 0.7,
name = L["ReloadUI"],
desc = L["Reloads the UI"],
type = "execute",
func = function()
ReloadUI()
end,
},
version = {
order = 4,
order = 5,
width = 1,
type = "description",
name = " Gladdy v" .. Gladdy.version_num .. "-" .. Gladdy.version_releaseType
@ -256,12 +283,6 @@ function Gladdy:SetupOptions()
childGroups = "tab",
order = 5,
args = {
locked = {
type = "toggle",
name = L["Lock frame"],
desc = L["Toggle if frame can be moved"],
order = 1,
},
growDirection = {
type = "select",
name = L["Grow Direction"],
@ -315,15 +336,6 @@ function Gladdy:SetupOptions()
max = 2,
step = .01,
},
padding = {
type = "range",
name = L["Frame padding"],
desc = L["Padding of the frame"],
order = 6,
min = 0,
max = 20,
step = 1,
},
barWidth = {
type = "range",
name = L["Frame width"],