pet buttons actually work now, using blizzard templates

This commit is contained in:
Hendrik Leppkes
2008-03-03 11:45:24 +00:00
parent 1ccc647634
commit 3ae640802d
4 changed files with 41 additions and 154 deletions
-1
View File
@@ -20,7 +20,6 @@ ButtonStyle.lua
Bar.lua
ButtonBar.lua
Button.lua
PetButton.xml
## Modules ##
ActionBars.lua
+1 -103
View File
@@ -14,108 +14,6 @@ do
end
end
local getProfilesOptionsTable
do
local defaultProfiles
--[[ Utility functions ]]
-- get exisiting profiles + some default entries
local tmpprofiles = {}
local function getProfileList(db, common, nocurrent)
-- clear old profile table
local profiles = {}
-- copy existing profiles into the table
local curr = db:GetCurrentProfile()
for i,v in pairs(db:GetProfiles(tmpprofiles)) do if not (nocurrent and v == curr) then profiles[v] = v end end
-- add our default profiles to choose from
for k,v in pairs(defaultProfiles) do
if (common or profiles[k]) and not (k == curr and nocurrent) then
profiles[k] = v
end
end
return profiles
end
function getProfilesOptionsTable(db)
defaultProfiles = {
["Default"] = "Default",
[db.keys.char] = "Char: " .. db.keys.char,
[db.keys.realm] = "Realm: " .. db.keys.realm,
[db.keys.class] = "Class: " .. UnitClass("player")
}
local tbl = {
profiles = {
type = "group",
name = "Profiles",
desc = "Manage Profiles",
args = {
reset = {
order = 1,
type = "execute",
name = "Reset Profile",
desc = "Reset the current profile to the default",
func = function() db:ResetProfile() end,
},
spacer1 = {
order = 2,
type = "header",
name = "Choose a Profile",
desc = "Set the active profile of this character.",
},
new = {
name = "New",
type = "input",
order = 3,
get = function() return false end,
set = function(info, value) db:SetProfile(value) end,
},
choose = {
name = "Current",
type = "select",
order = 4,
get = function() return db:GetCurrentProfile() end,
set = function(info, value) db:SetProfile(value) end,
values = function() return getProfileList(db, true) end,
},
spacer2 = {
type = "header",
order = 5,
name = "Copy a Profile",
},
copyfrom = {
order = 6,
type = "select",
name = "Copy From",
desc = "Copy the settings from another profile",
get = function() return false end,
set = function(info, value) db:CopyProfile(value) end,
values = function() return getProfileList(db, nil, true) end,
},
spacer3 = {
type = "header",
order = 7,
name = "Delete a Profile",
},
delete = {
order = 8,
type = "select",
name = "Delete a Profile",
desc = "Deletes a profile from the database.",
get = function() return false end,
set = function(info, value) db:DeleteProfile(value) end,
values = function() return getProfileList(db, nil, true) end,
confirm = true,
confirmText = "Are you sure you want to delete the selected profile?",
},
},
},
}
return tbl
end
end
function Bartender4:SetupOptions()
self.options = {
type = "group",
@@ -143,7 +41,7 @@ function Bartender4:SetupOptions()
},
}
self.options.plugins.profiles = getProfilesOptionsTable(Bartender4.db)
self.options.plugins.profiles = { profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(self.db) }
LibStub("AceConfig-3.0"):RegisterOptionsTable("Bartender4", self.options, "bttest")
+40 -4
View File
@@ -33,11 +33,25 @@ function PetBarMod:OnEnable()
end
self.bar.buttons = buttons
-- TODO: real positioning
self.bar:ClearSetPoint("CENTER")
self.bar:ApplyConfig()
self.bar:SetScript("OnEvent", PetBar.OnEvent)
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.bar:SetAttribute("unit", "pet")
RegisterUnitWatch(self.bar, false)
self.bar:ApplyConfig()
end
end
@@ -49,9 +63,10 @@ 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)
local button = setmetatable(CreateFrame("CheckButton", name, self.bar, "PetActionButtonTemplate"), PetButton_MT)
button:SetID(id)
button:UnregisterAllEvents()
button:SetScript("OnEvent", nil)
button.id = id
button.flash = _G[name .. "Flash"]
button.cooldown = _G[name .. "Cooldown"]
@@ -116,6 +131,12 @@ function PetButtonPrototype:Update()
self.icon:Hide()
self:SetNormalTexture("Interface\\Buttons\\UI-Quickslot")
end
self:UpdateCooldown()
end
function PetButtonPrototype:UpdateCooldown()
local start, duration, enable = GetPetActionCooldown(self.id)
CooldownFrame_SetTimer(self.cooldown, start, duration, enable)
end
function PetButtonPrototype:ClearSetPoint(...)
@@ -123,6 +144,21 @@ function PetButtonPrototype:ClearSetPoint(...)
self:SetPoint(...)
end
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()
ButtonBar.ApplyConfig(self)
-46
View File
@@ -1,46 +0,0 @@
<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">
<CheckButton name="Bartender4PetButtonTemplate" inherits="SecureActionButtonTemplate, ActionButtonTemplate" frameStrata="HIGH" virtual="true">
<Size>
<AbsDimension x="30" y="30"/>
</Size>
<Layers>
<Layer level="OVERLAY">
<Texture name="$parentAutoCastable" file="Interface\Buttons\UI-AutoCastableOverlay" hidden="true">
<Size>
<AbsDimension x="58" y="58"/>
</Size>
<Anchors>
<Anchor point="CENTER">
<Offset>
<AbsDimension x="0" y="0"/>
</Offset>
</Anchor>
</Anchors>
</Texture>
</Layer>
</Layers>
<Frames>
<Model name="$parentAutoCast" file="Interface\Buttons\UI-AutoCastButton.mdx" scale="1.2" hidden="true" setAllPoints="true">
<Scripts>
<OnLoad>
this:SetSequence(0);
this:SetSequenceTime(0, 0);
</OnLoad>
</Scripts>
</Model>
</Frames>
<NormalTexture name="$parentNormalTexture2" file="Interface\Buttons\UI-Quickslot2">
<Size>
<AbsDimension x="54" y="54"/>
</Size>
<Anchors>
<Anchor point="CENTER">
<Offset>
<AbsDimension x="0" y="-1"/>
</Offset>
</Anchor>
</Anchors>
</NormalTexture>
</CheckButton>
</Ui>