WoWInterface SVN BuyEmAll

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 13 to Rev 14
    Reverse comparison

Rev 13 → Rev 14

trunk/BuyEmAll/Localization.koKR.lua New file
0,0 → 1,17
if GetLocale() ~= "koKR" then
return
end
 
local L = BUYEMALL_LOCALS
 
-- Thanks to sayclub
L.MAX = "최대"
L.STACK = "세트"
L.CONFIRM = "정말로 당신은 다음과 같이 구매를 희망하십니까?\n[%d 개 × %s 아이템]"
L.STACK_PURCH = "세트 구입"
L.STACK_SIZE = "세트 수량"
L.PARTIAL = "부분 세트 구입"
L.MAX_PURCH = "최고 구입"
L.FIT = "구입 가능 수량"
L.AFFORD = "현재 자산으로 구입 가능 수량"
L.AVAILABLE = "최대 판매 수량"
trunk/BuyEmAll/BuyEmAll.toc New file
0,0 → 1,13
## Author: Shinisuryu
## Interface: 30100
## Notes: Enhances shift-click interface at vendors
## Title: BuyEmAll 2.8.5 (Beta)
Localization.enUS.lua
Localization.deDE.lua
Localization.frFR.lua
Localization.zhCN.lua
Localization.zhTW.lua
Localization.koKR.lua
BuyEmAll.lua
BuyEmAll.xml
SpaceCalc.lua
trunk/BuyEmAll/SpaceCalc.lua New file
0,0 → 1,51
-- Replacement to Cog's bag space calculation, hand written by Shinisuryu. ( Yes, I'm sure it looks horrible to some of you coders. xD )
 
function SepSpaceCalc(BagID,ItemID)
local ItemGroup = GetItemFamily(ItemID)
local BagName = GetBagName(BagID)
if ItemGroup == GetItemFamily(BagName) or GetItemFamily(BagName) == 0 then
local ItemSlotCanFit = ( select(1,GetContainerNumFreeSlots(BagID)) * select(8,GetItemInfo(ItemID)) )
return ItemSlotCanFit
end
end
 
function GetBagNum()
local NumBag = 0
local Bag1ID = GetInventorySlotInfo("Bag0Slot")
local Bag2ID = GetInventorySlotInfo("Bag1Slot")
local Bag3ID = GetInventorySlotInfo("Bag2Slot")
local Bag4ID = GetInventorySlotInfo("Bag3Slot")
if GetInventoryItemCount("player", Bag1ID) ~= 1 then NumBag = ( NumBag + 1 )
if GetInventoryItemCount("player", Bag2ID) ~= 1 then NumBag = ( NumBag + 1 )
if GetInventoryItemCount("player", Bag3ID) ~= 1 then NumBag = ( NumBag + 1 )
if GetInventoryItemCount("player", Bag4ID) ~= 1 then NumBag = ( NumBag + 1 )
end
end
end
end
return NumBag
end
 
