|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
local L = LibStub("AceLocale-3.0"):GetLocale("Breakables", false)
|
|
|
|
|
Breakables = LibStub("AceAddon-3.0"):NewAddon("Breakables", "AceConsole-3.0", "AceEvent-3.0")
|
|
|
|
|
local babbleInv = LibStub("LibBabble-Inventory-3.0"):GetLookupTable()
|
|
|
|
|
local LBF = LibStub("LibButtonFacade", true)
|
|
|
|
|
|
|
|
|
|
local lbfGroup
|
|
|
|
|
|
|
|
|
|
local MillingId = 51005
|
|
|
|
|
local MillingItemSubType = babbleInv["Herb"]
|
|
|
|
@ -15,8 +18,21 @@ local DisenchantId = 13262
|
|
|
|
|
local DisenchantTypes = {babbleInv["Armor"], babbleInv["Weapon"]}
|
|
|
|
|
local CanDisenchant = false
|
|
|
|
|
|
|
|
|
|
local PickLockId = 1804
|
|
|
|
|
local PickableItems = {
|
|
|
|
|
16882, -- battered junkbox
|
|
|
|
|
16883, -- worn junkbox
|
|
|
|
|
16884, -- sturdy junkbox
|
|
|
|
|
16885, -- heavy junkbox
|
|
|
|
|
29569, -- strong junkbox
|
|
|
|
|
43575, -- reinforced junkbox
|
|
|
|
|
63349, -- flame-scarred junkbox
|
|
|
|
|
}
|
|
|
|
|
local CanPickLock = false
|
|
|
|
|
|
|
|
|
|
-- item rarity must meet or surpass this to be considered for disenchantability (is that a word?)
|
|
|
|
|
local RARITY_UNCOMMON = 2
|
|
|
|
|
local RARITY_HEIRLOOM = 7
|
|
|
|
|
|
|
|
|
|
local IDX_LINK = 1
|
|
|
|
|
local IDX_COUNT = 2
|
|
|
|
@ -28,22 +44,26 @@ local IDX_SUBTYPE = 7
|
|
|
|
|
local IDX_LEVEL = 8
|
|
|
|
|
local IDX_BREAKABLETYPE = 9
|
|
|
|
|
local IDX_SOULBOUND = 10
|
|
|
|
|
local IDX_NAME = 11
|
|
|
|
|
|
|
|
|
|
local BREAKABLE_HERB = 1
|
|
|
|
|
local BREAKABLE_ORE = 2
|
|
|
|
|
local BREAKABLE_DE = 3
|
|
|
|
|
local BREAKABLE_PICK = 4
|
|
|
|
|
|
|
|
|
|
local BagUpdateCheckDelay = 1.5
|
|
|
|
|
local BagUpdateCheckDelay = 1.0
|
|
|
|
|
local nextCheck = {}
|
|
|
|
|
for i=0,NUM_BAG_SLOTS do
|
|
|
|
|
nextCheck[i] = -1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local buttonSize = 28
|
|
|
|
|
local buttonSize = 45
|
|
|
|
|
|
|
|
|
|
local _G = _G
|
|
|
|
|
|
|
|
|
|
-- can be 1 or 2
|
|
|
|
|
local validGrowDirections = {L["Left"], L["Right"], L["Up"], L["Down"]}
|
|
|
|
|
|
|
|
|
|
-- can be 1, 2, or 3 (in the case of a rogue with pick lock)
|
|
|
|
|
local numEligibleProfessions = 0
|
|
|
|
|
|
|
|
|
|
Breakables.optionsFrame = {}
|
|
|
|
@ -61,7 +81,8 @@ function Breakables:OnInitialize()
|
|
|
|
|
hide = false,
|
|
|
|
|
hideInCombat = false,
|
|
|
|
|
buttonScale = 1,
|
|
|
|
|
fontSize = 7,
|
|
|
|
|
fontSize = 11,
|
|
|
|
|
growDirection = 2,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
self.db = LibStub("AceDB-3.0"):New("BreakablesDB", self.defaults, true)
|
|
|
|
@ -85,6 +106,15 @@ function Breakables:OnInitialize()
|
|
|
|
|
self:InitLDB()
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
function Breakables:InitLDB()
|
|
|
|
|
local LDB = LibStub and LibStub("LibDataBroker-1.1", true)
|
|
|
|
|
|
|
|
|
@ -111,13 +141,26 @@ function Breakables:OnEnable()
|
|
|
|
|
CanMill = IsUsableSpell(GetSpellInfo(MillingId))
|
|
|
|
|
CanProspect = IsUsableSpell(GetSpellInfo(ProspectingId))
|
|
|
|
|
CanDisenchant = IsUsableSpell(GetSpellInfo(DisenchantId))
|
|
|
|
|
CanPickLock = IsUsableSpell(GetSpellInfo(PickLockId))
|
|
|
|
|
|
|
|
|
|
LibStub("AceConfig-3.0"):RegisterOptionsTable("Breakables", self:GetOptions(), "breakables")
|
|
|
|
|
self.optionsFrame = LibStub("AceConfigDialog-3.0"):AddToBlizOptions("Breakables")
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
self:RegisterEvents()
|
|
|
|
|
|
|
|
|
|
if CanMill or CanProspect or CanDisenchant then
|
|
|
|
|
if CanMill or CanProspect or CanDisenchant or CanPickLock then
|
|
|
|
|
if CanMill then
|
|
|
|
|
numEligibleProfessions = numEligibleProfessions + 1
|
|
|
|
|
end
|
|
|
|
@ -127,6 +170,9 @@ function Breakables:OnEnable()
|
|
|
|
|
if CanDisenchant then
|
|
|
|
|
numEligibleProfessions = numEligibleProfessions + 1
|
|
|
|
|
end
|
|
|
|
|
if CanPickLock then
|
|
|
|
|
numEligibleProfessions = numEligibleProfessions + 1
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
self:CreateButtonFrame()
|
|
|
|
|
if self.settings.hide then
|
|
|
|
@ -134,7 +180,10 @@ function Breakables:OnEnable()
|
|
|
|
|
else
|
|
|
|
|
self:FindBreakables()
|
|
|
|
|
end
|
|
|
|
|
self.frame:SetScript("OnUpdate", function() self:CheckShouldFindBreakables() end)
|
|
|
|
|
if not self.frame.OnUpdateFunc then
|
|
|
|
|
self.frame.OnUpdateFunc = function() self:CheckShouldFindBreakables() end
|
|
|
|
|
end
|
|
|
|
|
self.frame:SetScript("OnUpdate", self.frame.OnUpdateFunc)
|
|
|
|
|
else
|
|
|
|
|
self:UnregisterAllEvents()
|
|
|
|
|
end
|
|
|
|
@ -167,6 +216,10 @@ function Breakables:RegisterEvents()
|
|
|
|
|
if CanDisenchant then
|
|
|
|
|
self:RegisterEvent("TRADE_SKILL_UPDATE", "OnTradeSkillUpdate")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if CanPickLock then
|
|
|
|
|
self:RegisterEvent("CHAT_MSG_OPENING", "OnBagItemLockPicked")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnDisable()
|
|
|
|
@ -223,6 +276,10 @@ function Breakables:OnTradeSkillUpdate()
|
|
|
|
|
self:GetEnchantingLevel()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnBagItemLockPicked()
|
|
|
|
|
nextCheck[1] = GetTime() + BagUpdateCheckDelay
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:GetEnchantingLevel()
|
|
|
|
|
local skillName, skillType, numAvailable, isExpanded = GetTradeSkillInfo(1)
|
|
|
|
|
|
|
|
|
@ -351,6 +408,20 @@ function Breakables:GetOptions()
|
|
|
|
|
end,
|
|
|
|
|
order = 6,
|
|
|
|
|
},
|
|
|
|
|
growDirection = {
|
|
|
|
|
type = 'select',
|
|
|
|
|
name = L["Button grow direction"],
|
|
|
|
|
desc = L["This controls which direction the breakable buttons grow toward."],
|
|
|
|
|
values = validGrowDirections,
|
|
|
|
|
get = function()
|
|
|
|
|
return self.settings.growDirection
|
|
|
|
|
end,
|
|
|
|
|
set = function(info, v)
|
|
|
|
|
self.settings.growDirection = v
|
|
|
|
|
self:FindBreakables()
|
|
|
|
|
end,
|
|
|
|
|
order = 7,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -397,69 +468,93 @@ end
|
|
|
|
|
|
|
|
|
|
function Breakables:CreateButtonFrame()
|
|
|
|
|
if not self.frame then
|
|
|
|
|
self.frame = CreateFrame("Frame")
|
|
|
|
|
self.frame = CreateFrame("Frame", nil, UIParent)
|
|
|
|
|
end
|
|
|
|
|
self.frame:SetScale(self.settings.buttonScale)
|
|
|
|
|
if not self.buttonFrame then
|
|
|
|
|
self.buttonFrame = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
for i=1,numEligibleProfessions do
|
|
|
|
|
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
|
|
|
|
|
self.buttonFrame[i]:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.settings.buttonFrameLeft[i], self.settings.buttonFrameTop[i])
|
|
|
|
|
local frame = self.buttonFrame[i]
|
|
|
|
|
frame:SetPoint("TOPLEFT", UIParent, "BOTTOMLEFT", self.settings.buttonFrameLeft[i], self.settings.buttonFrameTop[i])
|
|
|
|
|
|
|
|
|
|
if CanMill and (i == 1 or self.buttonFrame[1].type ~= BREAKABLE_HERB) then
|
|
|
|
|
self.buttonFrame[i].type = BREAKABLE_HERB
|
|
|
|
|
frame.type = BREAKABLE_HERB
|
|
|
|
|
elseif CanDisenchant and (i == 1 or self.buttonFrame[1].type ~= BREAKABLE_DE) then
|
|
|
|
|
self.buttonFrame[i].type = BREAKABLE_DE
|
|
|
|
|
frame.type = BREAKABLE_DE
|
|
|
|
|
elseif CanProspect and (i == 1 or self.buttonFrame[1].type ~= BREAKABLE_ORE) then
|
|
|
|
|
self.buttonFrame[i].type = BREAKABLE_ORE
|
|
|
|
|
frame.type = BREAKABLE_ORE
|
|
|
|
|
elseif CanPickLock and (i == 1 or self.buttonFrame[1].type ~= BREAKABLE_PICK) then
|
|
|
|
|
frame.type = BREAKABLE_PICK
|
|
|
|
|
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
|
|
|
|
|
self.buttonFrame[i]:SetWidth(buttonSize * self.settings.buttonScale)
|
|
|
|
|
self.buttonFrame[i]:SetHeight(buttonSize * self.settings.buttonScale)
|
|
|
|
|
if frame.type then
|
|
|
|
|
frame:SetWidth(buttonSize)
|
|
|
|
|
frame:SetHeight(buttonSize)
|
|
|
|
|
|
|
|
|
|
self.buttonFrame[i]:EnableMouse(true)
|
|
|
|
|
self.buttonFrame[i]:RegisterForClicks("LeftButtonUp")
|
|
|
|
|
frame:EnableMouse(true)
|
|
|
|
|
frame:RegisterForClicks("LeftButtonUp")
|
|
|
|
|
|
|
|
|
|
self.buttonFrame[i]:SetMovable(true)
|
|
|
|
|
self.buttonFrame[i]:RegisterForDrag("LeftButton")
|
|
|
|
|
self.buttonFrame[i]:SetScript("OnMouseDown", function(frame) self:OnMouseDown(frame) end)
|
|
|
|
|
self.buttonFrame[i]:SetScript("OnMouseUp", function(frame) self:OnMouseUp(frame) end)
|
|
|
|
|
self.buttonFrame[i]:SetClampedToScreen(true)
|
|
|
|
|
if not frame.OnMouseDownFunc then
|
|
|
|
|
frame.OnMouseDownFunc = function(frame) self:OnMouseDown(frame) end
|
|
|
|
|
end
|
|
|
|
|
if not frame.OnMouseUpFunc then
|
|
|
|
|
frame.OnMouseUpFunc = function(frame) self:OnMouseUp(frame) end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local spellName, _, texture = GetSpellInfo((self.buttonFrame[i].type == BREAKABLE_HERB and MillingId) or (self.buttonFrame[i].type == BREAKABLE_ORE and ProspectingId) or DisenchantId)
|
|
|
|
|
frame:SetMovable(true)
|
|
|
|
|
frame:RegisterForDrag("LeftButton")
|
|
|
|
|
frame:SetScript("OnMouseDown", frame.OnMouseDownFunc)
|
|
|
|
|
frame:SetScript("OnMouseUp", frame.OnMouseUpFunc)
|
|
|
|
|
frame:SetClampedToScreen(true)
|
|
|
|
|
|
|
|
|
|
self.buttonFrame[i]:SetAttribute("type1", "spell")
|
|
|
|
|
self.buttonFrame[i]:SetAttribute("spell1", spellName)
|
|
|
|
|
local spellName, _, texture = GetSpellInfo(self:GetSpellIdFromProfessionButton(frame))
|
|
|
|
|
|
|
|
|
|
self.buttonFrame[i].icon:SetTexture(texture)
|
|
|
|
|
self.buttonFrame[i].icon:SetAllPoints(self.buttonFrame[i])
|
|
|
|
|
else
|
|
|
|
|
self.buttonFrame[i]:SetTexture(nil)
|
|
|
|
|
frame:SetAttribute("type1", "spell")
|
|
|
|
|
frame:SetAttribute("spell1", spellName)
|
|
|
|
|
|
|
|
|
|
if not lbfGroup then
|
|
|
|
|
frame:SetNormalTexture(texture)
|
|
|
|
|
else
|
|
|
|
|
frame.icon = frame:CreateTexture(frame:GetName().."Icon", "BACKGROUND")
|
|
|
|
|
frame.icon:SetTexture(texture)
|
|
|
|
|
|
|
|
|
|
lbfGroup:AddButton(frame)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if not frame.OnEnterFunc then
|
|
|
|
|
frame.OnEnterFunc = function(this) self:OnEnterProfessionButton(this) end
|
|
|
|
|
end
|
|
|
|
|
if not frame.OnLeaveFunc then
|
|
|
|
|
frame.OnLeaveFunc = function() self:OnLeaveProfessionButton() end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
frame:SetScript("OnEnter", frame.OnEnterFunc)
|
|
|
|
|
frame:SetScript("OnLeave", frame.OnLeaveFunc)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:GetSpellIdFromProfessionButton(btn)
|
|
|
|
|
return (btn.type == BREAKABLE_HERB and MillingId)
|
|
|
|
|
or (btn.type == BREAKABLE_ORE and ProspectingId)
|
|
|
|
|
or (btn.type == BREAKABLE_DE and DisenchantId)
|
|
|
|
|
or PickLockId
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:ApplyScale()
|
|
|
|
|
if not self.buttonFrame then
|
|
|
|
|
return
|
|
|
|
|
end
|
|
|
|
|
self.frame:SetScale(self.settings.buttonScale)
|
|
|
|
|
|
|
|
|
|
for i=1,numEligibleProfessions do
|
|
|
|
|
-- yes, setscale exists...but it was scaling buttonFrame and breakableButtons differently for some reason. this works better.
|
|
|
|
|
self.buttonFrame[i]:SetWidth(buttonSize * self.settings.buttonScale)
|
|
|
|
|
self.buttonFrame[i]:SetHeight(buttonSize * self.settings.buttonScale)
|
|
|
|
|
|
|
|
|
|
if self.breakableButtons[i] then
|
|
|
|
|
for j=1,#self.breakableButtons[i] do
|
|
|
|
|
self.breakableButtons[i][j]:SetWidth(buttonSize * self.settings.buttonScale)
|
|
|
|
|
self.breakableButtons[i][j]:SetHeight(buttonSize * self.settings.buttonScale)
|
|
|
|
|
self.breakableButtons[i][j].text:SetFont(NumberFont_Outline_Med:GetFont(), self.settings.fontSize, "OUTLINE")
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
@ -535,26 +630,28 @@ function Breakables:FindBreakables(bag)
|
|
|
|
|
|
|
|
|
|
if foundBreakables[i][IDX_BREAKABLETYPE] == self.buttonFrame[j].type and numBreakableStacks[j] < self.settings.maxBreakablesToShow then
|
|
|
|
|
local isDisenchantable = self:BreakableIsDisenchantable(foundBreakables[i][IDX_TYPE], foundBreakables[i][IDX_LEVEL])
|
|
|
|
|
if (CanDisenchant and isDisenchantable) or foundBreakables[i][IDX_COUNT] >= 5 then
|
|
|
|
|
local isLockedItem = foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_PICK
|
|
|
|
|
|
|
|
|
|
if (CanDisenchant and isDisenchantable) or (CanPickLock and isLockedItem) or (foundBreakables[i][IDX_COUNT] >= 5) then
|
|
|
|
|
numBreakableStacks[j] = numBreakableStacks[j] + 1
|
|
|
|
|
local btnIdx = numBreakableStacks[j]
|
|
|
|
|
|
|
|
|
|
local btn = self.breakableButtons[j][numBreakableStacks[j]]
|
|
|
|
|
if not self.breakableButtons[j][numBreakableStacks[j]] then
|
|
|
|
|
self.breakableButtons[j][numBreakableStacks[j]] = CreateFrame("Button", nil, self.buttonFrame[j], "SecureActionButtonTemplate")
|
|
|
|
|
local btn = self.breakableButtons[j][btnIdx]
|
|
|
|
|
if not self.breakableButtons[j][btnIdx] then
|
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
btn:SetPoint("LEFT", numBreakableStacks[j] == 1 and self.buttonFrame[j] or self.breakableButtons[j][numBreakableStacks[j] - 1], "RIGHT")
|
|
|
|
|
btn:SetWidth(buttonSize * self.settings.buttonScale)
|
|
|
|
|
btn:SetHeight(buttonSize * self.settings.buttonScale)
|
|
|
|
|
if lbfGroup then
|
|
|
|
|
btn.icon = btn:CreateTexture(btn:GetName().."Icon", "BACKGROUND")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
btn:SetWidth(buttonSize)
|
|
|
|
|
btn:SetHeight(buttonSize)
|
|
|
|
|
btn:EnableMouse(true)
|
|
|
|
|
btn:RegisterForClicks("AnyUp")
|
|
|
|
|
|
|
|
|
|
btn:SetAttribute("type", "macro")
|
|
|
|
|
|
|
|
|
|
-- btn:SetAttribute("type1", "item")
|
|
|
|
|
-- btn:SetAttribute("bag1", foundBreakables[i][IDX_BAG])
|
|
|
|
|
-- btn:SetAttribute("slot1", foundBreakables[i][IDX_SLOT])
|
|
|
|
|
btn:SetAttribute("type", "spell")
|
|
|
|
|
|
|
|
|
|
if not btn.text then
|
|
|
|
|
btn.text = btn:CreateFontString()
|
|
|
|
@ -562,22 +659,76 @@ function Breakables:FindBreakables(bag)
|
|
|
|
|
end
|
|
|
|
|
btn.text:SetFont(NumberFont_Outline_Med:GetFont(), self.settings.fontSize, "OUTLINE")
|
|
|
|
|
|
|
|
|
|
if not btn.icon then
|
|
|
|
|
btn.icon = btn:CreateTexture(nil, "BACKGROUND")
|
|
|
|
|
if lbfGroup then
|
|
|
|
|
lbfGroup:AddButton(btn)
|
|
|
|
|
end
|
|
|
|
|
btn.icon:SetAllPoints(btn)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local attachFrom = "LEFT"
|
|
|
|
|
local attachTo = "RIGHT"
|
|
|
|
|
if self.settings.growDirection then
|
|
|
|
|
if self.settings.growDirection == 1 then -- left
|
|
|
|
|
attachFrom = "RIGHT"
|
|
|
|
|
attachTo = "LEFT"
|
|
|
|
|
--elseif self.settings.growDirection == 2 then -- right
|
|
|
|
|
elseif self.settings.growDirection == 3 then -- up
|
|
|
|
|
attachFrom = "BOTTOM"
|
|
|
|
|
attachTo = "TOP"
|
|
|
|
|
elseif self.settings.growDirection == 4 then -- down
|
|
|
|
|
attachFrom = "TOP"
|
|
|
|
|
attachTo = "BOTTOM"
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
btn:ClearAllPoints()
|
|
|
|
|
btn:SetPoint(attachFrom, btnIdx == 1 and self.buttonFrame[j] or self.breakableButtons[j][btnIdx - 1], attachTo)
|
|
|
|
|
|
|
|
|
|
if not isDisenchantable then
|
|
|
|
|
btn.text:SetText(foundBreakables[i][IDX_COUNT].." ("..(floor(foundBreakables[i][IDX_COUNT]/5))..")")
|
|
|
|
|
local appendText = ""
|
|
|
|
|
if not isLockedItem then
|
|
|
|
|
appendText = " ("..(floor(foundBreakables[i][IDX_COUNT]/5))..")"
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
btn.text:SetText(foundBreakables[i][IDX_COUNT] .. appendText)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local BreakableAbilityName = GetSpellInfo((foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_HERB and MillingId) or (foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_ORE and ProspectingId) or DisenchantId)
|
|
|
|
|
btn:SetAttribute("macrotext", "/cast "..BreakableAbilityName.."\n/use "..foundBreakables[i][IDX_BAG].." "..foundBreakables[i][IDX_SLOT].."\n/script Breakables.justClicked=true")
|
|
|
|
|
btn.icon:SetTexture(foundBreakables[i][IDX_TEXTURE])
|
|
|
|
|
local BreakableAbilityName = GetSpellInfo((foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_HERB and MillingId)
|
|
|
|
|
or (foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_ORE and ProspectingId)
|
|
|
|
|
or (foundBreakables[i][IDX_BREAKABLETYPE] == BREAKABLE_DE and DisenchantId)
|
|
|
|
|
or PickLockId)
|
|
|
|
|
btn:SetAttribute("spell", BreakableAbilityName)
|
|
|
|
|
|
|
|
|
|
btn:SetScript("OnEnter", function(this) self:OnEnterBreakableButton(this, foundBreakables[i]) end)
|
|
|
|
|
btn:SetScript("OnLeave", function() self:OnLeaveBreakableButton(foundBreakables[i]) end)
|
|
|
|
|
if isLockedItem then
|
|
|
|
|
btn:SetAttribute("target-item")
|
|
|
|
|
btn:SetAttribute("target-bag", foundBreakables[i][IDX_BAG])
|
|
|
|
|
btn:SetAttribute("target-slot", foundBreakables[i][IDX_SLOT])
|
|
|
|
|
else
|
|
|
|
|
btn:SetAttribute("target-item", foundBreakables[i][IDX_NAME])
|
|
|
|
|
btn:SetAttribute("target-bag")
|
|
|
|
|
btn:SetAttribute("target-slot")
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if lbfGroup then
|
|
|
|
|
btn.icon:SetTexture(foundBreakables[i][IDX_TEXTURE])
|
|
|
|
|
else
|
|
|
|
|
btn:SetNormalTexture(foundBreakables[i][IDX_TEXTURE])
|
|
|
|
|
end
|
|
|
|
|
btn.bag = foundBreakables[i][IDX_BAG]
|
|
|
|
|
btn.slot = foundBreakables[i][IDX_SLOT]
|
|
|
|
|
|
|
|
|
|
if not btn.OnEnterFunc then
|
|
|
|
|
btn.OnEnterFunc = function(this) self:OnEnterBreakableButton(this) end
|
|
|
|
|
end
|
|
|
|
|
if not btn.OnLeaveFunc then
|
|
|
|
|
btn.OnLeaveFunc = function() self:OnLeaveBreakableButton() end
|
|
|
|
|
end
|
|
|
|
|
if not btn.PostClickedFunc then
|
|
|
|
|
btn.PostClickedFunc = function(this) self:PostClickedBreakableButton(this) end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
btn:SetScript("OnEnter", btn.OnEnterFunc)
|
|
|
|
|
btn:SetScript("OnLeave", btn.OnLeaveFunc)
|
|
|
|
|
btn:SetScript("PostClick", btn.PostClickedFunc)
|
|
|
|
|
|
|
|
|
|
btn:Show()
|
|
|
|
|
end
|
|
|
|
@ -593,7 +744,6 @@ function Breakables:FindBreakables(bag)
|
|
|
|
|
if self.breakableButtons[i] and numBreakableStacks[i] < #self.breakableButtons[i] then
|
|
|
|
|
for j=numBreakableStacks[i]+1,#self.breakableButtons[i] do
|
|
|
|
|
self.breakableButtons[i][j]:Hide()
|
|
|
|
|
self.breakableButtons[i][j].icon:SetTexture(nil)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
@ -607,15 +757,38 @@ function Breakables:FindBreakables(bag)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnEnterBreakableButton(this, breakable)
|
|
|
|
|
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT")
|
|
|
|
|
GameTooltip:SetBagItem(breakable[IDX_BAG], breakable[IDX_SLOT])
|
|
|
|
|
function Breakables:OnEnterProfessionButton(btn)
|
|
|
|
|
GameTooltip:SetOwner(btn, "ANCHOR_BOTTOMLEFT")
|
|
|
|
|
GameTooltip:SetSpellByID(self:GetSpellIdFromProfessionButton(btn))
|
|
|
|
|
|
|
|
|
|
GameTooltip:AddLine(" ")
|
|
|
|
|
GameTooltip:AddLine(L["Hold shift and left-click to drag the Breakables bar around."], 1, 1, 1, 1)
|
|
|
|
|
GameTooltip:Show()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnLeaveBreakableButton(breakable)
|
|
|
|
|
function Breakables:OnLeaveProfessionButton()
|
|
|
|
|
GameTooltip:Hide()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnEnterBreakableButton(this)
|
|
|
|
|
GameTooltip:SetOwner(this, "ANCHOR_BOTTOMLEFT")
|
|
|
|
|
GameTooltip:SetBagItem(this.bag, this.slot)
|
|
|
|
|
|
|
|
|
|
GameTooltip:AddLine(" ")
|
|
|
|
|
GameTooltip:AddLine(L["You can click on this button to break this item without having to click on the profession button first."], 1, 1, 1, 1)
|
|
|
|
|
GameTooltip:Show()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:OnLeaveBreakableButton()
|
|
|
|
|
GameTooltip:Hide()
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:PostClickedBreakableButton(this)
|
|
|
|
|
if this.type == BREAKABLE_HERB or this.type == BREAKABLE_ORE or this.type == BREAKABLE_DE then
|
|
|
|
|
self.justClicked = true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:FindBreakablesInBag(bagId)
|
|
|
|
|
local foundBreakables = {}
|
|
|
|
|
local i=1
|
|
|
|
@ -646,11 +819,12 @@ function Breakables:FindBreakablesInSlot(bagId, slotId)
|
|
|
|
|
local texture, itemCount, locked, quality, readable = GetContainerItemInfo(bagId, slotId)
|
|
|
|
|
if texture then
|
|
|
|
|
local itemLink = GetContainerItemLink(bagId, slotId)
|
|
|
|
|
local _, _, itemRarity, itemLevel, _, itemType, itemSubType, _, _, itemTexture = GetItemInfo(itemLink)
|
|
|
|
|
local itemName, _, itemRarity, itemLevel, _, itemType, itemSubType, _, _, itemTexture = GetItemInfo(itemLink)
|
|
|
|
|
|
|
|
|
|
self.myTooltip:SetBagItem(bagId, slotId)
|
|
|
|
|
|
|
|
|
|
if CanDisenchant and itemRarity and itemRarity >= RARITY_UNCOMMON and self:BreakableIsDisenchantable(itemType, itemLevel) then
|
|
|
|
|
if CanDisenchant and itemRarity and itemRarity >= RARITY_UNCOMMON and itemRarity < RARITY_HEIRLOOM
|
|
|
|
|
and self:BreakableIsDisenchantable(itemType, itemLevel) then
|
|
|
|
|
local i = 1
|
|
|
|
|
local soulbound = false
|
|
|
|
|
for i=1,5 do
|
|
|
|
@ -667,26 +841,86 @@ function Breakables:FindBreakablesInSlot(bagId, slotId)
|
|
|
|
|
local shouldHideThisItem = self.settings.hideEqManagerItems and isInEquipmentSet
|
|
|
|
|
|
|
|
|
|
if (not soulbound or self.settings.showSoulbound) and not shouldHideThisItem then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_DE, soulbound}
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_DE, soulbound, itemName}
|
|
|
|
|
else
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
local extraInfo = BreakablesTooltipTextLeft2:GetText()
|
|
|
|
|
|
|
|
|
|
if CanMill and (itemSubType == MillingItemSubType or itemSubType == MillingItemSecondarySubType) and extraInfo == ITEM_MILLABLE then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_HERB, false}
|
|
|
|
|
local idx = 1
|
|
|
|
|
local millable = false
|
|
|
|
|
local prospectable = false
|
|
|
|
|
for idx=1,5 do
|
|
|
|
|
if _G["BreakablesTooltipTextLeft"..idx] then
|
|
|
|
|
if _G["BreakablesTooltipTextLeft"..idx]:GetText() == ITEM_MILLABLE then
|
|
|
|
|
millable = true
|
|
|
|
|
break
|
|
|
|
|
elseif _G["BreakablesTooltipTextLeft"..idx]:GetText() == ITEM_PROSPECTABLE then
|
|
|
|
|
prospectable = true
|
|
|
|
|
break
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if CanProspect and itemSubType == ProspectingItemSubType and extraInfo == ITEM_PROSPECTABLE then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_ORE, false}
|
|
|
|
|
if CanMill and (itemSubType == MillingItemSubType or itemSubType == MillingItemSecondarySubType) and millable then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_HERB, false, itemName}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if CanProspect and itemSubType == ProspectingItemSubType and prospectable then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_ORE, false, itemName}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
if CanPickLock and self:ItemIsPickable(self:GetItemIdFromLink(itemLink)) and self:ItemIsLocked(bagId, slotId) then
|
|
|
|
|
return {itemLink, itemCount, itemType, itemTexture, bagId, slotId, itemSubType, itemLevel, BREAKABLE_PICK, false, itemName}
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:ItemIsPickable(itemId)
|
|
|
|
|
for i=1,#PickableItems do
|
|
|
|
|
if PickableItems[i] == itemId then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
do
|
|
|
|
|
local regions = {}
|
|
|
|
|
local tooltipBuffer = CreateFrame("GameTooltip","tooltipBuffer",nil,"GameTooltipTemplate")
|
|
|
|
|
tooltipBuffer:SetOwner(WorldFrame, "ANCHOR_NONE")
|
|
|
|
|
|
|
|
|
|
local function makeTable(t, ...)
|
|
|
|
|
wipe(t)
|
|
|
|
|
for i = 1, select("#", ...) do
|
|
|
|
|
t[i] = select(i, ...)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:ItemIsLocked(bagId, slotId)
|
|
|
|
|
tooltipBuffer:ClearLines()
|
|
|
|
|
tooltipBuffer:SetBagItem(bagId, slotId)
|
|
|
|
|
|
|
|
|
|
-- Grab all regions, stuff em into our table
|
|
|
|
|
makeTable(regions, tooltipBuffer:GetRegions())
|
|
|
|
|
|
|
|
|
|
-- Convert FontStrings to strings, replace anything else with ""
|
|
|
|
|
for i=1, #regions do
|
|
|
|
|
local region = regions[i]
|
|
|
|
|
if region:GetObjectType() == "FontString" then
|
|
|
|
|
if region:GetText() == LOCKED then
|
|
|
|
|
return true
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function Breakables:IsInEquipmentSet(itemId)
|
|
|
|
|
for setIdx=1, GetNumEquipmentSets() do
|
|
|
|
|
local set = GetEquipmentSetInfo(setIdx)
|
|
|
|
|