Pull qty popout into its own file
This commit is contained in:
parent
847478800f
commit
2d7d300124
|
@ -22,6 +22,7 @@ LibItemSearch-1.0.lua
|
||||||
frames\AltCurrency.lua
|
frames\AltCurrency.lua
|
||||||
frames\AltCurrencyItem.lua
|
frames\AltCurrencyItem.lua
|
||||||
frames\MerchantItem.lua
|
frames\MerchantItem.lua
|
||||||
|
frames\QtyPopout.lua
|
||||||
frames\RowShader.lua
|
frames\RowShader.lua
|
||||||
frames\SearchField.lua
|
frames\SearchField.lua
|
||||||
|
|
||||||
|
|
|
@ -28,28 +28,14 @@ local function OnClick(self, button)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
local function PopoutOnClick(self, button)
|
function ns.Purchase(id, quantity)
|
||||||
local id = self:GetParent():GetID()
|
local _, _, _, _, available = GetMerchantItemInfo(id)
|
||||||
local link = GetMerchantItemLink(id)
|
local max = GetMerchantItemMaxStack(id)
|
||||||
if not link then return end
|
|
||||||
|
|
||||||
local _, _, _, vendorStackSize, numAvailable = GetMerchantItemInfo(id)
|
if available > 0 and available < quantity then quantity = available end
|
||||||
local maxPurchase = GetMerchantItemMaxStack(id)
|
|
||||||
local _, _, _, _, _, _, _, itemStackSize = GetItemInfo(link)
|
|
||||||
|
|
||||||
local size = numAvailable > 0 and numAvailable or itemStackSize
|
|
||||||
OpenStackSplitFrame(250, self, "LEFT", "RIGHT")
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function Purchase(id, quantity)
|
|
||||||
local _, _, _, vendorStackSize, numAvailable = GetMerchantItemInfo(id)
|
|
||||||
local maxPurchase = GetMerchantItemMaxStack(id)
|
|
||||||
|
|
||||||
if numAvailable > 0 and numAvailable < quantity then quantity = numAvailable end
|
|
||||||
local purchased = 0
|
local purchased = 0
|
||||||
while purchased < quantity do
|
while purchased < quantity do
|
||||||
local buyamount = math.min(maxPurchase, quantity - purchased)
|
local buyamount = math.min(max, quantity - purchased)
|
||||||
purchased = purchased + buyamount
|
purchased = purchased + buyamount
|
||||||
BuyMerchantItem(id, buyamount)
|
BuyMerchantItem(id, buyamount)
|
||||||
end
|
end
|
||||||
|
@ -63,12 +49,7 @@ local function BuyItem(self, fullstack)
|
||||||
|
|
||||||
local _, _, _, vendorStackSize = GetMerchantItemInfo(id)
|
local _, _, _, vendorStackSize = GetMerchantItemInfo(id)
|
||||||
local _, _, _, _, _, _, _, itemStackSize = GetItemInfo(link)
|
local _, _, _, _, _, _, _, itemStackSize = GetItemInfo(link)
|
||||||
Purchase(id, fullstack and itemStackSize or vendorStackSize or 1)
|
ns.Purchase(id, fullstack and itemStackSize or vendorStackSize or 1)
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function PopoutSplitStack(self, qty)
|
|
||||||
Purchase(self:GetParent():GetID(), qty)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
@ -141,15 +122,9 @@ function ns.NewMerchantItemFrame(parent)
|
||||||
frame.icon = icon:CreateTexture(nil, "BORDER")
|
frame.icon = icon:CreateTexture(nil, "BORDER")
|
||||||
frame.icon:SetAllPoints()
|
frame.icon:SetAllPoints()
|
||||||
|
|
||||||
local popout = CreateFrame("Button", nil, frame)
|
local popout = ns.NewQtyPopoutFrame(frame)
|
||||||
popout:SetPoint("RIGHT")
|
popout:SetPoint("RIGHT")
|
||||||
popout:SetWidth(HEIGHT/2) popout:SetHeight(HEIGHT)
|
popout:SetSize(HEIGHT/2, HEIGHT)
|
||||||
popout:SetNormalTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-FlyoutButton")
|
|
||||||
popout:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-FlyoutButton")
|
|
||||||
popout:GetNormalTexture():SetTexCoord(0.15625, 0.5, 0.84375, 0.5, 0.15625, 0, 0.84375, 0)
|
|
||||||
popout:GetHighlightTexture():SetTexCoord(0.15625, 1, 0.84375, 1, 0.15625, 0.5, 0.84375, 0.5)
|
|
||||||
popout:SetScript("OnClick", PopoutOnClick)
|
|
||||||
popout.SplitStack = PopoutSplitStack
|
|
||||||
frame.popout = popout
|
frame.popout = popout
|
||||||
|
|
||||||
local ItemPrice = frame:CreateFontString(nil, nil, "NumberFontNormal")
|
local ItemPrice = frame:CreateFontString(nil, nil, "NumberFontNormal")
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
|
||||||
|
local myname, ns = ...
|
||||||
|
|
||||||
|
|
||||||
|
local function OnClick(self, button)
|
||||||
|
local id = self:GetParent():GetID()
|
||||||
|
local link = GetMerchantItemLink(id)
|
||||||
|
if not link then return end
|
||||||
|
|
||||||
|
local _, _, _, vendorStackSize, numAvailable = GetMerchantItemInfo(id)
|
||||||
|
local maxPurchase = GetMerchantItemMaxStack(id)
|
||||||
|
local _, _, _, _, _, _, _, itemStackSize = GetItemInfo(link)
|
||||||
|
|
||||||
|
local size = numAvailable > 0 and numAvailable or itemStackSize
|
||||||
|
OpenStackSplitFrame(250, self, "LEFT", "RIGHT")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
local function PopoutSplitStack(self, qty)
|
||||||
|
ns.Purchase(self:GetParent():GetID(), qty)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
function ns.NewQtyPopoutFrame(parent)
|
||||||
|
local frame = CreateFrame("Button", nil, parent)
|
||||||
|
|
||||||
|
frame:SetNormalTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-FlyoutButton")
|
||||||
|
frame:SetHighlightTexture("Interface\\PaperDollInfoFrame\\UI-GearManager-FlyoutButton")
|
||||||
|
frame:GetNormalTexture():SetTexCoord(0.15625, 0.5, 0.84375, 0.5, 0.15625, 0, 0.84375, 0)
|
||||||
|
frame:GetHighlightTexture():SetTexCoord(0.15625, 1, 0.84375, 1, 0.15625, 0.5, 0.84375, 0.5)
|
||||||
|
|
||||||
|
frame:SetScript("OnClick", OnClick)
|
||||||
|
|
||||||
|
frame.SplitStack = PopoutSplitStack
|
||||||
|
|
||||||
|
return frame
|
||||||
|
end
|
Loading…
Reference in New Issue