function ItemSpaceCalc(ItemID)
local ItemGroup = GetItemFamily(ItemID)
local StackSize = select(8,GetItemInfo(ItemID))
local TotalItemSpace = 0
local TotalAmmoSpace = 0
local BackpackItemSpace = 0
local NumBags = GetBagNum()
if ItemGroup ~= 1 or ItemGroup ~= 2 then
BackpackItemSpace = ( GetContainerNumFreeSlots(0) * select(8,GetItemInfo(ItemID)) )
end
for BagID = 1, NumBags do
local BagName = GetBagName(BagID)
if GetItemFamily(BagName) == 1 and ItemGroup == 1 or GetItemFamily(BagName) == 2 and ItemGroup == 2 then
TotalAmmoSpace = ( TotalAmmoSpace + SepSpaceCalc(BagID,ItemID) )
-- DEFAULT_CHAT_FRAME:AddMessage("TotalAmmoSpace: " .. TotalAmmoSpace .. ".");
elseif ItemGroup == GetItemFamily(BagName) and ItemGroup ~= 1 and ItemGroup ~= 2 or GetItemFamily(BagName) == 0 and ItemGroup ~= 1 and ItemGroup ~= 2 then
TotalItemSpace = ( TotalItemSpace + SepSpaceCalc(BagID,ItemID) )
-- DEFAULT_CHAT_FRAME:AddMessage("TotalItemSpace: " .. TotalItemSpace .. ".");
end
end
TotalItemSpace = ( TotalItemSpace + BackpackItemSpace )
return TotalItemSpace, TotalAmmoSpace, StackSize
end
\ No newline at end of file
trunk/BuyEmAll/Localization.enUS.lua New file
0,0 → 1,12
BUYEMALL_LOCALS = {
MAX = "Max",
STACK = "Stack",
CONFIRM = "Are you sure you want to buy\n %d × %s?",
STACK_PURCH = "Stack Purchase",
STACK_SIZE = "Stack size",
PARTIAL = "Partial stack",
MAX_PURCH = "Maximum purchase",
FIT = "You can fit",
AFFORD = "You can afford",
AVAILABLE = "Vendor has",
}
trunk/BuyEmAll/Localization.zhTW.lua New file
0,0 → 1,17
if GetLocale() ~= "zhTW" then
return
end
 
local L = BUYEMALL_LOCALS
 
-- Thanks to q09q09
L.MAX = "\230\156\128\229\164\154"
L.STACK = "\228\184\128\231\181\132"
L.CONFIRM = "\230\152\175\229\144\166\231\162\186\229\175\166\232\166\129\232\178\183\n %2$s × %1$d\228\187\182?"
L.STACK_PURCH = "\230\140\137\231\181\132\232\179\188\232\178\183"
L.STACK_SIZE = "\230\175\143\231\181\132\230\149\184\233\135\143"
L.PARTIAL = "\230\149\180\231\181\132\229\183\174\229\128\188"
L.MAX_PURCH = "\230\156\128\229\164\154\232\179\188\232\178\183"
L.FIT = "\232\131\140\229\140\133\230\156\128\229\164\154\229\173\152\230\148\190"
L.AFFORD = "\231\143\190\233\135\145\230\156\128\229\164\167\232\179\188\232\178\183"
L.AVAILABLE = "\229\149\134\228\186\186\229\173\152\232\178\168\230\149\184\233\135\143"
trunk/BuyEmAll/Localization.frFR.lua New file
0,0 → 1,17
if GetLocale() ~= "frFR" then
return
end
 
local L = BUYEMALL_LOCALS
 
-- Thanks to Layrajha
-- L.MAX = "Max"
L.STACK = "Pile"
L.CONFIRM = "Voulez-vous vraiment acheter\n %d × %s?"
-- L.STACK_PURCH = "Stack Purchase"
L.STACK_SIZE = "Taille de pile"
-- L.PARTIAL = "Partial stack"
L.MAX_PURCH = "Achat maximum"
L.FIT = "Vous pouvez transporter"
L.AFFORD = "Vous pouvez payer"
L.AVAILABLE = "Le marchand a"
trunk/BuyEmAll/Localization.xxXX.lua New file
0,0 → 1,17
-- Please PM me on WoWInterface with any localization updates.
if GetLocale() ~= "xxXX" then
return
end
 
local L = BUYEMALL_LOCALS
 
--L.MAX = "Max"
--L.STACK = "Stack"
--L.CONFIRM = "Are you sure you want to buy\n %d × %s?"
--L.STACK_PURCH = "Stack Purchase"
--L.STACK_SIZE = "Stack size"
--L.PARTIAL = "Partial stack"
--L.MAX_PURCH = "Maximum purchase"
--L.FIT = "You can fit"
--L.AFFORD = "You can afford"
--L.AVAILABLE = "Vendor has"
\ No newline at end of file
trunk/BuyEmAll/Localization.deDE.lua New file
0,0 → 1,17
if GetLocale() ~= "deDE" then
return
end
 
local L = BUYEMALL_LOCALS
 
