diff Core.lua @ 106:d3fbb5676a5e

Added tooltips to the item refill window headers. Now color coding the availibility of items at the item refill window. Added a hide help text option (which is off by default). Renamed all premade groups to a new naming pattern; ?Profession - Category - Detail?, e.g. ?Inscription - Glyphs by class - Death Knight?. To continue getting notified about updates to a selected premade group, you must re-add them. Repositioned elements of the item refill frame to fit better. No longer using colorsargs to remember the index of a queued move, but instead providing a reference to the move itself in the new ?rowData? property of each row. Added tooltips to the headers of the sort table. Merged missing and available columns together (showing available / missing) and sorting on available now sorts on percentage of how many of the missing items are available. Moving and available columns are now aligned to the right. Added an ?extra? config group which contains the additional (but completely optional) settings. Moved color codes adjustments, forget character, auto refill skip confirm and hide help info options to this group.
author Zerotorescue
date Wed, 12 Jan 2011 19:58:39 +0100
parents 6ae44d372360
children 67bd5057ecb7
line wrap: on
line diff
--- a/Core.lua	Wed Jan 12 14:15:50 2011 +0100
+++ b/Core.lua	Wed Jan 12 19:58:39 2011 +0100
@@ -10,7 +10,7 @@
 --@end-non-debug@]===]
 
 local _G = _G;
-local print, pairs, tonumber = _G.print, _G.pairs, _G.tonumber;
+local sformat, print, pairs, tonumber = _G.string.format, _G.print, _G.pairs, _G.tonumber;
 
 --  All modules must be able to retrieve our supported addons database, thus keep it a part of the addon object rather than local
 addon.supportedAddons = {};
@@ -42,6 +42,7 @@
 				bonusQueue = 0.1,
 				priceThreshold = 0,
 				summaryHidePriceThreshold = false,
+				hideHelp = false,
 				trackAtCharacters = {
 				},
 				localItemData = {
@@ -325,6 +326,32 @@
 
 
 
+function addon:ColorCode(num, required)
+	local percentage = ( num / required );
+	
+	if percentage >= addon.db.profile.defaults.colors.green then
+		return sformat("|cff00ff00%d|r", num);
+	elseif percentage >= addon.db.profile.defaults.colors.yellow then
+		return sformat("|cffffff00%d|r", num);
+	elseif percentage >= addon.db.profile.defaults.colors.orange then
+		return sformat("|cffff9933%d|r", num);
+	elseif percentage >= addon.db.profile.defaults.colors.red then
+		return sformat("|cffff0000%d|r", num);
+	else
+		return num;
+	end
+end
+
+function addon:DisplayItemCount(value, minimumStock)
+	if value == -1 then
+		return "|cffffff00Unknown|r";
+	elseif value == -3 then
+		return "|cffffff00Unknown|r";
+	else
+		return sformat("%s / %d", self:ColorCode(value, minimumStock), minimumStock);
+	end
+end
+
 -- Readable money
 
 local goldText = "%s%d|cffffd700g|r ";
@@ -336,19 +363,19 @@
 	
 	local gold = floor( copper / COPPER_PER_GOLD );
 	if gold > 0 then
-		text = goldText:format(text, gold);
+		text = sformat(goldText, text, gold);
 	end
 	
 	if not clean or (not gold or gold < 10) then
 		local silver = floor( ( copper % COPPER_PER_GOLD ) / COPPER_PER_SILVER );
 		if silver > 0 then
-			text = silverText:format(text, silver);
+			text = sformat(silverText, text, silver);
 		end
 		
 		if not clean or (not gold or gold < 1) then
 			local copper = floor( copper % COPPER_PER_SILVER );
 			if copper > 0 or text == "" then
-				text = copperText:format(text, copper);
+				text = sformat(copperText, text, copper);
 			end
 		end
 	end
@@ -467,6 +494,6 @@
 	end
 	
 	if self.debugChannel then
-		self.debugChannel:AddMessage(t:format(...));
+		self.debugChannel:AddMessage(sformat(t, ...));
 	end
 end