changeset 57:03c0610e9c1e

Added a minimum local stock option. I reckon people will want to keep maybe a stack in their bags/AH and another stack in their bank. Added a seperate alert option for the local stock option. When your selected item count addon isn?t enabled the options help text will now display the reason for this. No more debugging of something that ain?t broken. The minimum stock will now be displayed next to the current stock values rather than as a seperate column.
author Zerotorescue
date Tue, 21 Dec 2010 14:24:15 +0100
parents b33248fb89dd
children 344de8ffafc7
files Core.lua ItemCountAddons/ItemCount.lua Summary.lua
diffstat 3 files changed, 130 insertions(+), 77 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Mon Dec 20 14:32:21 2010 +0100
+++ b/Core.lua	Tue Dec 21 14:24:15 2010 +0100
@@ -27,8 +27,10 @@
 				auctionPricingAddon = "Auctioneer",
 				itemCountAddon = "Altoholic",
 				craftingAddon = "AdvancedTradeSkillWindow",
-				minimumStock = 60,
-				alertBelowMinimum = true,
+				minimumLocalStock = 20,
+				alertBelowLocalMinimum = true,
+				minimumStock = 60, -- global stock
+				alertBelowMinimum = true, -- global stock
 				summaryThresholdShow = 10,
 				restockTarget = 60,
 				minCraftingQueue = 0.05,
@@ -590,6 +592,7 @@
 							local t = "Here you can set general settings. The settings entered here will be used when you choose not to override the settings within an individual group.\n\n";
 							
 							local currentAddon, selectedAddonName = addon:GetItemCountAddon();
+							local preferedAddon = self.db.global.defaults.itemCountAddon;
 							
 							if currentAddon then
 								--GetCharacterCount
@@ -603,6 +606,10 @@
 								elseif currentAddon.GetCharacterCount then
 									t = t .. " This addon supports |cfffed000only local|r item counts.";
 								end
+								
+								if preferedAddon ~= selectedAddonName then
+									t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus a random alternative was selected.|r";
+								end
 							end
 							
 							return t;
@@ -712,20 +719,48 @@
 						type = "header",
 						name = "",
 					},