-- Thanks to JokerGermany
-- L.MAX = "Max"
-- L.STACK = "Stack"
L.CONFIRM = "Bist du sicher das du\n %d × %s kaufen willst?"
-- L.STACK_PURCH = "Stack Purchase"
L.STACK_SIZE = "Stack größe"
-- L.PARTIAL = "Partial stack"
L.MAX_PURCH = "Größt möglcher Einkauf"
L.FIT = "Du hast Platz für"
L.AFFORD = "Du kannst dir leisten"
L.AVAILABLE = "Der Verkäufer hat"
trunk/BuyEmAll/BuyEmAll.xml New file
0,0 → 1,174
<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/
..\UI.xsd">
<!-- Template for the Okay and Cancel buttons -->
<Button name="BuyEmAllButtonTemplate" inherits="UIPanelButtonTemplate" virtual="true">
<Size x="64" y="24"/>
<Scripts>
<OnClick>
BuyEmAll:OnClick(self)
</OnClick>
</Scripts>
</Button>
 
<!-- Template for the max and stack buttons -->
<Button name="BuyEmAllTooltipButtonTemplate" inherits="BuyEmAllButtonTemplate" virtual="true">
<Scripts>
<OnEnter>
BuyEmAll:OnEnter(self)
</OnEnter>
<OnLeave>
BuyEmAll:OnLeave()
</OnLeave>
</Scripts>
</Button>
 
<Frame name="BuyEmAllFrame" frameStrata="HIGH" parent="UIParent" toplevel="true" enableMouse="true" enableKeyboard="true" hidden="true">
<Size x="172" y="134"/>
<Layers>
<Layer level="BACKGROUND">
<!-- The top border of the money frame. -->
<Texture name="$parentTopTex" file="Interface\MoneyFrame\UI-MoneyFrame2">
<Size x="172" y="14"/>
<Anchors>
<Anchor point="TOP"/>
</Anchors>
<TexCoords left="0" right="0.671875" top="0" bottom=".109375"/>
</Texture>
 
<!-- The bottom border -->
<Texture name="$parentBottomTex" file="Interface\MoneyFrame\UI-MoneyFrame2">
<Size x="172" y="20"/>
<Anchors>
<Anchor point="BOTTOM"/>
</Anchors>
<TexCoords left="0" right="0.671875" top=".59375" bottom=".75"/>
</Texture>
 
<!-- The background behind the buttons -->
<Texture name="$parentBackTex" file="Interface\MoneyFrame\UI-MoneyFrame2">
<Anchors>
<Anchor point="TOPLEFT" relativePoint="BOTTOMLEFT" relativeTo="$parentTopTex"/>
<Anchor point="BOTTOMRIGHT" relativePoint="TOPRIGHT" relativeTo="$parentBottomTex"/>
</Anchors>
<TexCoords left="0" right="0.671875" top=".109375" bottom=".59375"/>
</Texture>
</Layer>
<Layer level="BORDER">
<!-- The actual box where the amount you will be buying goes -->
<Texture name="$parentMoneyTex" file="Interface\MoneyFrame\UI-MoneyFrame">
<Size x="121" y="33"/>
<Anchors>
<Anchor point="TOP">
<Offset x="1" y="-14"/>
</Anchor>
</Anchors>
<TexCoords left=".10546875" right="0.578125" top=".109375" bottom=".3671875"/>
</Texture>
 
