diff Summary.lua @ 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 06fee4208bf2
children d903b0a151d3
line wrap: on
line diff
--- 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