-					minimumStock = {
+					minLocalStock = {
 						order = 10,
 						type = "range",
 						min = 0,
 						max = 100000,
 						softMax = 100,
 						step = 1,
-						name = "Minimum stock",
+						name = "Minimum local stock",
+						desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
+						get = function() return self.db.global.defaults.minimumLocalStock; end,
+						set = function(i, v) self.db.global.defaults.minimumLocalStock = v; end,
+					},
+					alertBelowLocalMinimum = {
+						order = 11,
+						type = "toggle",
+						name = "Alert when below local minimum (NYI)",
+						desc = "Show an alert when this item gets below this threshold.",
+						get = function() return self.db.global.defaults.alertBelowLocalMinimum; end,
+						set = function(i, v) self.db.global.defaults.alertBelowLocalMinimum = v; end,
+					},
+					minGlobalStock = {
+						order = 20,
+						type = "range",
+						min = 0,
+						max = 100000,
+						softMax = 100,
+						step = 1,
+						name = "Minimum global stock",
 						desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
 						get = function() return self.db.global.defaults.minimumStock; end,
 						set = function(i, v) self.db.global.defaults.minimumStock = v; end,
 					},
+					alertBelowGlobalMinimum = {
+						order = 21,
+						type = "toggle",
+						name = "Alert when below global minimum (NYI)",
+						desc = "Show an alert when this item gets below this threshold.",
+						get = function() return self.db.global.defaults.alertBelowMinimum; end,
+						set = function(i, v) self.db.global.defaults.alertBelowMinimum = v; end,
+					},
 					summaryThresholdShow = {
-						order = 20,
+						order = 30,
 						type = "range",
 						min = 0,
 						max = 10,
@@ -733,18 +768,10 @@
 						step = 0.05,
 						isPercent = true,
 						name = "Show in summary when below",
-						desc = "Show items in the summary when below this percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
+						desc = "Show items in the summary when below this percentage of the minimum stock. This can be either below the minimum or the global stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
 						get = function() return self.db.global.defaults.summaryThresholdShow; end,
 						set = function(i, v) self.db.global.defaults.summaryThresholdShow = v; end,
 					},
-					alertBelowMinimum = {
-						order = 30,
-						type = "toggle",
-						name = "NYI | Alert when below minimum",
-						desc = "Show an alert when this item gets below this threshold.",
-						get = function() return self.db.global.defaults.alertBelowMinimum; end,
-						set = function(i, v) self.db.global.defaults.alertBelowMinimum = v; end,
-					},
 					trackAtCharacters = {
 						order = 40,
 						type = "multiselect",
@@ -1217,6 +1244,7 @@
 								local t = "Here you can set general settings for the currently selected group. If you do not wish to override a setting, the default setting specified in the general group will be used.\n\n";
 								
 								local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
+								local preferedAddon = addon:GetOptionByKey(groupName, "itemCountAddon");
 								
 								if currentAddon then
 									--GetCharacterCount
@@ -1230,6 +1258,10 @@
 									elseif currentAddon.GetCharacterCount then
 										t = t .. " This addon supports |cfffed000only local|r item counts.";
 									end
+									
+									if preferedAddon ~= selectedAddonName then
+										t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus a random alternative was selected.|r";
+									end
 								end
 								
 								return t;
@@ -1406,33 +1438,82 @@
 							type = "header",
 							name = "",
 						},
-						overrideMinimumStock = {
-							order = 9,
+						
+						overrideMinLocalStock = {
+							order = 10,
 							type = "toggle",
-							name = "Override min stock",
-							desc = "Allows you to override the minimum stock setting for this group.",
-							arg = "minimumStock",
+							name = "Override min local stock",
+							desc = "Allows you to override the minimum local stock setting for this group.",
+							arg = "minLocalStock",
 						},
-						minimumStock = {
-							order = 10,
+						minLocalStock = {
+							order = 11,
 							type = "range",
 							min = 0,
 							max = 100000,
 							softMax = 100,
 							step = 1,
-							name = "Minimum stock",
+							name = "Minimum local stock",
 							desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
-							arg = "overrideMinimumStock",
+							arg = "overrideMinLocalStock",
 						},
+						overrideAlertBelowLocalMinimum = {
+							order = 15,
+							type = "toggle",
+							name = "Override local minimum alert",
+							desc = "Allows you to override wether an alert should be shown when an item in this group gets below the local minimum stock threshold.",
+							arg = "alertBelowLocalMinimum",
+						},
+						alertBelowLocalMinimum = {
+							order = 16,
+							type = "toggle",
+							name = "Alert when below local minimum (NYI)",
+							desc = "Show an alert when an item in this group gets below the local minimum stock threshold.",
+							arg = "overrideAlertBelowLocalMinimum",
+						},
+						
+						overrideMinGlobalStock = {
+							order = 20,
+							type = "toggle",
+							name = "Override min global stock",
+							desc = "Allows you to override the minimum global stock setting for this group.",
+							arg = "minGlobalStock",
+						},
+						minGlobalStock = {
+							order = 21,
+							type = "range",
+							min = 0,
+							max = 100000,
+							softMax = 100,
+							step = 1,
+							name = "Minimum global stock",
+							desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
+							arg = "overrideMinGlobalStock",
+						},
+						overrideAlertBelowGlobalMinimum = {
+							order = 25,
+							type = "toggle",
+							name = "Override global minimum alert",
+							desc = "Allows you to override wether an alert should be shown when an item in this group gets below the global minimum stock threshold.",
+							arg = "alertBelowGlobalMinimum",
+						},
+						alertBelowGlobalMinimum = {
+							order = 26,
+							type = "toggle",
+							name = "Alert when below global minimum (NYI)",
+							desc = "Show an alert when an item in this group gets below the global minimum stock threshold.",
+							arg = "overrideAlertBelowGlobalMinimum",
+						},
+						
 						overrideSummaryThresholdShow = {
-							order = 19,
+							order = 34,
 							type = "toggle",
 							name = "Override summary showing",
 							desc = "Allows you to override when this group should appear in the summary.",
 							arg = "summaryThresholdShow",
 						},
 						summaryThresholdShow = {
-							order = 20,
+							order = 35,
 							type = "range",
 							min = 0,
 							max = 10,
@@ -1443,20 +1524,6 @@
 							desc = "Show items in the summary when below the specified percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
 							arg = "overrideSummaryThresholdShow",
 						},
-						overrideAlertBelowMinimum = {
-							order = 29,
-							type = "toggle",
-							name = "Override minimum alert",
-							desc = "Allows you to override wether an alert should be shown when an item in this group gets below the minimum stock threshold.",
-							arg = "alertBelowMinimum",
-						},
-						alertBelowMinimum = {
-							order = 30,
-							type = "toggle",
-							name = "NYI | Alert when below minimum",
-							desc = "Show an alert when an item in this group gets below the minimum stock threshold.",
-							arg = "overrideAlertBelowMinimum",
-						},
 						overrideTrackAtCharacters = {
 							order = 39,
 							type = "toggle",
--- a/ItemCountAddons/ItemCount.lua	Mon Dec 20 14:32:21 2010 +0100
+++ b/ItemCountAddons/ItemCount.lua	Tue Dec 21 14:24:15 2010 +0100
@@ -5,7 +5,8 @@
 	end
 	
 	local function GetCharacterCount(itemId)
-		return ICGetItemCountCharacter(itemId) or -1;
+		local bags, bank, auctionHouse, mail = ICGetItemCountCharacter(itemId);
+		return bags or 0, bank or 0, auctionHouse or 0, mail or 0;
 	end
 	
 	local function IsEnabled()
--- a/Summary.lua	Mon Dec 20 14:32:21 2010 +0100
+++ b/Summary.lua	Tue Dec 21 14:24:15 2010 +0100
@@ -97,7 +97,7 @@
 	-- Main Window
 	mod.frame = AceGUI:Create("Frame");
 	_G["InventoriumSummary"] = mod.frame; -- name the global frame so it can be put in the UISpecialFrames
-	mod.frame:SetTitle("Summary");
+	mod.frame:SetTitle("Inventory Summary");
 	mod.frame:SetLayout("Fill");
 	mod.frame:SetCallback("OnClose", function(widget)
 		mod:CancelTimer(self.tmrUpdater, true);
@@ -153,7 +153,7 @@
 	
 	mod:Build();
 end
-	
+
 -- From http://www.wowwiki.com/API_sort
 local function pairsByKeys (t, f)
 	local a = {}
@@ -276,7 +276,8 @@
 		
 			
 			-- Get group settings
-			local minimumStock = addon:GetOptionByKey(groupName, "minimumStock");
+			local minGlobalStock = addon:GetOptionByKey(groupName, "minimumStock");
+			local minLocalStock = addon:GetOptionByKey(groupName, "minimumLocalStock");
 			local showWhenBelow = addon:GetOptionByKey(groupName, "summaryThresholdShow");
 			local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
 			local hideWhenBelowPriceThreshold = addon:GetOptionByKey(groupName, "summaryHidePriceThreshold");
@@ -305,7 +306,7 @@
 			local lblItem = AceGUI:Create("InteractiveLabel");
 			lblItem:SetText("|cfffed000Item|r");
 			lblItem:SetFontObject(GameFontHighlight);
-			lblItem:SetRelativeWidth(.6);
+			lblItem:SetRelativeWidth(.7);
 			lblItem:SetCallback("OnClick", function() ReSort("item"); end);
 			lblItem:SetCallback("OnEnter", ShowTooltip);
 			lblItem:SetCallback("OnLeave", HideTooltip);
@@ -340,19 +341,6 @@
 			
 			iGroup:AddChild(lblQuantity);
 			
-			-- Required stock
-			local lblMinimumStock = AceGUI:Create("InteractiveLabel");
-			lblMinimumStock:SetText("|cfffed000Min.|r");
-			lblMinimumStock:SetFontObject(GameFontHighlight);
-			lblMinimumStock:SetRelativeWidth(.099);
-			lblMinimumStock:SetCallback("OnClick", function() ReSort("percentage"); end);
-			lblMinimumStock:SetCallback("OnEnter", ShowTooltip);
-			lblMinimumStock:SetCallback("OnLeave", HideTooltip);
-			lblMinimumStock.frame.tooltipTitle = "Minimum stock";
-			lblMinimumStock.frame.tooltip = "Sort on the minimum amount of items you wish to keep in stock.";
-			
-			iGroup:AddChild(lblMinimumStock);
-			
 			-- Lowest value
 			local lblValue = AceGUI:Create("InteractiveLabel");
 			lblValue:SetText("|cfffed000Value|r");
@@ -421,12 +409,6 @@
 					else
 						return a.localCount > b.localCount;
 					end
-				elseif sortMethod == "percentage" then
-					if sortDirectory == "ASC" then
-						return ( a.count / minimumStock ) < ( b.count / minimumStock );
-					else
-						return ( a.count / minimumStock ) > ( b.count / minimumStock );
-					end
 				elseif sortMethod == "value" then
 					if sortDirectory == "ASC" then
 						return a.value < b.value;
@@ -445,7 +427,7 @@
 			for i, item in pairs(itemsCache[groupName]) do
 				-- Go through all items for this group
 				
-				if (( item.count / minimumStock ) < showWhenBelow or ( item.localCount / minimumStock ) < showWhenBelow) and (not hideWhenBelowPriceThreshold or priceThreshold == 0 or item.value < 0 or item.value >= priceThreshold) then
+				if (( item.count / minGlobalStock ) < showWhenBelow or ( item.localCount / minLocalStock ) < showWhenBelow) and (not hideWhenBelowPriceThreshold or priceThreshold == 0 or item.value < 0 or item.value >= priceThreshold) then
 																-- if the option "hide when below threshold" is disabled or no price threshold is set or the value is above the price threshold or the value could not be determined, proceed
 																
 					local btnItemLink = AceGUI:Create("ItemLinkButton");
@@ -464,31 +446,33 @@
 							QueryAuctionItems(itemName, nil, nil, 0, 0, 0, 0, 0, 0);
 						end
 					end);
-					btnItemLink:SetRelativeWidth(.6);
+					btnItemLink:SetRelativeWidth(.7);
 					btnItemLink:SetItemId(item.id);
 					
 					iGroup:AddChild(btnItemLink);
 					
 					-- Local quantity
 					local lblLocal = AceGUI:Create("Label");
-					lblLocal:SetText(self:DisplayItemCount(item.localCount, minimumStock));
+					lblLocal:SetText(self:DisplayItemCount(item.localCount, minLocalStock));
 					lblLocal:SetRelativeWidth(.099);
 					
 					iGroup:AddChild(lblLocal);
 					
 					-- Current quantity
 					local lblQuantity = AceGUI:Create("Label");
-					lblQuantity:SetText(self:DisplayItemCount(item.count, minimumStock));
+					lblQuantity:SetText(self:DisplayItemCount(item.count, minGlobalStock));
 					lblQuantity:SetRelativeWidth(.099);
 					
 					iGroup:AddChild(lblQuantity);
 					
-					-- Required stock
-					local lblMinimumStock = AceGUI:Create("Label");
-					lblMinimumStock:SetText(minimumStock);
-					lblMinimumStock:SetRelativeWidth(.099);
-					
-					iGroup:AddChild(lblMinimumStock);
+					--[[
+						-- Required stock
+						local lblMinimumStock = AceGUI:Create("Label");
+						lblMinimumStock:SetText(minGlobalStock);
+						lblMinimumStock:SetRelativeWidth(.099);
+						
+						iGroup:AddChild(lblMinimumStock);
+					]]
 					
 					-- Value
 					local lblValue = AceGUI:Create("Label");
@@ -547,7 +531,8 @@
 	local i = 0;
 	
 	for groupName, items in pairs(itemsCache) do
-		local minimumStock = addon:GetOptionByKey(groupName, "minimumStock");
+		local minGlobalStock = addon:GetOptionByKey(groupName, "minimumStock");
+		local minLocalStock = addon:GetOptionByKey(groupName, "minimumLocalStock");
 		local priceThreshold = addon:GetOptionByKey(groupName, "priceThreshold");
 		
 		for _, item in pairs(items) do
@@ -556,7 +541,7 @@
 					-- Only if item count was queued, update it
 					item.count = addon:GetItemCount(item.id, groupName);
 					if item.set.current and item.set.current.SetText then
-						item.set.current:SetText(self:DisplayItemCount(item.count, minimumStock));
+						item.set.current:SetText(self:DisplayItemCount(item.count, minGlobalStock));
 					end
 				end
 				
@@ -564,7 +549,7 @@
 					-- Only if item count was queued, update it
 					item.localCount = addon:GetLocalItemCount(item.id, groupName);
 					if item.set.localCount and item.set.localCount.SetText then
-						item.set.localCount:SetText(self:DisplayItemCount(item.localCount, minimumStock));
+						item.set.localCount:SetText(self:DisplayItemCount(item.localCount, minLocalStock));
 					end
 				end
 				
@@ -653,7 +638,7 @@
 	elseif value == -3 then
 		return "|cffffff00Unknown|r";
 	else
-		return self:ColorCode(value, minimumStock);
+		return ("%s / %d"):format(self:ColorCode(value, minimumStock), minimumStock);
 	end
 end