<!-- This is the number that goes inside $parentMoneyTex -->
<FontString name="BuyEmAllText" inherits="GameFontHighlight" justifyH="RIGHT">
<Anchors>
<Anchor point="RIGHT" relativeTo="$parentMoneyTex">
<Offset x="-12" y="2"/>
</Anchor>
</Anchors>
</FontString>
</Layer>
</Layers>
<Frames>
<!-- These are the left and right arrows used for changing the amount -->
<Button name="BuyEmAllLeftButton">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="TOPRIGHT" relativePoint="TOP" relativeTo="$parentMoneyTex">
<Offset x="-60" y="-8"/>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
BuyEmAll:Left_Click()
</OnClick>
</Scripts>
<NormalTexture file="Interface\MoneyFrame\Arrow-Left-Up"/>
<PushedTexture file="Interface\MoneyFrame\Arrow-Left-Down"/>
<DisabledTexture file="Interface\MoneyFrame\Arrow-Left-Disabled"/>
</Button>
<Button name="BuyEmAllRightButton">
<Size x="16" y="16"/>
<Anchors>
<Anchor point="TOPLEFT" relativePoint="TOP" relativeTo="$parentMoneyTex">
<Offset x="63" y="-8"/>
</Anchor>
</Anchors>
<Scripts>
<OnClick>
BuyEmAll:Right_Click()
</OnClick>
</Scripts>
<NormalTexture file="Interface\MoneyFrame\Arrow-Right-Up"/>
<PushedTexture file="Interface\MoneyFrame\Arrow-Right-Down"/>
<DisabledTexture file="Interface\MoneyFrame\Arrow-Right-Disabled"/>
</Button>
 
<!-- The money frame where the cost of the purchase is displayed -->
<Frame name="BuyEmAllMoneyFrame" inherits="SmallMoneyFrameTemplate">
<Size x="120" y="24"/>
<Anchors>
<Anchor point="TOP" relativePoint="BOTTOM" relativeTo="$parentMoneyTex">
<Offset x="7" y="2"/>
</Anchor>
</Anchors>
<Scripts>
<OnLoad>
BuyEmAll:MoneyFrame_OnLoad(self)
</OnLoad>
</Scripts>
</Frame>
 
<Button name="BuyEmAllOkayButton" inherits="BuyEmAllButtonTemplate" text="OKAY">
<Anchors>
<Anchor point="RIGHT" relativePoint="BOTTOM">
<Offset x="-3" y="30"/>
</Anchor>
</Anchors>
</Button>
<Button name="BuyEmAllCancelButton" inherits="BuyEmAllButtonTemplate" text="CANCEL">
<Anchors>
<Anchor point="LEFT" relativePoint="BOTTOM">
<Offset x="5" y="30"/>
</Anchor>
</Anchors>
</Button>
 
<!-- The Max and Stack buttons -->
<Button name="BuyEmAllStackButton" inherits="BuyEmAllTooltipButtonTemplate" text="BUYEMALL_STACK">
<Anchors>
<Anchor point="BOTTOM" relativePoint="TOP" relativeTo="BuyEmAllOkayButton">
<Offset x="0" y="2"/>
</Anchor>
</Anchors>
</Button>
<Button name="BuyEmAllMaxButton" inherits="BuyEmAllTooltipButtonTemplate" text="BUYEMALL_MAX">
<Anchors>
<Anchor point="BOTTOM" relativePoint="TOP" relativeTo="BuyEmAllCancelButton">
<Offset x="0" y="2"/>
</Anchor>
</Anchors>
</Button>
</Frames>
<Scripts>
<OnLoad>
BuyEmAll:OnLoad()
</OnLoad>
<OnHide>
BuyEmAll:OnHide()
</OnHide>
<OnChar>
BuyEmAll:OnChar(text)
</OnChar>
<OnKeyDown>
BuyEmAll:OnKeyDown(key)
</OnKeyDown>
</Scripts>
</Frame>
</Ui>
trunk/BuyEmAll/Localization.zhCN.lua New file
0,0 → 1,17
if GetLocale() ~= "zhCN" then
return
end
 
local L = BUYEMALL_LOCALS
 
