/
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 = "ìµë í매 ìë" |
## Interface: 20003 |
## Title: BuyEmAll |
## Author: Cogwheel |
## Url: http://cogwheel.wowinterface.com |
## eMail: mcogwheel@gmail.com |
## Notes: Enhances shift-click interface at vendors |
## OptionalDeps: CogsBagSpace |
CogsBagSpace\CogsBagSpace.lua |
Localization.enUS.lua |
Localization.deDE.lua |
Localization.frFR.lua |
Localization.zhCN.lua |
Localization.zhTW.lua |
Localization.koKR.lua |
BuyEmAll.lua |
BuyEmAll.xml |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
<html xmlns="http://www.w3.org/1999/xhtml"> |
<head> |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
<title>BuyEmAll Readme</title> |
<style type="text/css"> |
h2,h3 { border-bottom: 1px solid; } |
a:visited:after { content: "Â â"; } |
p.notice { |
font-size: smaller; |
color: #999; |
margin-left: 0; |
} |
ol.footnotes { |
font-size: small; |
} |
.item { |
font-size: small; |
font-family: Arial, Helvetica, sans-serif; |
border: solid 1px; |
border-top-color: #FFF; |
border-left-color: #888; |
border-right-color: #888; |
border-bottom-color: #555; |
-moz-border-radius: 4px; |
background-color: #000; |
color: #FFF; |
padding: 2px; |
} |
.poor { color: gray; } |
.common { color: white; } |
.uncommon { color: #1EFF00; } |
.rare { color: #0080FF; } |
.epic { color: #B048F8; } |
.legendary { color: #F07902; } |
.artifact { color: #FFCF00; } |
@media screen { |
body { |
font-family: "Trebuchet MS", Helvetica, Verdana, Arial, sans-serif; |
color: #FFF; |
background: #333; |
width: 80%; |
min-width: 600px; |
padding-left: 30px; |
} |
h1,h2,h3,h4,h5,h6 { |
font-family: Georgia, "Times New Roman", Times, serif; |
color: #ED0; |
} |
h1,h2,h3,h5,h6 { |
font-family: Georgia, "Times New Roman", Times, serif; |
} |
h2,h3 { border-bottom-color: #ED0; } |
p,h3,h4,h5,h6 { margin-left: 30px; } |
a:link { |
color: #FC0; |
text-decoration: none; |
} |
a:visited { |
color: #999; |
text-decoration: none; |
} |
a:hover { |
color: #0F0; |
} |
a:active { |
color: #0F0; |
} |
.gold { color: #ED0; } |
.silver { color: #BBB; } |
.copper { color: #D63; } |
} |
@media print { |
body { |
font-family: "Times New Roman", Times, serif; |
} |
h1,h2,h3,h4,h5,h6 { |
font-family: Arial, Helvetica, sans-serif; |
} |
} |
</style> |
</head> |
<body> |
<h1>BuyEmAll</h1> |
<p>By Cogwheel â v2.8</p> |
<p>BuyEmAll enhances the shift-click interface at vendors.</p> |
<p>Please visit <a href="http://cogwheel.wowinterface.com">Cogwheelâs Workshop</a> for updates, bug reports, feature requests, etc. </p> |
<ul> |
<li><a href="#features">Features</a> |
<ul> |
<li><a href="#type">Type in the amount you want to buy</a></li> |
<li><a href="#buymore">Buy more than the stack size of the item at once</a></li> |
<li><a href="#preset">Shift-click items that come in preset stacks</a></li> |
<li><a href="#spending">Know how much you will be spending</a></li> |
<li><a href="#maxstack">Quickly fill stacks or buy as much as you can</a></li> |
<li><a href="#ammo">Quickly refill your ammo pouch</a></li> |
</ul> |
</li> |
<li><a href="#notes">Notes</a> |
<ul> |
<li><a href="#maxnote">Maximum Purchase</a></li> |
<li><a href="#presetnote">Preset Stacks</a> </li> |
<li><a href="#bullets">Bullets/Arrows</a></li> |
</ul> |
</li> |
<li><a href="#bugs">Bugs/Improvements</a></li> |
<li><a href="#changes">Changes</a></li> |
</ul> |
<h2><a name="features" id="features"></a>Features</h2> |
<h4><a name="type" id="type"></a>Type in the amount you want to buy</h4> |
<p>This is actually part of the default UI. Enough people donât know about it due to the fact that there is no cursor and clicking in the box gives no feedback, that I decided to list it here.</p> |
<h4> <a name="buymore" id="buymore"></a>Buy more than the stack size of the item at once </h4> |
<p>For instance, if you want to buy 80 pieces of <span class="item common">Silk Thread</span>, you currently have to shift-click the thread, enter 20, hit <kbd>Okay</kbd>, shift-click the thread, enter 20, hit <kbd>Okay</kbd>, shift-click the thread, enter 20, hit <kbd>Okay</kbd>, shift-click the thread, enter 20, and hit <kbd>Okay</kbd>.</p> |
<p>With BuyEmAll, you shift-click the thread, enter 80, hit <kbd>Okay</kbd>, and confirm that you want to buy more than a stack. This confirmation appears so you donât accidentally buy 1000 of something when you meant to buy 100.</p> |
<h4> <a name="preset" id="preset"></a>Shift-click items that come in preset stacks </h4> |
<p>The default UI doesnât allow you to shift-click items like <span class="item common">Refreshing Spring Water</span> which come in preset stacks. If you want to buy 50 of them, you have to right-click the item 10 times. BuyEmAll allows you to shift-click the item and enter the amount you want. See <a href="#notes">Notes</a> for more information on preset stacks.</p> |
<h4> <a name="spending" id="spending"></a>Know how much you will be spending </h4> |
<p>Below the box where you enter the amount is a money display. This updates as you change the amount you are going to buy, showing you exactly how much your purchase will cost.</p> |
<h4> <a name="maxstack" id="maxstack"></a>Quickly fill stacks or buy as much as you can </h4> |
<p>The BuyEmAll window has <kbd>Stack</kbd> and <kbd>Max</kbd> buttons which allow you to enter a full stack or as much as you can afford/fit. Hovering over the buttons shows a tooltip with the number of items you will be buying and how much it will cost. See <a href="#notes">Notes</a> for information on the maximum you can buy.</p> |
<p>If you already have some of an item, the first click of the <kbd>Stack</kbd> button will enter the amount you need to fill that stack. Subsequent clicks will add full stacks to your pruchase.</p> |
<h4> <a name="ammo" id="ammo"></a>Quickly refill your ammo pouch </h4> |
<p>If you are buying ammo and have free spots in your ammo pouch/quiver, the amount that appears when you first shift-click the ammo will be however many stacks it takes to refill your bag. Just hit <kbd>Enter/Return</kbd>, and you bag will be filled.</p> |
<h2><a name="notes" id="notes"></a>Notes </h2> |
<h3><a name="maxnote" id="maxnote"></a>Maximum Purchase </h3> |
<p>The amount you can enter is limited by:</p> |
<ul> |
<li> The amount of free space in your bags. Partial stacks are included in this calculation, as are specialty bags (e.g. free slots in enchanting bags will be only be counted towards your free space if you are buying an essence, dust, or shard).</li> |
<li> The amount you can afford.</li> |
<li>The amount available from the vendor (for limited stock items).</li> |
</ul> |
<p>A breakdown of these numbers is included in the<kbd> Max </kbd>buttonâs tooltip.</p> |
<p>If you can only buy one item for any of these reasons, shift-click behaves just like a left click, picking up one of the item onto your cursor. If you canât buy any, then shift-click does nothing.</p> |
<h3><a name="presetnote" id="presetnote"></a>Preset Stacks </h3> |
<p>When you are choosing the amount for items that come prestacked, the amount you enter is the total amount you want to buy, not the number of stacks you want to buy. If you use the arrow buttons, this number will increase or decrease to multiples of the preset stack size.</p> |
<p>The confirmation window will only show up if you buy more than the maximum stack size in your inventory, not the stack size that you can buy at once.</p> |
<h4>Example</h4> |
<p><span class="item common">Refreshing Spring Water</span> â Stack Size: 20, Preset Stack: 5</p> |
<p>If you enter 18 and hit <kbd>Okay</kbd>, it will automatically buy 20 with no confirmation. If you enter 23, a confirmation will pop up asking, âAre you sure you want to buy 25 of this item?â</p> |
<h2><a name="bugs" id="bugs"></a>Bugs/Improvements</h2> |
<p>German, French, & Chinese localizations are missing some recently added translations.</p> |
<p>Please visit <a href="http://cogwheel.wowinterface.com">Cogwheelâs Workshop</a> if you have any suggestions or bug reports, and to see what is in store for the future.</p> |
<h2><a name="changes" id="changes"></a>Changes</h2> |
<h4>v2.8</h4> |
<ul> |
<li>Cost of Stack or Max purchase now shown in the buttonâs tooltip instead of changing the money display.</li> |
<li>No longer displays âloadedâ message.</li> |
<li>Separated localization files for more flexibility.</li> |
</ul> |
<h4>v2.7</h4> |
<ul> |
<li>Updated for 2.0.3.</li> |
</ul> |
<h4>v2.6.3</h4> |
<ul> |
<li>Fixed ammo pouch bug.</li> |
</ul> |
<h4>v2.6.2</h4> |
<ul> |
<li>Added workaround for ammo pouch bug.</li> |
</ul> |
<h4>v2.6.1</h4> |
<ul> |
<li>Added Korean localization thanks to sayclub. </li> |
</ul> |
<h4>v2.6</h4> |
<ul> |
<li>Updated for WoW 2.0. </li> |
</ul> |
<h4>v2.5</h4> |
<ul> |
<li>Fixed a bug where the amount you could afford was shown as the amount you could fit and vise versa. </li> |
<li><kbd>Stack</kbd> button now works a bit more intuitively for items which come in preset stacks.</li> |
<li>De-aced.<sup><a href="#1">1</a></sup></li> |
</ul> |
<h4>v2.2</h4> |
<ul> |
<li> Changed behavior of <kbd>Stack</kbd> button (see <a href="#maxstack">Features</a>).</li> |
<li> Improved efficiency in certain areas.</li> |
</ul> |
<h4>v2.1.2</h4> |
<ul> |
<li> Fixed a bug that caused an error for people with enchanting or herbalism bags</li> |
<li> Updated Ace2 libraries.</li> |
</ul> |
<h4>v2.1.1</h4> |
<ul> |
<li> Updated TOC for patch 1.12.</li> |
<li>Updated Ace2 libraries.</li> |
</ul> |
<h4>v2.1</h4> |
<ul> |
<li>Slightly rearranged the buttons to have a bit more space in between.</li> |
<li>Clicking on the <kbd>Max</kbd> and <kbd>Stack</kbd> buttons will now change the amount in the box instead of immediately bringing up the confirmation window.</li> |
<li><kbd>Stack</kbd> button will now be disabled for items whose stack size is the same as their purchase unit (ammunition, for instance).</li> |
</ul> |
<h4>v2.0</h4> |
<ul> |
<li> <kbd>Stack</kbd> button will now be disabled for items that do not stack.</li> |
<li>Ace2ified. Functionality is the same except for the above patch change, but behind the scenes itâs a whole new beast.</li> |
</ul> |
<h4>v1.12.1</h4> |
<ul> |
<li> Disabled display of the âVendor hasâ line of the <kbd>Max</kbd> buttonâs tooltip if there is no limit.</li> |
<li>Changed coloring of tooltip text.</li> |
<li>French translation courtesy of Layrajha.</li> |
<li>Chinese translation thanks to q09q09.</li> |
</ul> |
<h4>v1.12</h4> |
<ul> |
<li> <kbd>Stack</kbd> and <kbd>Max</kbd> buttons display a confirmation regardless of purchase size to alleviate accidental clicks.</li> |
<li>The BuyEmAll frame will not hide until you accept the confirmation or if there is no confirmation.</li> |
<li>Fixed a bug where you could attempt to buy an item a vendor no longer has.</li> |
<li>German translation courtesy of JokerGermany.</li> |
<li>Changed the text on <kbd>Max</kbd> and <kbd>Stack</kbd> buttonsâ tooltips.</li> |
<li>Corrected a few typos in this readme.</li> |
</ul> |
<h4>v1.11.1</h4> |
<ul> |
<li> Remembered to turn off debugging mode. :P</li> |
<li>Changed the way the window is rendered such that I donât have to include a texture file.</li> |
</ul> |
<h4>v1.11</h4> |
<ul> |
<li> Changed cost display for better visual integration with WoW.</li> |
<li>Removed display of maximum purchase from the frame.</li> |
<li>Added <kbd>Max</kbd> button.</li> |
<li><kbd>Max</kbd> and <kbd>Stack</kbd> buttons update the cost display when you mouse over them.</li> |
<li>Added tooltips to the <kbd>Max</kbd> and <kbd>Stack</kbd> buttons.</li> |
<li>The <kbd>Stack</kbd> button is disabled if you cannot buy a stack.</li> |
</ul> |
<h4>v1.10</h4> |
<ul> |
<li> Added display of total purchase cost.</li> |
<li>Added <kbd>Stack</kbd> button.</li> |
<li>The confirmation box no longer appears when filling an ammo pouch.</li> |
<li>Fixed bug where default stack for ammo could be more than you could afford. </li> |
<li>Added a line break in the confirmation window to make it easier to read.</li> |
</ul> |
<h4>v1.9</h4> |
<ul> |
<li> Free space calculation now takes into account special bag types.</li> |
<li> Added quick-fill feature for ammo pouches/quivers.</li> |
</ul> |
<h4>v1.8</h4> |
<ul> |
<li> The Stack Split frame now shows you the maximum amount you will be able to purchase.</li> |
<li> For preset stack items, the left and right arrows increase or decrease to multiples of the preset stack size.</li> |
</ul> |
<h4>v1.5</h4> |
<ul> |
<li> Added support for items that come in preset stacks and items that donât stack at all.<br /> |
Limited the maximum you can attempt to buy as described above.</li> |
</ul> |
<h4>v1.0</h4> |
<ul> |
<li> Initial Release</li> |
</ul> |
<h4>Footnotes</h4> |
<ol class="footnotes"> |
<li><a name="1" id="1"></a>This change was made for a number of reasons, not the least of which are load time and download size. On a more selfish note, Iâm tired of dealing with âbugâ reports that are actually caused by other addons using Ace2 that show my addonâs path since it's had a fresh version each release. :)</li> |
</ol> |
</body> |
</html> |
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", |
} |
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 \195\151 %1$d\228\187\182?" |
-- L.STACK_PURCH = "Stack Purchase" |
L.STACK_SIZE = "\229\160\134\231\150\138\229\164\167\229\176\143" |
-- L.PARTIAL = "Partial stack" |
L.MAX_PURCH = "\230\156\128\229\164\154\232\131\189\232\179\188\232\178\183" |
L.FIT = "\232\131\189\229\164\160\232\178\183" |
L.AFFORD = "\232\131\189\232\178\183\229\190\151\232\181\183" |
L.AVAILABLE = "\229\149\134\229\186\151\230\156\137" |
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" |
-- Please e-mail localization files to mcogwheel@gmail.com |
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" |
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" |
<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() |
</OnClick> |
</Scripts> |
</Button> |
<!-- Template for the max and stack buttons --> |
<Button name="BuyEmAllTooltipButtonTemplate" inherits="BuyEmAllButtonTemplate" virtual="true"> |
<Scripts> |
<OnEnter> |
BuyEmAll:OnEnter() |
</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() |
</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() |
</OnChar> |
<OnKeyDown> |
BuyEmAll:OnKeyDown() |
</OnKeyDown> |
</Scripts> |
</Frame> |
</Ui> |
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 \195\151 %1$d\228\187\182?" |
-- L.STACK_PURCH = "Stack Purchase", |
L.STACK_SIZE = "\229\160\134\229\143\160\229\164\167\229\176\143" |
-- L.PARTIAL = "Partial stack", |
L.MAX_PURCH = "\230\156\128\229\164\154\232\131\189\232\180\173\228\185\176" |
L.FIT = "\232\131\189\229\164\159\228\185\176" |
L.AFFORD = "\232\131\189\228\185\176\229\190\151\232\181\183" |
L.AVAILABLE = "\229\149\134\229\186\151\230\156\137" |
-- BuyEmAll - By Cogwheel. |
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(amount) self:DoPurchase(amount) end, |
timeout = 0, |
hideOnEscape = true, |
} |
self.OrigMerchantItemButton_OnModifiedClick = MerchantItemButton_OnModifiedClick |
MerchantItemButton_OnModifiedClick = function(button, ...) |
return self:MerchantItemButton_OnModifiedClick(button, ...) |
end |
self.OrigMerchantFrame_OnHide = MerchantFrame:GetScript("OnHide") |
MerchantFrame:SetScript("OnHide", function(...) |
return self:MerchantFrame_OnHide(...) |
end) |
end |
function BuyEmAll:MoneyFrame_OnLoad() |
-- 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("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(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 = this: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 = |
CogsBagSpace:FreeBagSpace(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() |
else |
self.OrigMerchantItemButton_OnModifiedClick(button, ...) |
end |
end |
--[[ |
Prepare the various UI elements of the BuyEmAll frame and show it |
]] |
function BuyEmAll:Show() |
self.typing = 0 |
BuyEmAllLeftButton:Disable() |
BuyEmAllRightButton:Enable() |
BuyEmAllStackButton:Enable() |
if self.max < self.stackClick then |
BuyEmAllStackButton:Disable() |
end |
BuyEmAllFrame:ClearAllPoints() |
BuyEmAllFrame:SetPoint("BOTTOMLEFT", this, "TOPLEFT", 0, 0) |
BuyEmAllFrame:Show() |
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() |
if this == BuyEmAllOkayButton then |
self:VerifyPurchase() |
elseif this == BuyEmAllCancelButton then |
BuyEmAllFrame:Hide() |
elseif this == BuyEmAllStackButton then |
self.split = self.stackClick |
self:UpdateDisplay() |
if this:IsEnabled() == 1 then |
self:OnEnter() |
else |
GameTooltip:Hide() |
end |
elseif this == 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() |
if arg1 < "0" or arg1 > "9" then |
return |
end |
if self.typing == 0 then |
self.typing = 1 |
self.split = 0 |
end |
local split = (self.split * 10) + arg1 |
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() |
if arg1 == "BACKSPACE" or arg1 == "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 arg1 == "ENTER" then |
self:VerifyPurchase() |
elseif arg1 == "ESCAPE" then |
BuyEmAllFrame:Hide() |
elseif arg1 == "LEFT" or arg1 == "DOWN" then |
BuyEmAll:Left_Click() |
elseif arg1 == "RIGHT" or arg1 == "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() |
local lines = self.lines[this == 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(lines) |
end |
--[[ |
Creates the tooltip from the given lines table. See the structure of lines above for |
more insight. |
]] |
function BuyEmAll:CreateTooltip(lines) |
GameTooltip:SetOwner(this, "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() |
end |
--[[ |
When the BuyEmAll frame is closed, close any confirmations waiting for a |
response. |
]] |
function BuyEmAll:OnHide() |
StaticPopup_Hide("BUYEMALL_CONFIRM") |
end |