mirror of
https://github.com/parnic/breakables.git
synced 2025-06-17 01:41:51 -05:00
- added ButtonFacade support (ticket #7)
This commit is contained in:
1
.pkgmeta
1
.pkgmeta
@ -34,3 +34,4 @@ externals:
|
|||||||
libs/LibBabble-Inventory-3.0:
|
libs/LibBabble-Inventory-3.0:
|
||||||
url: svn://svn.wowace.com/wow/libbabble-inventory-3-0/mainline/trunk
|
url: svn://svn.wowace.com/wow/libbabble-inventory-3-0/mainline/trunk
|
||||||
tag: latest
|
tag: latest
|
||||||
|
libs/LibButtonFacade: svn://svn.wowace.com/wow/buttonfacade/mainline/trunk/Libs/LibButtonFacade
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
local L = LibStub("AceLocale-3.0"):GetLocale("Breakables", false)
|
local L = LibStub("AceLocale-3.0"):GetLocale("Breakables", false)
|
||||||
Breakables = LibStub("AceAddon-3.0"):NewAddon("Breakables", "AceConsole-3.0", "AceEvent-3.0")
|
Breakables = LibStub("AceAddon-3.0"):NewAddon("Breakables", "AceConsole-3.0", "AceEvent-3.0")
|
||||||
local babbleInv = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
|
local babbleInv = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
|
||||||
|
local LBF = LibStub("LibButtonFacade", true)
|
||||||
|
|
||||||
|
local lbfGroup
|
||||||
|
|
||||||
local MillingId = 51005
|
local MillingId = 51005
|
||||||
local MillingItemSubType = babbleInv["Herb"]
|
local MillingItemSubType = babbleInv["Herb"]
|
||||||
@ -88,6 +91,27 @@ function Breakables:OnInitialize()
|
|||||||
end
|
end
|
||||||
|
|
||||||
self:InitLDB()
|
self:InitLDB()
|
||||||
|
|
||||||
|
if LBF then
|
||||||
|
LBF:RegisterSkinCallback("Breakables", self.ButtonFacadeCallback, self)
|
||||||
|
|
||||||
|
lbfGroup = LBF:Group("Breakables")
|
||||||
|
if lbfGroup then
|
||||||
|
lbfGroup:Skin(self.settings.SkinID,
|
||||||
|
self.settings.Gloss,
|
||||||
|
self.settings.Backdrop,
|
||||||
|
self.settings.Colors)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Breakables:ButtonFacadeCallback(SkinID, Gloss, Backdrop, Group, Button, Colors)
|
||||||
|
if not Group then
|
||||||
|
self.settings.SkinID = SkinID
|
||||||
|
self.settings.Gloss = Gloss
|
||||||
|
self.settings.Backdrop = Backdrop
|
||||||
|
self.settings.Colors = Colors
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function Breakables:InitLDB()
|
function Breakables:InitLDB()
|
||||||
@ -424,7 +448,7 @@ function Breakables:CreateButtonFrame()
|
|||||||
|
|
||||||
for i=1,numEligibleProfessions do
|
for i=1,numEligibleProfessions do
|
||||||
if not self.buttonFrame[i] then
|
if not self.buttonFrame[i] then
|
||||||
self.buttonFrame[i] = CreateFrame("Button", "BreakablesButtonFrame1", self.frame, "SecureActionButtonTemplate")
|
self.buttonFrame[i] = CreateFrame("Button", "BREAKABLES_BUTTON_FRAME"..i, self.frame, "SecureActionButtonTemplate")
|
||||||
end
|
end
|
||||||
self.buttonFrame[i]:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.settings.buttonFrameLeft[i], self.settings.buttonFrameTop[i])
|
self.buttonFrame[i]:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.settings.buttonFrameLeft[i], self.settings.buttonFrameTop[i])
|
||||||
|
|
||||||
@ -436,9 +460,6 @@ function Breakables:CreateButtonFrame()
|
|||||||
self.buttonFrame[i].type = BREAKABLE_ORE
|
self.buttonFrame[i].type = BREAKABLE_ORE
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self.buttonFrame[i].icon then
|
|
||||||
self.buttonFrame[i].icon = self.buttonFrame[i]:CreateTexture(nil, "BACKGROUND")
|
|
||||||
end
|
|
||||||
if self.buttonFrame[i].type then
|
if self.buttonFrame[i].type then
|
||||||
self.buttonFrame[i]:SetWidth(buttonSize * self.settings.buttonScale)
|
self.buttonFrame[i]:SetWidth(buttonSize * self.settings.buttonScale)
|
||||||
self.buttonFrame[i]:SetHeight(buttonSize * self.settings.buttonScale)
|
self.buttonFrame[i]:SetHeight(buttonSize * self.settings.buttonScale)
|
||||||
@ -457,10 +478,14 @@ function Breakables:CreateButtonFrame()
|
|||||||
self.buttonFrame[i]:SetAttribute("type1", "spell")
|
self.buttonFrame[i]:SetAttribute("type1", "spell")
|
||||||
self.buttonFrame[i]:SetAttribute("spell1", spellName)
|
self.buttonFrame[i]:SetAttribute("spell1", spellName)
|
||||||
|
|
||||||
self.buttonFrame[i].icon:SetTexture(texture)
|
if not lbfGroup then
|
||||||
self.buttonFrame[i].icon:SetAllPoints(self.buttonFrame[i])
|
self.buttonFrame[i]:SetNormalTexture(texture)
|
||||||
else
|
else
|
||||||
self.buttonFrame[i]:SetTexture(nil)
|
self.buttonFrame[i].icon = self.buttonFrame[i]:CreateTexture(self.buttonFrame[i]:GetName().."Icon", "BACKGROUND")
|
||||||
|
self.buttonFrame[i].icon:SetTexture(texture)
|
||||||
|
|
||||||
|
lbfGroup:AddButton(self.buttonFrame[i])
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -556,12 +581,17 @@ function Breakables:FindBreakables(bag)
|
|||||||
local isDisenchantable = self:BreakableIsDisenchantable(foundBreakables[i][IDX_TYPE], foundBreakables[i][IDX_LEVEL])
|
local isDisenchantable = self:BreakableIsDisenchantable(foundBreakables[i][IDX_TYPE], foundBreakables[i][IDX_LEVEL])
|
||||||
if (CanDisenchant and isDisenchantable) or foundBreakables[i][IDX_COUNT] >= 5 then
|
if (CanDisenchant and isDisenchantable) or foundBreakables[i][IDX_COUNT] >= 5 then
|
||||||
numBreakableStacks[j] = numBreakableStacks[j] + 1
|
numBreakableStacks[j] = numBreakableStacks[j] + 1
|
||||||
|
local btnIdx = numBreakableStacks[j]
|
||||||
|
|
||||||
local btn = self.breakableButtons[j][numBreakableStacks[j]]
|
local btn = self.breakableButtons[j][btnIdx]
|
||||||
if not self.breakableButtons[j][numBreakableStacks[j]] then
|
if not self.breakableButtons[j][btnIdx] then
|
||||||
self.breakableButtons[j][numBreakableStacks[j]] = CreateFrame("Button", nil, self.buttonFrame[j], "SecureActionButtonTemplate")
|
self.breakableButtons[j][btnIdx] = CreateFrame("Button", "BREAKABLES_BUTTON"..j.."-"..btnIdx, self.buttonFrame[j], "SecureActionButtonTemplate")
|
||||||
|
|
||||||
btn = self.breakableButtons[j][numBreakableStacks[j]]
|
btn = self.breakableButtons[j][btnIdx]
|
||||||
|
|
||||||
|
if lbfGroup then
|
||||||
|
btn.icon = btn:CreateTexture(btn:GetName().."Icon", "BACKGROUND")
|
||||||
|
end
|
||||||
|
|
||||||
btn:SetWidth(buttonSize * self.settings.buttonScale)
|
btn:SetWidth(buttonSize * self.settings.buttonScale)
|
||||||
btn:SetHeight(buttonSize * self.settings.buttonScale)
|
btn:SetHeight(buttonSize * self.settings.buttonScale)
|
||||||
@ -576,10 +606,9 @@ function Breakables:FindBreakables(bag)
|
|||||||
end
|
end
|
||||||
btn.text:SetFont(NumberFont_Outline_Med:GetFont(), self.settings.fontSize, "OUTLINE")
|
btn.text:SetFont(NumberFont_Outline_Med:GetFont(), self.settings.fontSize, "OUTLINE")
|
||||||
|
|
||||||
if not btn.icon then
|
if lbfGroup then
|
||||||
btn.icon = btn:CreateTexture(nil, "BACKGROUND")
|
lbfGroup:AddButton(btn)
|
||||||
end
|
end
|
||||||
btn.icon:SetAllPoints(btn)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
local attachFrom = "LEFT"
|
local attachFrom = "LEFT"
|
||||||
@ -599,7 +628,7 @@ function Breakables:FindBreakables(bag)
|
|||||||
end
|
end
|
||||||
|
|
||||||
btn:ClearAllPoints()
|
btn:ClearAllPoints()
|
||||||
btn:SetPoint(attachFrom, numBreakableStacks[j] == 1 and self.buttonFrame[j] or self.breakableButtons[j][numBreakableStacks[j] - 1], attachTo)
|
btn:SetPoint(attachFrom, btnIdx == 1 and self.buttonFrame[j] or self.breakableButtons[j][btnIdx - 1], attachTo)
|
||||||
|
|
||||||
if not isDisenchantable then
|
if not isDisenchantable then
|
||||||
btn.text:SetText(foundBreakables[i][IDX_COUNT].." ("..(floor(foundBreakables[i][IDX_COUNT]/5))..")")
|
btn.text:SetText(foundBreakables[i][IDX_COUNT].." ("..(floor(foundBreakables[i][IDX_COUNT]/5))..")")
|
||||||
@ -608,7 +637,11 @@ function Breakables:FindBreakables(bag)
|
|||||||
local BreakableAbilityName = GetSpellInfo((foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_HERB and MillingId) or (foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_ORE and ProspectingId) or DisenchantId)
|
local BreakableAbilityName = GetSpellInfo((foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_HERB and MillingId) or (foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_ORE and ProspectingId) or DisenchantId)
|
||||||
btn:SetAttribute("spell", BreakableAbilityName)
|
btn:SetAttribute("spell", BreakableAbilityName)
|
||||||
btn:SetAttribute("target-item", foundBreakables[i][IDX_NAME])
|
btn:SetAttribute("target-item", foundBreakables[i][IDX_NAME])
|
||||||
|
if lbfGroup then
|
||||||
btn.icon:SetTexture(foundBreakables[i][IDX_TEXTURE])
|
btn.icon:SetTexture(foundBreakables[i][IDX_TEXTURE])
|
||||||
|
else
|
||||||
|
btn:SetNormalTexture(foundBreakables[i][IDX_TEXTURE])
|
||||||
|
end
|
||||||
|
|
||||||
btn:SetScript("OnEnter", function(this) self:OnEnterBreakableButton(this, foundBreakables[i]) end)
|
btn:SetScript("OnEnter", function(this) self:OnEnterBreakableButton(this, foundBreakables[i]) end)
|
||||||
btn:SetScript("OnLeave", function() self:OnLeaveBreakableButton(foundBreakables[i]) end)
|
btn:SetScript("OnLeave", function() self:OnLeaveBreakableButton(foundBreakables[i]) end)
|
||||||
@ -627,7 +660,6 @@ function Breakables:FindBreakables(bag)
|
|||||||
if self.breakableButtons[i] and numBreakableStacks[i] < #self.breakableButtons[i] then
|
if self.breakableButtons[i] and numBreakableStacks[i] < #self.breakableButtons[i] then
|
||||||
for j=numBreakableStacks[i]+1,#self.breakableButtons[i] do
|
for j=numBreakableStacks[i]+1,#self.breakableButtons[i] do
|
||||||
self.breakableButtons[i][j]:Hide()
|
self.breakableButtons[i][j]:Hide()
|
||||||
self.breakableButtons[i][j].icon:SetTexture(nil)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
## Notes: Tracks herbs/ore/items that can be broken into component pieces
|
## Notes: Tracks herbs/ore/items that can be broken into component pieces
|
||||||
## Version: @project-version@ (Revision: @project-revision@)
|
## Version: @project-version@ (Revision: @project-revision@)
|
||||||
## SavedVariables: BreakablesDB
|
## SavedVariables: BreakablesDB
|
||||||
## OptionalDeps: Ace3, LibBabble-Inventory-3.0
|
## OptionalDeps: Ace3, LibBabble-Inventory-3.0, ButtonFacade
|
||||||
|
|
||||||
#@no-lib-strip@
|
#@no-lib-strip@
|
||||||
embeds.xml
|
embeds.xml
|
||||||
|
@ -10,4 +10,5 @@
|
|||||||
<Include file="libs\AceGUI-3.0\AceGUI-3.0.xml"/>
|
<Include file="libs\AceGUI-3.0\AceGUI-3.0.xml"/>
|
||||||
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
|
<Include file="libs\AceLocale-3.0\AceLocale-3.0.xml"/>
|
||||||
<Include file="libs\LibBabble-Inventory-3.0\lib.xml"/>
|
<Include file="libs\LibBabble-Inventory-3.0\lib.xml"/>
|
||||||
|
<Include file="libs\LibButtonFacade\LibButtonFacade.xml"/>
|
||||||
</Ui>
|
</Ui>
|
Reference in New Issue
Block a user