diff --git a/.pkgmeta b/.pkgmeta
index 6b702e5..74ce385 100644
--- a/.pkgmeta
+++ b/.pkgmeta
@@ -39,3 +39,6 @@ externals:
Libs/LibLogger-1.0:
url: svn://svn.wowace.com/wow/liblogger-1-0/mainline/trunk/LibLogger-1.0
tag: latest
+ Libs/WoWUnit-1.0.9:
+ url: svn://svn.wowace.com/wow/wowunit/mainline/trunk
+ tag: latest
diff --git a/Cauldron.toc b/Cauldron.toc
index d83f38c..dab36f8 100755
--- a/Cauldron.toc
+++ b/Cauldron.toc
@@ -4,14 +4,14 @@
## Author: Caendra of Silver Hand
## Notes: An improved interface for your trade skills
## RequiredDeps:
-## OptionalDeps: Ace3, LibStub, LibDataBroker-1.1, LibPeriodicTable-3.1
+## OptionalDeps: Ace3, LibStub, LibDataBroker-1.1
## SavedVariables: CauldronDB
## SavedVariablesPerCharacter:
## DefaultState: enabled
## X-Name: Cauldron
## X-Category: Tradeskill
## X-eMail: dm AT critical DASH failure DOT org
-## X-Embeds: Ace3, LibPeriodicTable-3.1
+## X-Embeds: Ace3
#@no-lib-strip@
#### List of embedded libraries
@@ -33,3 +33,6 @@ CauldronShoppingListUI.lua
CauldronMain.xml
CauldronShoppingList.xml
+#@alpha@
+CauldronUnitTests.lua
+#@end-alpha@
\ No newline at end of file
diff --git a/CauldronMain.lua b/CauldronMain.lua
index 294707d..4902e16 100644
--- a/CauldronMain.lua
+++ b/CauldronMain.lua
@@ -57,6 +57,18 @@ function Cauldron:OnInitialize()
type = 'execute',
func = function() Cauldron:ShowShoppingList() end,
},
+ enable = {
+ name = L["Enable Cauldron"],
+ desc = L["Use Cauldron as your tradeskill interface"],
+ type = 'execute',
+ func = function() Cauldron:Enable() end,
+ },
+ disable = {
+ name = L["Disable Cauldron"],
+ desc = L["Use the standard Blizzard window as your tradeskill interface"],
+ type = 'execute',
+ func = function() Cauldron:Disable() end,
+ },
version = {
name = L["Version"],
desc = L["Shows the version number of the addon"],
@@ -971,6 +983,16 @@ end
--]]
+function Cauldron:Enable()
+ Cauldron.vars.enabled = true;
+end
+
+function Cauldron:Disable()
+ Cauldron.vars.enabled = false;
+
+ Cauldron:Frame_Hide();
+end
+
function Cauldron:Reset()
self:Print("Resetting data structures...");
diff --git a/CauldronMainUI.lua b/CauldronMainUI.lua
index 745721e..ea1f9fc 100644
--- a/CauldronMainUI.lua
+++ b/CauldronMainUI.lua
@@ -10,37 +10,39 @@ function Cauldron:Frame_Show()
self:debug("Frame_Show enter");
--@end-alpha@
+ if Cauldron.vars.enable and not(IsShiftKeyDown() and IsControlKeyDown()) then
--@alpha@
- self:debug("Frame_Show: close dropdown menus");
+ self:debug("Frame_Show: close dropdown menus");
--@end-alpha@
- CloseDropDownMenus();
+ CloseDropDownMenus();
-- self:UpdateFramePosition();
-- self:UpdateFrameStrata();
--@alpha@
- self:debug("Frame_Show: show our frame");
+ self:debug("Frame_Show: show our frame");
--@end-alpha@
- ShowUIPanel(CauldronFrame);
+ ShowUIPanel(CauldronFrame);
- if TradeSkillFrame then
+ if TradeSkillFrame then
--@alpha@
- self:debug("Frame_Show: hide the original tradeskill frame");
+ self:debug("Frame_Show: hide the original tradeskill frame");
--@end-alpha@
- -- hide the original tradeskill frame
- TradeSkillFrame:SetAlpha(0);
- TradeSkillFrame:ClearAllPoints();
- TradeSkillFrame:SetPoint("TOPLEFT", 0, 900);
+ -- hide the original tradeskill frame
+ TradeSkillFrame:SetAlpha(0);
+ TradeSkillFrame:ClearAllPoints();
+ TradeSkillFrame:SetPoint("TOPLEFT", 0, 900);
-- CauldronFrame:SetPoint("TOPLEFT", TradeSkillFrame, "TOPLEFT", 0, 0);
end
- self:RegisterMessage("Cauldron_Update", "OnCauldronUpdate");
+ self:RegisterMessage("Cauldron_Update", "OnCauldronUpdate");
--@alpha@
- self:debug("Frame_Show: call Frame_Update()");
+ self:debug("Frame_Show: call Frame_Update()");
--@end-alpha@
- self:Frame_Update();
+ self:Frame_Update();
+ end
--@alpha@
self:debug("Frame_Show exit");
diff --git a/CauldronShoppingList.lua b/CauldronShoppingList.lua
index 17f69c9..f07ad49 100644
--- a/CauldronShoppingList.lua
+++ b/CauldronShoppingList.lua
@@ -156,4 +156,64 @@ function CauldronShopping:EmptyShoppingList(list, requestor)
end
function CauldronShopping:AutoBuyShoppingItems(list, requestor)
+
+ if not list then
+ Cauldron:warn("CauldronShopping:AutoBuyShoppingItems: missing list!");
+ return;
+ end
+
+ local merchant = Cauldron:GetMerchantItems();
+
+ -- TODO: remove
+ -- store merchant items in the DB
+ if not Cauldron.db.realm.userdata[Cauldron.vars.playername].merchant then
+ Cauldron.db.realm.userdata[Cauldron.vars.playername].merchant = {};
+ end
+ for item, info in pairs(merchant) do
+ Cauldron.db.realm.userdata[Cauldron.vars.playername].merchant[item] = info;
+ end
+
+ -- iterate over shopping list
+ --[[
+ for r, _ in pairs(list) do
+ for item, amount in pairs(r) do
+ -- check if the merchant has the item and it can be purchased
+ if merchant[item] then
+ CauldronShopping:BuyItem(item, merchant[item], amount);
+ end
+ end
+ end
+ --]]
+
+end
+
+function CauldronShopping:BuyItem(item, merchInfo, amount)
+
+ if (not merchInfo) or (not amount) or (amount < 1) then
+ Cauldron:warn("CauldronShopping:BuyItem: missing merchant item info or invalid amount!");
+ return;
+ end
+
+ -- figure out how many to purchase, accounting for stacks
+ local stacks = 1;
+ local purchases = 1;
+
+ if amount > 1 then
+ end
+
+ local total = purchases * merchInfo.quantity;
+
+ local qtyInfo = string.format(L["(%1$d total)"], total);
+ if stacks > 1 then
+ qtyInfo = string.format(L["(%1$d stacks, %2$d total)"], stacks, total);
+ end
+
+ -- tell the user, because that's the right thing to do
+ Cauldron:Print(string.format(L["Purchasing %1$s from merchant %2$s..."], item, qtyInfo));
+
+ -- buy the items
+ for i=1,purchases do
+ -- BuyMerchantItem(merchInfo.index, stacks);
+ end
+
end
diff --git a/CauldronShoppingList.xml b/CauldronShoppingList.xml
index 8a270db..d96194d 100644
--- a/CauldronShoppingList.xml
+++ b/CauldronShoppingList.xml
@@ -190,6 +190,7 @@
</Scripts>
<NormalTexture file="Interface\AddOns\Cauldron\Artwork\resize"/>
</Button>
+ <!--
<CheckButton name="$parentAutoBuyButton" hidden="false" inherits="UICheckButtonTemplate" text="">
<Size x="18" y="18" />
<Anchors>
@@ -212,9 +213,7 @@
</Layers>
<Scripts>
<OnLoad>
- -- self:SetScale(0.625);
getglobal(self:GetName().."Text"):SetText(Cauldron:LocaleString("Auto-buy?"));
- -- self:SetChecked(Cauldron.db.realm.userdata[Cauldron.vars.playername].options.autoBuy);
</OnLoad>
<OnEnter>
GameTooltip:SetOwner(self, "ANCHOR_RIGHT");
@@ -233,6 +232,7 @@
</OnClick>
</Scripts>
</CheckButton>
+ -->
</Frames>
<Scripts>
diff --git a/CauldronUnitTests.lua b/CauldronUnitTests.lua
new file mode 100644
index 0000000..fc4f8c4
--- /dev/null
+++ b/CauldronUnitTests.lua
@@ -0,0 +1,32 @@
+-- unit tests
+-- $Revision$
+
+local CauldronTestSuite = {
+ mocks = {
+ GetItemCount = function(arg)
+ return 1;
+ end;
+ };
+ setUp = function()
+ return {};
+ end;
+ tearDown = function()
+ -- no tear down required
+ end;
+ -- core tests
+ -- UI tests
+ -- queue tests
+ -- shopping tests
+ -- shopping UI tests
+ -- tradeskill tests
+ -- util tests
+ testIsVendorItem = function()
+ assert(Cauldron:IsVendorItem(12345), "12345 should be a vendor item");
+ end;
+ testGetPotentialCraftCount = function()
+ assert(true, "");
+ end;
+};
+
+WoWUnit:AddTestSuite("CauldronTestSuite", CauldronTestSuite);
+
diff --git a/CauldronUtil.lua b/CauldronUtil.lua
index 4b55597..007b003 100644
--- a/CauldronUtil.lua
+++ b/CauldronUtil.lua
@@ -130,7 +130,24 @@ function Cauldron:GetNameFromLink(link)
end
function Cauldron:ScanBags()
- -- TODO
+
+ -- reset inventory
+ self.vars.inventory = {};
+
+ -- process keyring and inventory bags
+ for _,bagid in ipairs({-2,0,1,2,3,4}) do
+ -- iterate over bag
+ for i=1,GetContainerNumSlots(bagid) do
+ local link = GetContainerItemLink(bagid, i);
+ if link then
+ local name = select(1, {GetItemInfo(link)});
+ local count = GetItemCount(link);
+
+ self.vars.inventory[name] = count;
+ end
+ end
+ end
+
end
function Cauldron:GetItemDeltas(bagid)
@@ -164,22 +181,30 @@ function Cauldron:GetItemDeltas(bagid)
-- save the delta information
deltas[name] = delta;
end
-
- -- store the bag slot information
- if count > 0 then
- inv[name] = count;
- else
- inv[name] = nil;
- end
end
end
return deltas;
end
-function Cauldron:IsKeyReagent(itemName)
-
- -- TODO
-
- return false;
+function Cauldron:GetMerchantItems()
+
+ local items = {};
+
+ for i=1,GetMerchantNumItems() do
+ local name, _, price, quantity, avail, _, extCost = GetMerchantItemInfo(i);
+ local maxStack = GetMerchantItemMaxStack(i);
+
+ if avail > 0 then
+ items[name] = {
+ ['index'] = i,
+ ['price'] = price,
+ ['quantity'] = quantity,
+ ['available'] = avail,
+ ['maxStack'] = maxStack,
+ };
+ end
+ end
+
+ return items;
end
diff --git a/Locale/Cauldron-enUS.lua b/Locale/Cauldron-enUS.lua
index 2ffdca0..9f43311 100644
--- a/Locale/Cauldron-enUS.lua
+++ b/Locale/Cauldron-enUS.lua
@@ -115,6 +115,10 @@ L["Available at vendor"] = true
L["Click to queue the listed amount of this item"] = true
L["Shift-click to queue the listed potential amount of this item"] = true
+L["Purchasing %1$s from merchant %2$d..."] = true
+L["(%1$d stacks, %2$d total)"] = true
+L["(%1$d total)"] = true
+
-- error messages
L["Crafting %1$s requires the %2$s skill."] = true