big restructuring, split the options from the code and moved individual modules into subdirs
- expect big breakage if you try to update without completely restarting wow
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
-- register module
|
||||
local BagBarMod = Bartender4:NewModule("BagBar", "AceHook-3.0")
|
||||
|
||||
-- fetch upvalues
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
|
||||
-- create prototype information
|
||||
local BagBar = setmetatable({}, {__index = ButtonBar})
|
||||
|
||||
local table_insert = table.insert
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
keyring = false,
|
||||
onebag = false,
|
||||
}, Bartender4.ButtonBar.defaults) }
|
||||
|
||||
function BagBarMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("BagBar", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
local noopFunc = function() end
|
||||
|
||||
function BagBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("BagBar", self.db.profile, L["Bag Bar"]), {__index = BagBar})
|
||||
|
||||
-- TODO: real start position
|
||||
self.bar:SetPoint("CENTER")
|
||||
end
|
||||
self.bar:Enable()
|
||||
self:ToggleOptions()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function BagBarMod:OnDisable()
|
||||
if not self.bar then return end
|
||||
self.bar:Disable()
|
||||
self:ToggleOptions()
|
||||
end
|
||||
|
||||
function BagBarMod:ApplyConfig()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function BagBar:ApplyConfig(config)
|
||||
ButtonBar.ApplyConfig(self, config)
|
||||
self:FeedButtons()
|
||||
self:UpdateButtonLayout()
|
||||
end
|
||||
|
||||
function clearSetPoint(btn, ...)
|
||||
btn:ClearAllPoints()
|
||||
btn:SetPoint(...)
|
||||
end
|
||||
|
||||
BagBar.button_width = 37
|
||||
BagBar.button_height = 37
|
||||
BagBarMod.button_count = 5
|
||||
function BagBar:FeedButtons()
|
||||
local count = 1
|
||||
if self.buttons then
|
||||
while next(self.buttons) do
|
||||
local btn = table.remove(self.buttons)
|
||||
btn:Hide()
|
||||
btn:SetParent(UIParent)
|
||||
btn:ClearSetPoint("CENTER")
|
||||
if btn ~= KeyRingButton and btn.LBFButtonData then
|
||||
local group = self.LBFGroup
|
||||
group:RemoveButton(btn)
|
||||
end
|
||||
end
|
||||
else
|
||||
self.buttons = {}
|
||||
end
|
||||
|
||||
if self.config.keyring then
|
||||
table_insert(self.buttons, KeyRingButton)
|
||||
count = count + 1
|
||||
end
|
||||
|
||||
if not self.config.onebag then
|
||||
table_insert(self.buttons, CharacterBag3Slot)
|
||||
table_insert(self.buttons, CharacterBag2Slot)
|
||||
table_insert(self.buttons, CharacterBag1Slot)
|
||||
table_insert(self.buttons, CharacterBag0Slot)
|
||||
count = count + 4
|
||||
end
|
||||
|
||||
table_insert(self.buttons, MainMenuBarBackpackButton)
|
||||
|
||||
for i,v in pairs(self.buttons) do
|
||||
v:SetParent(self)
|
||||
v:Show()
|
||||
if v ~= KeyRingButton then
|
||||
v:SetNormalTexture("")
|
||||
|
||||
if LBF then
|
||||
local group = self.LBFGroup
|
||||
if not v.LBFButtonData then
|
||||
v.LBFButtonData = {
|
||||
Button = v,
|
||||
Icon = _G[v:GetName() .. "IconTexture"],
|
||||
}
|
||||
end
|
||||
group:AddButton(v, v.LBFButtonData)
|
||||
end
|
||||
end
|
||||
|
||||
v.ClearSetPoint = clearSetPoint
|
||||
end
|
||||
|
||||
BagBarMod.button_count = count
|
||||
if BagBarMod.optionobject then
|
||||
BagBarMod.optionobject.table.general.args.rows.max = count
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,65 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
|
||||
local BagBarMod = Bartender4:GetModule("BagBar")
|
||||
|
||||
-- fetch upvalues
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
|
||||
function BagBarMod:SetupOptions()
|
||||
if not self.options then
|
||||
self.optionobject = ButtonBar:GetOptionObject()
|
||||
self.optionobject.table.general.args.rows.max = self.button_count
|
||||
local enabled = {
|
||||
type = "toggle",
|
||||
order = 1,
|
||||
name = L["Enabled"],
|
||||
desc = L["Enable the Bag Bar"],
|
||||
get = function() return self.db.profile.enabled end,
|
||||
set = "ToggleModule",
|
||||
handler = self,
|
||||
}
|
||||
self.optionobject:AddElement("general", "enabled", enabled)
|
||||
|
||||
local onebag = {
|
||||
type = "toggle",
|
||||
order = 80,
|
||||
name = L["One Bag"],
|
||||
desc = L["Only show one Bag Button in the BagBar."],
|
||||
get = function() return self.db.profile.onebag end,
|
||||
set = function(info, state) self.db.profile.onebag = state; self.bar:FeedButtons(); self.bar:UpdateButtonLayout() end,
|
||||
}
|
||||
self.optionobject:AddElement("general", "onebag", onebag)
|
||||
|
||||
local keyring = {
|
||||
type = "toggle",
|
||||
order = 80,
|
||||
name = L["Keyring"],
|
||||
desc = L["Show the keyring button."],
|
||||
get = function() return self.db.profile.keyring end,
|
||||
set = function(info, state) self.db.profile.keyring = state; self.bar:FeedButtons(); self.bar:UpdateButtonLayout() end,
|
||||
}
|
||||
self.optionobject:AddElement("general", "keyring", keyring)
|
||||
|
||||
self.disabledoptions = {
|
||||
general = {
|
||||
type = "group",
|
||||
name = L["General Settings"],
|
||||
cmdInline = true,
|
||||
order = 1,
|
||||
args = {
|
||||
enabled = enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
self.options = {
|
||||
order = 30,
|
||||
type = "group",
|
||||
name = L["Bag Bar"],
|
||||
desc = L["Configure the Bag Bar"],
|
||||
childGroups = "tab",
|
||||
}
|
||||
Bartender4:RegisterBarOptions("BagBar", self.options)
|
||||
end
|
||||
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
|
||||
end
|
||||
@@ -0,0 +1,84 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
-- register module
|
||||
local MicroMenuMod = Bartender4:NewModule("MicroMenu", "AceHook-3.0")
|
||||
|
||||
-- fetch upvalues
|
||||
local ActionBars = Bartender4:GetModule("ActionBars")
|
||||
local Bar = Bartender4.Bar.prototype
|
||||
|
||||
-- create prototype information
|
||||
local MicroMenuBar = setmetatable({}, {__index = Bar})
|
||||
|
||||
local table_insert = table.insert
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
vertical = false,
|
||||
}, Bartender4.Bar.defaults) }
|
||||
|
||||
function MicroMenuMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("MicroMenu", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
local noopFunc = function() end
|
||||
|
||||
function MicroMenuMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.Bar:Create("MicroMenu", self.db.profile, L["Micro Menu"]), {__index = MicroMenuBar})
|
||||
local buttons = {}
|
||||
table_insert(buttons, CharacterMicroButton)
|
||||
table_insert(buttons, SpellbookMicroButton)
|
||||
table_insert(buttons, TalentMicroButton)
|
||||
table_insert(buttons, QuestLogMicroButton)
|
||||
table_insert(buttons, SocialsMicroButton)
|
||||
table_insert(buttons, LFGMicroButton)
|
||||
table_insert(buttons, MainMenuMicroButton)
|
||||
table_insert(buttons, HelpMicroButton)
|
||||
self.bar.buttons = buttons
|
||||
|
||||
self:RawHook("UpdateTalentButton", noopFunc, true)
|
||||
|
||||
for i,v in pairs(buttons) do
|
||||
v:SetParent(self.bar)
|
||||
v:Show()
|
||||
v:SetFrameLevel(self.bar:GetFrameLevel() + 1)
|
||||
end
|
||||
|
||||
-- TODO: real start position
|
||||
self.bar:SetPoint("CENTER")
|
||||
end
|
||||
self.bar:Enable()
|
||||
self:ToggleOptions()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function MicroMenuMod:OnDisable()
|
||||
if not self.bar then return end
|
||||
self.bar:Disable()
|
||||
self:ToggleOptions()
|
||||
end
|
||||
|
||||
function MicroMenuMod:ApplyConfig()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function MicroMenuBar:ApplyConfig(config)
|
||||
Bar.ApplyConfig(self, config)
|
||||
self:PerformLayout()
|
||||
end
|
||||
|
||||
function MicroMenuBar:PerformLayout()
|
||||
if self.config.vertical then
|
||||
-- TODO: vertical
|
||||
else
|
||||
self:SetSize(212, 45)
|
||||
self.buttons[1]:ClearAllPoints()
|
||||
self.buttons[1]:SetPoint("TOPLEFT", self, "TOPLEFT", 5, 18)
|
||||
for i = 2, #self.buttons do
|
||||
self.buttons[i]:ClearAllPoints()
|
||||
self.buttons[i]:SetPoint("TOPLEFT", self.buttons[i-1], "TOPRIGHT", -4, 0)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,44 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
|
||||
local MicroMenuMod = Bartender4:GetModule("MicroMenu")
|
||||
|
||||
-- fetch upvalues
|
||||
local Bar = Bartender4.Bar.prototype
|
||||
|
||||
function MicroMenuMod:SetupOptions()
|
||||
if not self.options then
|
||||
self.optionobject = Bar:GetOptionObject()
|
||||
local enabled = {
|
||||
type = "toggle",
|
||||
order = 1,
|
||||
name = L["Enabled"],
|
||||
desc = L["Enable the Micro Menu"],
|
||||
get = function() return self.db.profile.enabled end,
|
||||
set = "ToggleModule",
|
||||
handler = self,
|
||||
}
|
||||
self.optionobject:AddElement("general", "enabled", enabled)
|
||||
|
||||
self.disabledoptions = {
|
||||
general = {
|
||||
type = "group",
|
||||
name = L["General Settings"],
|
||||
cmdInline = true,
|
||||
order = 1,
|
||||
args = {
|
||||
enabled = enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
self.options = {
|
||||
order = 30,
|
||||
type = "group",
|
||||
name = L["Micro Menu"],
|
||||
desc = L["Configure the Micro Menu"],
|
||||
childGroups = "tab",
|
||||
}
|
||||
Bartender4:RegisterBarOptions("MicroMenu", self.options)
|
||||
end
|
||||
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
|
||||
end
|
||||
@@ -0,0 +1,123 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
-- register module
|
||||
local PetBarMod = Bartender4:NewModule("PetBar", "AceEvent-3.0")
|
||||
|
||||
-- fetch upvalues
|
||||
local ActionBars = Bartender4:GetModule("ActionBars")
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
|
||||
-- create prototype information
|
||||
local PetBar = setmetatable({}, {__index = ButtonBar})
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
scale = 1.0,
|
||||
}, Bartender4.ButtonBar.defaults) }
|
||||
|
||||
function PetBarMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("PetBar", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
function PetBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("PetBar", self.db.profile, L["Pet Bar"]), {__index = PetBar})
|
||||
|
||||
local buttons = {}
|
||||
for i=1,10 do
|
||||
buttons[i] = Bartender4.PetButton:Create(i, self.bar)
|
||||
end
|
||||
self.bar.buttons = buttons
|
||||
|
||||
-- TODO: real positioning
|
||||
self.bar:ClearSetPoint("CENTER")
|
||||
|
||||
self.bar:SetScript("OnEvent", PetBar.OnEvent)
|
||||
|
||||
self.bar:SetAttribute("unit", "pet")
|
||||
end
|
||||
self.bar:Enable()
|
||||
|
||||
RegisterUnitWatch(self.bar, false)
|
||||
|
||||
self.bar:RegisterEvent("PLAYER_CONTROL_LOST")
|
||||
self.bar:RegisterEvent("PLAYER_CONTROL_GAINED")
|
||||
self.bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
|
||||
self.bar:RegisterEvent("UNIT_PET")
|
||||
self.bar:RegisterEvent("UNIT_FLAGS")
|
||||
self.bar:RegisterEvent("UNIT_AURA")
|
||||
self.bar:RegisterEvent("PET_BAR_UPDATE")
|
||||
self.bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
|
||||
self.bar:RegisterEvent("PET_BAR_SHOWGRID")
|
||||
self.bar:RegisterEvent("PET_BAR_HIDEGRID")
|
||||
|
||||
self:ApplyConfig()
|
||||
self:ToggleOptions()
|
||||
|
||||
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
|
||||
self:ReassignBindings()
|
||||
end
|
||||
|
||||
function PetBarMod:OnDisable()
|
||||
if not self.bar then return end
|
||||
|
||||
UnregisterUnitWatch(self.bar)
|
||||
|
||||
self.bar:Disable()
|
||||
self:ToggleOptions()
|
||||
end
|
||||
|
||||
function PetBarMod:ReassignBindings()
|
||||
if InCombatLockdown() then return end
|
||||
if not self.bar or not self.bar.buttons then return end
|
||||
ClearOverrideBindings(self.bar)
|
||||
for i = 1, 10 do
|
||||
local button, real_button = ("BONUSACTIONBUTTON%d"):format(i), ("BT4PetButton%d"):format(i)
|
||||
for k=1, select('#', GetBindingKey(button)) do
|
||||
local key = select(k, GetBindingKey(button))
|
||||
SetOverrideBindingClick(self.bar, false, key, real_button)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function PetBarMod:ApplyConfig()
|
||||
if not self:IsEnabled() then return end
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
self:ReassignBindings()
|
||||
end
|
||||
|
||||
PetBar.button_width = 30
|
||||
PetBar.button_height = 30
|
||||
function PetBar:OnEvent(event, arg1)
|
||||
if event == "PET_BAR_UPDATE" or
|
||||
(event == "UNIT_PET" and arg1 == "player") or
|
||||
((event == "UNIT_FLAGS" or event == "UNIT_AURA") and arg1 == "pet") or
|
||||
event == "PLAYER_CONTROL_LOST" or event == "PLAYER_CONTROL_GAINED" or event == "PLAYER_FARSIGHT_FOCUS_CHANGED"
|
||||
then
|
||||
self:ForAll("Update")
|
||||
elseif event == "PET_BAR_UPDATE_COOLDOWN" then
|
||||
self:ForAll("UpdateCooldown")
|
||||
elseif event == "PET_BAR_SHOWGRID" then
|
||||
self:ForAll("ShowGrid")
|
||||
elseif event == "PET_BAR_HIDEGRID" then
|
||||
self:ForAll("HideGrid")
|
||||
end
|
||||
end
|
||||
|
||||
function PetBar:ApplyConfig(config)
|
||||
ButtonBar.ApplyConfig(self, config)
|
||||
self:UpdateButtonLayout()
|
||||
self:ForAll("Update")
|
||||
self:ForAll("ApplyStyle", self.config.style)
|
||||
end
|
||||
|
||||
function PetBar:Unlock()
|
||||
UnregisterUnitWatch(self)
|
||||
ButtonBar.Unlock(self)
|
||||
end
|
||||
|
||||
function PetBar:Lock()
|
||||
ButtonBar.Lock(self)
|
||||
RegisterUnitWatch(self, false)
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
|
||||
local PetBarMod = Bartender4:GetModule("PetBar")
|
||||
|
||||
-- fetch upvalues
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
|
||||
function PetBarMod:SetupOptions()
|
||||
if not self.options then
|
||||
self.optionobject = ButtonBar:GetOptionObject()
|
||||
|
||||
self.optionobject.table.general.args.rows.max = 10
|
||||
|
||||
local enabled = {
|
||||
type = "toggle",
|
||||
order = 1,
|
||||
name = L["Enabled"],
|
||||
desc = L["Enable the PetBar"],
|
||||
get = function() return self.db.profile.enabled end,
|
||||
set = "ToggleModule",
|
||||
handler = self,
|
||||
}
|
||||
self.optionobject:AddElement("general", "enabled", enabled)
|
||||
|
||||
self.disabledoptions = {
|
||||
general = {
|
||||
type = "group",
|
||||
name = L["General Settings"],
|
||||
cmdInline = true,
|
||||
order = 1,
|
||||
args = {
|
||||
enabled = enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.options = {
|
||||
order = 30,
|
||||
type = "group",
|
||||
name = L["Pet Bar"],
|
||||
desc = L["Configure the Pet Bar"],
|
||||
childGroups = "tab",
|
||||
}
|
||||
Bartender4:RegisterBarOptions("PetBar", self.options)
|
||||
end
|
||||
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
|
||||
..\FrameXML\UI.xsd">
|
||||
<Script file="BagBar.lua"/>
|
||||
<Script file="BagBarOptions.lua"/>
|
||||
<Script file="MicroMenu.lua"/>
|
||||
<Script file="MicroMenuOptions.lua"/>
|
||||
<Script file="PetBar.lua"/>
|
||||
<Script file="PetBarOptions.lua"/>
|
||||
<Script file="StanceBar.lua"/>
|
||||
<Script file="StanceBarOptions.lua"/>
|
||||
</Ui>
|
||||
@@ -0,0 +1,233 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
-- register module
|
||||
local StanceBarMod = Bartender4:NewModule("StanceBar", "AceEvent-3.0")
|
||||
|
||||
-- fetch upvalues
|
||||
local ActionBars = Bartender4:GetModule("ActionBars")
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
|
||||
-- create prototype information
|
||||
local StanceBar = setmetatable({}, {__index = ButtonBar})
|
||||
local StanceButtonPrototype = CreateFrame("CheckButton")
|
||||
local StanceButton_MT = {__index = StanceButtonPrototype}
|
||||
|
||||
local format = string.format
|
||||
|
||||
local LBF = LibStub("LibButtonFacade", true)
|
||||
local KeyBound = LibStub("LibKeyBound-1.0")
|
||||
|
||||
local defaults = { profile = Bartender4:Merge({
|
||||
enabled = true,
|
||||
scale = 1.5,
|
||||
}, Bartender4.ButtonBar.defaults) }
|
||||
|
||||
function StanceBarMod:OnInitialize()
|
||||
self.db = Bartender4.db:RegisterNamespace("StanceBar", defaults)
|
||||
self:SetEnabledState(self.db.profile.enabled)
|
||||
end
|
||||
|
||||
function StanceBarMod:OnEnable()
|
||||
if not self.bar then
|
||||
self.bar = setmetatable(Bartender4.ButtonBar:Create("StanceBar", self.db.profile, L["Stance Bar"]), {__index = StanceBar})
|
||||
|
||||
self.bar:ClearSetPoint("CENTER")
|
||||
self.bar:SetScript("OnEvent", StanceBar.OnEvent)
|
||||
end
|
||||
self.bar:Enable()
|
||||
|
||||
self:ToggleOptions()
|
||||
self.bar:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
self.bar:RegisterEvent("UPDATE_SHAPESHIFT_FORMS")
|
||||
self.bar:RegisterEvent("SPELL_UPDATE_COOLDOWN")
|
||||
self.bar:RegisterEvent("SPELL_UPDATE_USABLE")
|
||||
self.bar:RegisterEvent("PLAYER_AURAS_CHANGED")
|
||||
self.bar:RegisterEvent("PLAYER_REGEN_ENABLED")
|
||||
self.bar:RegisterEvent("ACTIONBAR_PAGE_CHANGED")
|
||||
self:RegisterEvent("UPDATE_BINDINGS", "ReassignBindings")
|
||||
self:ReassignBindings()
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
end
|
||||
|
||||
function StanceBarMod:OnDisable()
|
||||
if not self.bar then return end
|
||||
self.bar:Disable()
|
||||
self:ToggleOptions()
|
||||
end
|
||||
|
||||
StanceBarMod.button_count = 10
|
||||
|
||||
function StanceBarMod:ApplyConfig()
|
||||
if not self:IsEnabled() then return end
|
||||
self.bar:ApplyConfig(self.db.profile)
|
||||
|
||||
if GetNumShapeshiftForms() == 0 then
|
||||
self:Disable()
|
||||
end
|
||||
end
|
||||
|
||||
function StanceBarMod:ReassignBindings()
|
||||
if InCombatLockdown() then return end
|
||||
if not self.bar or not self.bar.buttons then return end
|
||||
ClearOverrideBindings(self.bar)
|
||||
for i = 1, min(#self.bar.buttons, 10) do
|
||||
local button, real_button = ("SHAPESHIFTBUTTON%d"):format(i), ("BT4StanceButton%d"):format(i)
|
||||
for k=1, select('#', GetBindingKey(button)) do
|
||||
local key = select(k, GetBindingKey(button))
|
||||
SetOverrideBindingClick(self.bar, false, key, real_button)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function StanceButtonPrototype:Update()
|
||||
if not self:IsShown() then return end
|
||||
local id = self:GetID()
|
||||
local texture, name, isActive, isCastable = GetShapeshiftFormInfo(id)
|
||||
|
||||
self.icon:SetTexture(texture)
|
||||
|
||||
-- manage cooldowns
|
||||
if texture then
|
||||
self.cooldown:Show()
|
||||
else
|
||||
self.cooldown:Hide()
|
||||
end
|
||||
local start, duration, enable = GetShapeshiftFormCooldown(id)
|
||||
CooldownFrame_SetTimer(self.cooldown, start, duration, enable)
|
||||
|
||||
if isActive then
|
||||
self:SetChecked(1)
|
||||
else
|
||||
self:SetChecked(0)
|
||||
end
|
||||
|
||||
if isCastable then
|
||||
self.icon:SetVertexColor(1.0, 1.0, 1.0)
|
||||
else
|
||||
self.icon:SetVertexColor(0.4, 0.4, 0.4)
|
||||
end
|
||||
end
|
||||
|
||||
function StanceButtonPrototype:GetHotkey()
|
||||
local key = GetBindingKey(format("SHAPESHIFTBUTTON%d", self:GetID())) or GetBindingKey("CLICK "..self:GetName()..":LeftButton")
|
||||
return key and KeyBound:ToShortKey(key)
|
||||
end
|
||||
|
||||
function StanceButtonPrototype:GetBindings()
|
||||
local keys, binding = ""
|
||||
|
||||
binding = format("SHAPESHIFTBUTTON%d", self:GetID())
|
||||
for i = 1, select('#', GetBindingKey(binding)) do
|
||||
local hotKey = select(i, GetBindingKey(binding))
|
||||
if keys ~= "" then
|
||||
keys = keys .. ', '
|
||||
end
|
||||
keys = keys .. GetBindingText(hotKey,'KEY_')
|
||||
end
|
||||
|
||||
binding = "CLICK "..self:GetName()..":LeftButton"
|
||||
for i = 1, select('#', GetBindingKey(binding)) do
|
||||
local hotKey = select(i, GetBindingKey(binding))
|
||||
if keys ~= "" then
|
||||
keys = keys .. ', '
|
||||
end
|
||||
keys = keys.. GetBindingText(hotKey,'KEY_')
|
||||
end
|
||||
|
||||
return keys
|
||||
end
|
||||
|
||||
function StanceButtonPrototype:SetKey(key)
|
||||
SetBinding(key, format("SHAPESHIFTBUTTON%d", self:GetID()))
|
||||
end
|
||||
|
||||
local actionTmpl = "Stance Button %d (%s)"
|
||||
function StanceButtonPrototype:GetActionName()
|
||||
local id = self:GetID()
|
||||
return format(actionTmpl, id, select(2, GetShapeshiftFormInfo(id)))
|
||||
end
|
||||
|
||||
|
||||
function StanceButtonPrototype:ClearSetPoint(...)
|
||||
self:ClearAllPoints()
|
||||
self:SetPoint(...)
|
||||
end
|
||||
|
||||
local function onEnter(self, ...)
|
||||
self:OnEnter(...)
|
||||
KeyBound:Set(self)
|
||||
end
|
||||
|
||||
function StanceBarMod:CreateStanceButton(id)
|
||||
local button = setmetatable(CreateFrame("CheckButton", "BT4StanceButton" .. id, self.bar, "ShapeshiftButtonTemplate"), StanceButton_MT)
|
||||
button:SetID(id)
|
||||
button.icon = _G[button:GetName() .. "Icon"]
|
||||
button.cooldown = _G[button:GetName() .. "Cooldown"]
|
||||
button.normalTexture = button:GetNormalTexture()
|
||||
button.normalTexture:SetTexture("")
|
||||
-- button.checkedTexture = button:GetCheckedTexture()
|
||||
-- button.checkedTexture:SetTexture("")
|
||||
|
||||
button.OnEnter = button:GetScript("OnEnter")
|
||||
button:SetScript("OnEnter", onEnter)
|
||||
|
||||
if LBF then
|
||||
local group = self.bar.LBFGroup
|
||||
button.LBFButtonData = {
|
||||
Button = button
|
||||
}
|
||||
group:AddButton(button, button.LBFButtonData)
|
||||
end
|
||||
|
||||
return button
|
||||
end
|
||||
|
||||
function StanceBar:ApplyConfig(config)
|
||||
ButtonBar.ApplyConfig(self, config)
|
||||
self:UpdateStanceButtons()
|
||||
self:ForAll("ApplyStyle", self.config.style)
|
||||
end
|
||||
|
||||
StanceBar.button_width = 30
|
||||
StanceBar.button_height = 30
|
||||
function StanceBar:UpdateStanceButtons()
|
||||
local buttons = self.buttons or {}
|
||||
|
||||
local num_stances = GetNumShapeshiftForms()
|
||||
|
||||
local updateBindings = (num_stances > #buttons)
|
||||
|
||||
for i = (#buttons+1), num_stances do
|
||||
buttons[i] = StanceBarMod:CreateStanceButton(i)
|
||||
end
|
||||
|
||||
for i = 1, num_stances do
|
||||
buttons[i]:Show()
|
||||
buttons[i]:Update()
|
||||
end
|
||||
|
||||
for i = num_stances+1, #buttons do
|
||||
buttons[i]:Hide()
|
||||
end
|
||||
|
||||
StanceBarMod.button_count = num_stances
|
||||
if StanceBarMod.optionobject then
|
||||
StanceBarMod.optionobject.table.general.args.rows.max = num_stances
|
||||
end
|
||||
|
||||
self.buttons = buttons
|
||||
|
||||
self:UpdateButtonLayout()
|
||||
if updateBindings then
|
||||
StanceBarMod:ReassignBindings()
|
||||
end
|
||||
self.disabled = (GetNumShapeshiftForms() == 0) and true or nil
|
||||
end
|
||||
|
||||
function StanceBar:OnEvent(event, ...)
|
||||
if event == "PLAYER_ENTERING_WORLD" or event == "UPDATE_SHAPESHIFT_FORMS" and not InCombatLockdown() then
|
||||
self:UpdateStanceButtons()
|
||||
else
|
||||
self:ForAll("Update")
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,48 @@
|
||||
--[[ $Id$ ]]
|
||||
local L = LibStub("AceLocale-3.0"):GetLocale("Bartender4")
|
||||
|
||||
-- module
|
||||
local StanceBarMod = Bartender4:GetModule("StanceBar")
|
||||
|
||||
-- fetch upvalues
|
||||
local ButtonBar = Bartender4.ButtonBar.prototype
|
||||
|
||||
function StanceBarMod:SetupOptions()
|
||||
if not self.options then
|
||||
self.optionobject = ButtonBar:GetOptionObject()
|
||||
self.optionobject.table.general.args.rows.max = self.button_count
|
||||
local enabled = {
|
||||
type = "toggle",
|
||||
order = 1,
|
||||
name = L["Enabled"],
|
||||
desc = L["Enable the StanceBar"],
|
||||
get = function() return self.db.profile.enabled end,
|
||||
set = "ToggleModule",
|
||||
handler = self,
|
||||
}
|
||||
self.optionobject:AddElement("general", "enabled", enabled)
|
||||
|
||||
self.disabledoptions = {
|
||||
general = {
|
||||
type = "group",
|
||||
name = L["General Settings"],
|
||||
cmdInline = true,
|
||||
order = 1,
|
||||
args = {
|
||||
enabled = enabled,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.options = {
|
||||
order = 30,
|
||||
type = "group",
|
||||
name = L["Stance Bar"],
|
||||
desc = L["Configure the Stance Bar"],
|
||||
childGroups = "tab",
|
||||
disabled = function(info) return GetNumShapeshiftForms() == 0 end,
|
||||
}
|
||||
Bartender4:RegisterBarOptions("StanceBar", self.options)
|
||||
end
|
||||
self.options.args = self:IsEnabled() and self.optionobject.table or self.disabledoptions
|
||||
end
|
||||
Reference in New Issue
Block a user