Trying to fix the buttons of bags

This commit is contained in:
Bunny67
2018-07-22 15:43:56 +03:00
parent 0b7ba7535c
commit 2c39bb067c
+59
View File
@@ -366,6 +366,61 @@ function B:ResetSlotAlphaForBags(f)
end end
end end
local function buttonOnClick(button, ignoreModifiers)
if not button then button = arg1 end
--KeyRing special case code
if this:GetParent():GetID() == KEYRING_CONTAINER then
KeyRingItemButton_OnClick(button, ignoreModifiers)
return
end
if button == "LeftButton" then
if IsControlKeyDown() and not ignoreModifiers then
DressUpItemLink(GetContainerItemLink(this:GetParent():GetID(), this:GetID()))
elseif IsShiftKeyDown() and not ignoreModifiers then
if ChatFrameEditBox:IsShown() then
ChatFrameEditBox:Insert(GetContainerItemLink(this:GetParent():GetID(), this:GetID()))
else
local texture, itemCount, locked = GetContainerItemInfo(this:GetParent():GetID(), this:GetID())
if not locked then
this.SplitStack = function(button, split)
SplitContainerItem(button:GetParent():GetID(), button:GetID(), split)
end
OpenStackSplitFrame(this.count, this, "BOTTOMRIGHT", "TOPRIGHT")
end
end
else
PickupContainerItem(this:GetParent():GetID(), this:GetID())
StackSplitFrame:Hide()
end
else
if IsControlKeyDown() and not ignoreModifiers then
return
elseif IsShiftKeyDown() and MerchantFrame:IsShown() and not ignoreModifiers then
this.SplitStack = function(button, split)
SplitContainerItem(button:GetParent():GetID(), button:GetID(), split)
MerchantItemButton_OnClick("LeftButton")
end
OpenStackSplitFrame(this.count, this, "BOTTOMRIGHT", "TOPRIGHT")
elseif MerchantFrame:IsShown() and MerchantFrame.selectedTab == 2 then
-- Don't sell the item if the buyback tab is selected
return
else
UseContainerItem(this:GetParent():GetID(), this:GetID())
StackSplitFrame:Hide()
end
end
end
local function buttonOnDragStart()
buttonOnClick("LeftButton", 1)
end
local function buttonOnReceiveDrag()
buttonOnClick("LeftButton", 1)
end
function B:Layout(isBank) function B:Layout(isBank)
if E.private.bags.enable ~= true then return end if E.private.bags.enable ~= true then return end
local f = self:GetContainerFrame(isBank) local f = self:GetContainerFrame(isBank)
@@ -472,6 +527,10 @@ function B:Layout(isBank)
f.Bags[bagID][slotID]:SetNormalTexture("") f.Bags[bagID][slotID]:SetNormalTexture("")
f.Bags[bagID][slotID]:SetCheckedTexture("") f.Bags[bagID][slotID]:SetCheckedTexture("")
f.Bags[bagID][slotID]:SetScript("OnClick", buttonOnClick)
f.Bags[bagID][slotID]:SetScript("OnDragStart", buttonOnDragStart)
f.Bags[bagID][slotID]:SetScript("OnReceiveDrag", buttonOnReceiveDrag)
f.Bags[bagID][slotID].Count = _G[f.Bags[bagID][slotID]:GetName().."Count"] f.Bags[bagID][slotID].Count = _G[f.Bags[bagID][slotID]:GetName().."Count"]
f.Bags[bagID][slotID].Count:ClearAllPoints() f.Bags[bagID][slotID].Count:ClearAllPoints()
E:Point(f.Bags[bagID][slotID].Count, "BOTTOMRIGHT", 0, 2) E:Point(f.Bags[bagID][slotID].Count, "BOTTOMRIGHT", 0, 2)