-- Thanks to q09q09
L.MAX = "\230\156\128\229\164\154"
L.STACK = "\228\184\128\231\187\132"
L.CONFIRM = "\230\152\175\229\144\166\231\161\174\229\174\158\232\166\129\228\185\176\n %2$s × %1$d\228\187\182?"
L.STACK_PURCH = "\230\140\137\231\187\132\232\180\173\228\185\176"
L.STACK_SIZE = "\230\175\143\231\187\132\230\149\176\233\135\143"
L.PARTIAL = "\230\149\180\231\187\132\229\183\174\229\128\188"
L.MAX_PURCH = "\230\156\128\229\164\154\232\180\173\228\185\176"
L.FIT = "\232\131\140\229\140\133\230\156\128\229\164\154\229\173\152\230\148\190"
L.AFFORD = "\231\142\176\233\135\145\230\156\128\229\164\167\232\180\173\228\185\176"
L.AVAILABLE = "\229\149\134\228\186\186\229\173\152\232\180\167\230\149\176\233\135\143"
trunk/BuyEmAll/BuyEmAll.lua New file
0,0 → 1,454
-- BuyEmAll - Originally created and developed by Cogwheel up to version 2.8.4, now developed by Shinisuryu.
BuyEmAll = {}
 
local L = BUYEMALL_LOCALS
 
-- These are used for the text on the Max and Stack buttons. See BuyEmAll.xml.
BUYEMALL_MAX = L.MAX
BUYEMALL_STACK = L.STACK
 
--[[
It's ALIVE!!! Muahahahahhahahaa!!!!!!
]]
function BuyEmAll:OnLoad()
-- Set up confirmation dialog
StaticPopupDialogs["BUYEMALL_CONFIRM"] = {
text = L.CONFIRM,
button1 = YES,
button2 = NO,
OnAccept = function(dialog) self:DoPurchase(dialog.data) end,
timeout = 0,
hideOnEscape = true,
}
 
self.OrigMerchantItemButton_OnModifiedClick = MerchantItemButton_OnModifiedClick
MerchantItemButton_OnModifiedClick = function(...)
self:MerchantItemButton_OnModifiedClick(this, ...)
end
 
self.OrigMerchantFrame_OnHide = MerchantFrame:GetScript("OnHide")
MerchantFrame:SetScript("OnHide", function(...)
return self:MerchantFrame_OnHide(...)
end)
end
 
 
 
 
function BuyEmAll:MoneyFrame_OnLoad(frame)
-- Set up money frame
MoneyTypeInfo["BUYEMALL"] = {
UpdateFunc = function() return 0 end, -- Stub to satisfy MoneyFrame_SetType
showSmallerCoins = "Backpack",
fixedWidth = 1,
collapse = 1,
}
BuyEmAllMoneyFrame.small = 1
MoneyFrame_SetType(frame, "BUYEMALL")
end
 
 
 
 
--[[
Makes sure the BuyEmAll frame goes away when you leave a vendor
]]
function BuyEmAll:MerchantFrame_OnHide(...)
BuyEmAllFrame:Hide()
return self.OrigMerchantFrame_OnHide(...)
end
 
 
 
 
--[[
Hooks left-clicks on merchant item buttons
]]
function BuyEmAll:MerchantItemButton_OnModifiedClick(frame, button, ...)
if MerchantFrame.selectedTab == 1
and IsShiftKeyDown()
and not IsControlKeyDown()
and not (ChatFrameEditBox:IsVisible() and button == "LeftButton") then
 
-- Set up various data before showing the BuyEmAll frame
self.itemIndex = frame:GetID()
 
local name, texture, price, quantity, numAvailable =
GetMerchantItemInfo(self.itemIndex)
self.preset = quantity
self.price = price
self.itemName = name
self.available = numAvailable
 
local bagMax, specialMax, stack =
ItemSpaceCalc(tonumber(strmatch(GetMerchantItemLink(self.itemIndex), "item:(%d+):")))
self.stack = stack
self.fit = floor(bagMax / quantity) * quantity + specialMax
self.afford = floor(GetMoney() / price) * quantity
self.max = min(self.fit, self.afford)
if numAvailable > -1 then
self.max = min(self.max, numAvailable * quantity)
end
if self.max == 0 or not name then
return
elseif self.max == 1 then
MerchantItemButton_OnClick("LeftButton", 1)
return
end
 
specialMax = floor(specialMax / quantity) * quantity
self.defaultStack =
specialMax > 0 and specialMax <= self.max and specialMax or quantity
 
self.split = self.defaultStack
 
self.partialFit = self.fit % stack
self:SetStackClick()
 
