some work on pet bar, interim commit so i can raid in peace :P
This commit is contained in:
+77
-2
@@ -27,9 +27,17 @@ function PetBarMod:OnEnable()
|
|||||||
if not self.bar then
|
if not self.bar then
|
||||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", nil, self.db.profile), {__index = PetBar})
|
self.bar = setmetatable(Bartender4.ButtonBar:Create("Pet", nil, self.db.profile), {__index = PetBar})
|
||||||
|
|
||||||
|
local buttons = {}
|
||||||
|
for i=1,10 do
|
||||||
|
buttons[i] = self:CreatePetButton(i)
|
||||||
|
end
|
||||||
|
self.bar.buttons = buttons
|
||||||
|
|
||||||
self.bar:ClearSetPoint("CENTER")
|
self.bar:ClearSetPoint("CENTER")
|
||||||
self.bar:ApplyConfig()
|
self.bar:ApplyConfig()
|
||||||
self.bar:SetScript("OnEvent", PetBar.OnEvent)
|
self.bar:SetScript("OnEvent", PetBar.OnEvent)
|
||||||
|
self.bar:SetAttribute("unit", "pet")
|
||||||
|
RegisterUnitWatch(self.bar, false)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,19 +47,86 @@ function PetBarMod:OnDisable()
|
|||||||
self.bar:Hide()
|
self.bar:Hide()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function PetBarMod:CreatePetButton(id)
|
||||||
|
local name = "BT4PetButton" .. id
|
||||||
|
local button = setmetatable(CreateFrame("CheckButton", name, self.bar, "Bartender4PetButtonTemplate"), PetButton_MT)
|
||||||
|
button:SetAttribute("type", "pet")
|
||||||
|
button:SetAttribute("action", id)
|
||||||
|
button.id = id
|
||||||
|
button.flash = _G[name .. "Flash"]
|
||||||
|
button.cooldown = _G[name .. "Cooldown"]
|
||||||
|
button.icon = _G[name .. "Icon"]
|
||||||
|
button.autocastable = _G[name .. "AutoCastable"]
|
||||||
|
button.autocast = _G[name .. "AutoCast"]
|
||||||
|
|
||||||
|
return button
|
||||||
|
end
|
||||||
|
|
||||||
function PetBarMod:SetupOptions()
|
function PetBarMod:SetupOptions()
|
||||||
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
self.options = Bartender4.ButtonBar.prototype:GetOptionObject()
|
||||||
|
|
||||||
ActionBars.options.args["pet"] = {
|
ActionBars.options.args["Pet"] = {
|
||||||
order = 30,
|
order = 30,
|
||||||
type = "group",
|
type = "group",
|
||||||
name = "Pet Bar",
|
name = "Pet Bar",
|
||||||
desc = "Configure the Pet Bar",
|
desc = "Configure the Pet Bar",
|
||||||
childGroups = "tab",
|
childGroups = "tab",
|
||||||
}
|
}
|
||||||
ActionBars.options.args["stance"].args = self.options.table
|
ActionBars.options.args["Pet"].args = self.options.table
|
||||||
end
|
end
|
||||||
|
|
||||||
function PetBarMod:ApplyConfig()
|
function PetBarMod:ApplyConfig()
|
||||||
self.bar:ApplyConfig(self.db.profile)
|
self.bar:ApplyConfig(self.db.profile)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function PetButtonPrototype:Update()
|
||||||
|
local name, subtext, texture, isToken, isActive, autoCastAllowed, autoCastEnabled = GetPetActionInfo(self.id)
|
||||||
|
|
||||||
|
if not isToken then
|
||||||
|
self.icon:SetTexture(texture)
|
||||||
|
self.tooltipName = name;
|
||||||
|
else
|
||||||
|
self.icon:SetTexture(_G[texture])
|
||||||
|
self.tooltipName = _G[name]
|
||||||
|
end
|
||||||
|
|
||||||
|
self.isToken = isToken;
|
||||||
|
self.tooltipSubtext = subtext;
|
||||||
|
self:SetChecked(isActive and 1 or 0)
|
||||||
|
if autoCastAllowed then
|
||||||
|
self.autocastable:Show()
|
||||||
|
else
|
||||||
|
self.autocastable:Hide()
|
||||||
|
end
|
||||||
|
if autoCastEnabled then
|
||||||
|
self.autocast:Show()
|
||||||
|
else
|
||||||
|
self.autocast:Hide()
|
||||||
|
end
|
||||||
|
|
||||||
|
if texture then
|
||||||
|
if GetPetActionsUsable() then
|
||||||
|
SetDesaturation(self.icon, nil)
|
||||||
|
else
|
||||||
|
SetDesaturation(self.icon, 1)
|
||||||
|
end
|
||||||
|
self.icon:Show()
|
||||||
|
self:SetNormalTexture("Interface\\Buttons\\UI-Quickslot2")
|
||||||
|
else
|
||||||
|
self.icon:Hide()
|
||||||
|
self:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function PetButtonPrototype:ClearSetPoint(...)
|
||||||
|
self:ClearAllPoints()
|
||||||
|
self:SetPoint(...)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function PetBar:ApplyConfig()
|
||||||
|
ButtonBar.ApplyConfig(self)
|
||||||
|
self:UpdateButtonLayout()
|
||||||
|
self:ForAll("Update")
|
||||||
|
self:ForAll("ApplyStyle", self.config.style)
|
||||||
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user