self:Show(frame)
else
self.OrigMerchantItemButton_OnModifiedClick(frame, button, ...)
end
end
 
 
 
 
--[[
Prepare the various UI elements of the BuyEmAll frame and show it
]]
function BuyEmAll:Show(frame)
self.typing = 0
BuyEmAllLeftButton:Disable()
BuyEmAllRightButton:Enable()
 
BuyEmAllStackButton:Enable()
if self.max < self.stackClick then
BuyEmAllStackButton:Disable()
end
 
BuyEmAllFrame:ClearAllPoints()
BuyEmAllFrame:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 0)
 
BuyEmAllFrame:Show(frame)
self:UpdateDisplay()
end
 
 
 
 
--[[
If the amount is more than stack and defaultStack, show a confirmation.
Otherwise, do the purchase
]]
function BuyEmAll:VerifyPurchase(amount)
amount = amount or self.split
if (amount > 0) then
amount = ceil(amount/self.preset) * self.preset
if amount > self.stack and amount > self.defaultStack then
self:DoConfirmation(amount)
else
self:DoPurchase(amount)
end
end
end
 
 
 
 
--[[
Makes the actual purchase(s)
amount must be a multiple of the preset stack size if preset stack size > 1
]]
function BuyEmAll:DoPurchase(amount)
BuyEmAllFrame:Hide()
 
local numLoops, purchAmount, leftover
 
if self.preset > 1 then
numLoops = amount/self.preset
purchAmount = 1
leftover = 0
else
numLoops = floor(amount/self.stack)
purchAmount = self.stack
leftover = amount % self.stack
end
 
for i = 1, numLoops do
BuyMerchantItem(self.itemIndex, purchAmount)
end
 
if leftover > 0 then BuyMerchantItem(self.itemIndex, leftover) end
end
 
 
 
 
 
--[[
Changes the money display to however much amount of the item will cost. If
amount is not specified, it uses the current split value.
]]
function BuyEmAll:UpdateDisplay()
local purchase = ceil(self.split / self.preset)
local cost = purchase * self.price
MoneyFrame_Update("BuyEmAllMoneyFrame", cost)
BuyEmAllText:SetText(self.split)
 
BuyEmAllLeftButton:Enable()
BuyEmAllRightButton:Enable()
if self.split == self.max then
BuyEmAllRightButton:Disable()
elseif self.split <= self.preset then
BuyEmAllLeftButton:Disable()
end
 
self:SetStackClick()
BuyEmAllStackButton:Enable()
if self.max < self.stackClick then
BuyEmAllStackButton:Disable()
end
end
 
 
 
 
--[[
Shows the confirmation dialog
]]
function BuyEmAll:DoConfirmation(amount)
local dialog = StaticPopup_Show("BUYEMALL_CONFIRM", amount, self.itemName)
dialog.data = amount
end
 
 
 
 
--[[
Calculates the amount that the Stack button will enter
]]
function BuyEmAll:SetStackClick()
local increase = (self.partialFit == 0 and self.stack or self.partialFit) - (self.split % self.stack)
self.stackClick = self.split + (increase == 0 and self.stack or increase)
end
 
 
 
 
--[[
OnClick handler for the four main buttons
]]
function BuyEmAll:OnClick(frame)
if frame == BuyEmAllOkayButton then
self:VerifyPurchase()
elseif frame == BuyEmAllCancelButton then
BuyEmAllFrame:Hide()
elseif frame == BuyEmAllStackButton then
self.split = self.stackClick
self:UpdateDisplay()
if frame:IsEnabled() == 1 then
self:OnEnter(frame)
else
GameTooltip:Hide()
end
elseif frame == BuyEmAllMaxButton then
self.split = self.max
self:UpdateDisplay()
end
end
 
 
 
 
--[[
Allows you to type a number to buy. This is adapted directly from the Default
UI's code.
]]
function BuyEmAll:OnChar(text)
if text < "0" or text > "9" then
return
end
 
if self.typing == 0 then
self.typing = 1
self.split = 0
end
 
local split = (self.split * 10) + text
if split == self.split then
if self.split == 0 then
self.split = 1
end
 
self:UpdateDisplay()
return
end
 
if split <= self.max then
self.split = split
elseif split == 0 then
self.split = 1
end
self:UpdateDisplay()
end
 
 
 
 
--[[
Key handler for keys other than 0-9
]]
function BuyEmAll:OnKeyDown(key)
if key == "BACKSPACE" or key == "DELETE" then
if self.typing == 0 or self.split == 1 then
return
end
 
self.split = floor(self.split / 10)
if self.split <= 1 then
self.split = 1
self.typing = 0
end
 
self:UpdateDisplay()
elseif key == "ENTER" then
self:VerifyPurchase()
elseif key == "ESCAPE" then
BuyEmAllFrame:Hide()
elseif key == "LEFT" or key == "DOWN" then
BuyEmAll:Left_Click()
elseif key == "RIGHT" or key == "UP" then
BuyEmAll:Right_Click()
end
end
 
 
 
 
--[[
Decreases the amount by however much is necessary to go down to the next
lowest multiple of the preset stack size.
]]
function BuyEmAll:Left_Click()
if self.split <= self.preset then
return
end
 
local decrease = self.split % self.preset
decrease = decrease == 0 and self.preset or decrease
 
self.split = self.split - decrease
 
self:UpdateDisplay()
end
 
 
 
 
--[[
Increases the amount by however much is necessary to go up to the next highest
multiple of the preset stack size.
]]
function BuyEmAll:Right_Click()
local increase = self.preset - (self.split % self.preset)
 
if self.split + increase > self.max then
return
end
 
self.split = self.split + increase
 
self:UpdateDisplay()
end
 
 
 
 
--[[
This table is used for the two functions that follow
]]
BuyEmAll.lines = {
stack = {
label = L.STACK_PURCH,
field = "stackClick",
{ label = L.STACK_SIZE, field = "stack" },
{ label = L.PARTIAL, field = "partialFit" },
},
max = {
label = L.MAX_PURCH,
field = "max",
{ label = L.AFFORD, field = "afford" },
{ label = L.FIT, field = "fit" },
{
label = L.AVAILABLE,
field = "available",
Hide = function()
return BuyEmAll.available <= 1
end
},
},
}
 
 
 
 
--[[
Shows tooltips when you hover over the Stack or Max buttons
]]
function BuyEmAll:OnEnter(frame)
local lines = self.lines[frame == BuyEmAllMaxButton and "max" or "stack"]
 
lines.amount = self[lines.field]
for i, line in ipairs(lines) do
line.amount = self[line.field]
end
 
self:CreateTooltip(frame, lines)
end
 
 
 
 
--[[
Creates the tooltip from the given lines table. See the structure of lines above for
more insight.
]]
function BuyEmAll:CreateTooltip(frame, lines)
GameTooltip:SetOwner(frame, "ANCHOR_BOTTOMRIGHT")
GameTooltip:SetText(lines.label.."|cFFFFFFFF - |r"..GREEN_FONT_COLOR_CODE..lines.amount.."|r")
 
for _, line in ipairs(lines) do
if not (line.Hide and line.Hide()) then
local color =
line.amount == lines.amount and GREEN_FONT_COLOR or HIGHLIGHT_FONT_COLOR
GameTooltip:AddDoubleLine(line.label, line.amount, 1,1,1, color.r,color.g,color.b)
end
end
 
SetTooltipMoney(GameTooltip, ceil(lines.amount / self.preset) * self.price)
 
GameTooltip:Show()
end
 
 
 
 
--[[
Hides the tooltip
]]
function BuyEmAll:OnLeave()
GameTooltip:Hide()
GameTooltip_ClearMoney(GameTooltip)
end
 
 
 
 
--[[
When the BuyEmAll frame is closed, close any confirmations waiting for a
response.
]]
function BuyEmAll:OnHide()
StaticPopup_Hide("BUYEMALL_CONFIRM")
end