changeset 157:e136c99fe5bb

You can now select which guilds to include in the item count when selecting an item count supporting this. Renamed DataStore (with guilds) to ?all accounts?. Removed DataStore (without guilds) option.
author Zerotorescue
date Sat, 22 Jan 2011 19:24:48 +0100
parents 314943963155
children 6c13f2af8a81
files Core.lua Modules/Config.lua Plugins/ItemCountAddons/DataStore (all accounts).lua Plugins/ItemCountAddons/DataStore (with guilds).lua Plugins/ItemCountAddons/DataStore (without guilds).lua Plugins/ItemCountAddons/ItemCountAddons.xml
diffstat 6 files changed, 171 insertions(+), 203 deletions(-) [+]
line wrap: on
line diff
--- a/Core.lua	Sat Jan 22 02:57:08 2011 +0100
+++ b/Core.lua	Sat Jan 22 19:24:48 2011 +0100
@@ -36,28 +36,36 @@
 		},
 		profile = {
 			defaults = {
+				-- General
 				auctionPricingAddon = "Auctioneer",
 				itemCountAddon = "Altoholic",
 				craftingAddon = "AdvancedTradeSkillWindow",
+				trackAtCharacters = { },
+				localItemData = {
+					["Bag"] = true,
+					["Auction House"] = true,
+				},
+				
+				-- Minimumm stock
 				minLocalStock = 20,
 				alertBelowLocalMinimum = true,
 				autoRefill = true,
 				autoRefillSkipConfirm = false,
 				minGlobalStock = 60,
 				alertBelowGlobalMinimum = true,
-				summaryThresholdShow = 10,
+				
+				-- Queueing
 				restockTarget = 60,
 				minCraftingQueue = 0.05,
 				bonusQueue = 0.1,
 				priceThreshold = 0,
+				
+				-- Summary
+				summaryThresholdShow = 10,
 				summaryHidePriceThreshold = false,
+				
+				-- Global (can't be overridden)
 				hideHelp = false,
-				trackAtCharacters = {
-				},
-				localItemData = {
-					["Bag"] = true,
-					["Auction House"] = true,
-				},
 				summary = {
 					speed = 5,
 					width = 700,
@@ -69,6 +77,7 @@
 					yellow = 0.6,
 					green = 0.95,
 				},
+				itemCountGuildsExcluded = { },
 			},
 			groups = {
 				-- items = {},
@@ -222,12 +231,20 @@
 	if self.supportedAddons.itemCount[selectedExternalAddon] and self.supportedAddons.itemCount[selectedExternalAddon].IsEnabled() then
 		-- Try to use the default item count addon
 		
+		if self.supportedAddons.itemCount[selectedExternalAddon].SetGuildState then
+			self.supportedAddons.itemCount[selectedExternalAddon].SetGuildState(self.db.profile.defaults.itemCountGuildsExcluded);
+		end
+		
 		return self.supportedAddons.itemCount[selectedExternalAddon], selectedExternalAddon;
 	else
 		-- Default not available, get the first one then
 		
 		for name, value in pairs(self.supportedAddons.itemCount) do
 			if value.IsEnabled() then
+				if value.SetGuildState then
+					value.SetGuildState(self.db.profile.defaults.itemCountGuildsExcluded);
+				end
+				
 				return value, name;
 			end
 		end
@@ -464,12 +481,12 @@
 -- General
 
 addon.Colors = {
-	Red = { 1, 0, 0 },
-	Orange = { 1, .46, .1 },
-	Green = { 0, 1, 0 },
-	Blue = { 0, 0, 1 },
-	Yellow = { 1, 1, 0 },
-	Cyan = { 0, 1, 1 },
+	["Red"] = { 1, 0, 0 },
+	["Orange"] = { 1, .46, .1 },
+	["Green"] = { 0, 1, 0 },
+	["Blue"] = { 0, 0, 1 },
+	["Yellow"] = { 1, 1, 0 },
+	["Cyan"] = { 0, 1, 1 },
 }; -- easy to extend if more colors are needed
 function addon:Print(text, color)
 	local red, green, blue;
--- a/Modules/Config.lua	Sat Jan 22 02:57:08 2011 +0100
+++ b/Modules/Config.lua	Sat Jan 22 19:24:48 2011 +0100
@@ -1710,6 +1710,55 @@
 							end
 						end,
 					},
+					guildSelection = {
+						order = 40,
+						type = "multiselect",
+						name = "Include guild bank data",
+						desc = "Select which guild data should be included in the item counts.",
+						values = function()
+							local temp = {};
+							
+							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
+							
+							if currentAddon.GetGuildNames then
+								local guilds = currentAddon.GetGuildNames();
+								
+								if guilds and type(guilds) == "table" then
+									for guildName, state in pairs(guilds) do
+										temp[guildName] = guildName;
+										
+										if addon.db.profile.defaults.itemCountGuildsExcluded[guildName] then
+											currentAddon.SetGuildState(guildName, false);
+										else
+											currentAddon.SetGuildState(guildName, true);
+										end
+									end
+								end
+							end
+							
+							return temp;
+						end,
+						get = function(i, v)
+							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
+							
+							return currentAddon.GetGuildNames and currentAddon.GetGuildNames()[v];
+						end,
+						set = function(i, v, e)
+							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
+							
+							if e then
+								-- Guild is enabled, so not excluded
+								addon.db.profile.defaults.itemCountGuildsExcluded[v] = nil;
+							else
+								addon.db.profile.defaults.itemCountGuildsExcluded[v] = true; -- this is excluded, excluded is indicated by true
+							end
+							
+							if currentAddon.SetGuildState then
+								currentAddon.SetGuildState(v, e);
+							end
+						end, -- can't be nil or the defaults will be used
+						dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
+					},
 				},
 			},
 		},
@@ -1782,63 +1831,6 @@
 					},
 				},
 			},
-			guildSelection = {
-				order = 15,
-				type = "group",
-				inline = true,
-				name = "Filter item count data",
-				args = {
-					description = {
-						order = 0,
-						type = "description",
-						name = "Change which data sources are used in the item counts.",
-						hidden = function() return addon.db.profile.defaults.hideHelp; end,
-					},
-					header = {
-						order = 5,
-						type = "header",
-						name = "",
-						hidden = function() return addon.db.profile.defaults.hideHelp; end,
-					},
-					guilds = {
-						order = 20,
-						type = "multiselect",
-						width = "double",
-						name = "Include guild bank data",
-						desc = "Select which guild data should be included in the item counts.",
-						values = function()
-							local temp = {};
-							
-							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
-							
-							if currentAddon.GetGuildNames then
-								local guilds = currentAddon.GetGuildNames();
-								
-								if guilds and type(guilds) == "table" then
-									for guildName, state in pairs(guilds) do
-										temp[guildName] = guildName;
-									end
-								end
-							end
-							
-							return temp;
-						end,
-						get = function(i, v)
-							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
-							
-							return currentAddon.GetGuildNames and currentAddon.GetGuildNames()[v];
-						end,
-						set = function(i, v, e)
-							local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
-							
-							if currentAddon.SetGuildState then
-								currentAddon:SetGuildState(v, e);
-							end
-						end, -- can't be nil or the defaults will be used
-						dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
-					},
-				},
-			},
 			export = {
 				order = 20,
 				type = "group",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Plugins/ItemCountAddons/DataStore (all accounts).lua	Sat Jan 22 19:24:48 2011 +0100
@@ -0,0 +1,91 @@
+do
+	local disabledGuilds = {};
+	
+	local function GetGuildNames()
+		local guilds = {};
+		
+		local realm = GetRealmName();
+		
+		-- Process all accounts
+		for accountName in pairs(DataStore:GetAccounts()) do
+			for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
+			
+				if disabledGuilds[guildName] then
+					guilds[guildName] = false;
+				else
+					guilds[guildName] = true;
+				end
+				
+			end
+		end
+		
+		return guilds;
+	end
+	
+	local function SetGuildState(guildName, state)
+		if guildName and type(guildName) == "table" then
+			disabledGuilds = guildName;
+		else
+			if not state then
+				disabledGuilds[guildName] = true;
+			else
+				disabledGuilds[guildName] = nil;
+			end
+		end
+	end
+	
+	local function GetTotalCount(itemId)
+		local realm = GetRealmName();
+		
+		local totalCount = 0;
+		
+		local guilds = {};
+		
+		-- Process all accounts
+		for accountName in pairs(DataStore:GetAccounts()) do
+			-- Process all charracters
+			for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) do
+				-- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
+				local bag, bank = DataStore:GetContainerItemCount(character, itemId);
+				bag = (bag or 0); bank = (bank or 0);
+				local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
+				local mail = DataStore:GetMailItemCount(character, itemId) or 0;
+				
+				totalCount = totalCount + bag + bank + auctionHouse + mail;
+			end
+			
+			-- Process all guilds
+			for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
+				if not guilds[guildName] and not disabledGuilds[guildName] then
+					-- We don't want itemcounts from a single guild to be counted twice, so first to present data wins
+					
+					guilds[guildName] = true;
+					
+					local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0;
+				
+					totalCount = totalCount + guild;
+				end
+			end
+		end
+		
+		return totalCount or -1;
+	end
+	
+	local function GetCharacterCount(itemId)
+		local character = DataStore:GetCharacter();
+		
+		local bag, bank = DataStore:GetContainerItemCount(character, itemId);
+		bag = (bag or 0); bank = (bank or 0);
+		local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
+		local mail = DataStore:GetMailItemCount(character, itemId) or 0;
+		
+		return bag, bank, auctionHouse, mail;
+	end
+	
+	local function IsEnabled()
+		return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
+	end
+	
+	IMRegisterItemCountAddon("DataStore (all accounts)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState);
+	
+end
--- a/Plugins/ItemCountAddons/DataStore (with guilds).lua	Sat Jan 22 02:57:08 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,88 +0,0 @@
-do
-	local disabledGuilds = {};
-	
-	local function GetGuildNames()
-		local guilds = {};
-		
-		local realm = GetRealmName();
-		
-		-- Process all accounts
-		for accountName in pairs(DataStore:GetAccounts()) do
-			for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
-			
-				if disabledGuilds[guildName] then
-					guilds[guildName] = false;
-				else
-					guilds[guildName] = true;
-				end
-				
-			end
-		end
-		
-		return guilds;
-	end
-	
-	local function SetGuildState(guildName, state)
-		if not state then
-			disabledGuilds[guildName] = true;
-		else
-			disabledGuilds[guildName] = nil;
-		end
-	end
-	
-	local function GetTotalCount(itemId)
-		local realm = GetRealmName();
-		
-		local totalCount = 0;
-		
-		local guilds = {};
-		
-		-- Process all accounts
-		for accountName in pairs(DataStore:GetAccounts()) do
-		
-			-- Process all charracters
-			for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) do
-				-- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
-				local bag, bank = DataStore:GetContainerItemCount(character, itemId);
-				bag = (bag or 0); bank = (bank or 0);
-				local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
-				local mail = DataStore:GetMailItemCount(character, itemId) or 0;
-				
-				totalCount = totalCount + bag + bank + auctionHouse + mail;
-			end
-			
-			-- Process all guilds
-			for guildName, guild in pairs(DataStore:GetGuilds(realm, accountName)) do
-				if not guilds[guildName] and not disabledGuilds[guildName] then
-					-- We don't want itemcounts from a single guild to be counted twice, so first to present data wins
-					
-					guilds[guildName] = true;
-					
-					local guild = DataStore:GetGuildBankItemCount(guild, itemId) or 0;
-				
-					totalCount = totalCount + guild;
-				end
-			end
-		end
-		
-		return totalCount or -1;
-	end
-	
-	local function GetCharacterCount(itemId)
-		local character = DataStore:GetCharacter();
-		
-		local bag, bank = DataStore:GetContainerItemCount(character, itemId);
-		bag = (bag or 0); bank = (bank or 0);
-		local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
-		local mail = DataStore:GetMailItemCount(character, itemId) or 0;
-		
-		return bag, bank, auctionHouse, mail;
-	end
-	
-	local function IsEnabled()
-		return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
-	end
-	
-	IMRegisterItemCountAddon("DataStore (with guilds)", GetTotalCount, GetCharacterCount, IsEnabled, nil, GetGuildNames, SetGuildState);
-	
-end
--- a/Plugins/ItemCountAddons/DataStore (without guilds).lua	Sat Jan 22 02:57:08 2011 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,43 +0,0 @@
-do
-	
-	local function GetTotalCount(itemId)
-		local realm = GetRealmName();
-		
-		local totalCount = 0;
-		
-		-- Process all accounts
-		for accountName in pairs(DataStore:GetAccounts()) do
-		
-			-- Process all charracters
-			for characterName, character in pairs(DataStore:GetCharacters(realm, accountName)) do
-				-- Get only useful info (currency / gear shouldn't contain the stuff we are interested in)
-				local bag, bank = DataStore:GetContainerItemCount(character, itemId);
-				bag = (bag or 0); bank = (bank or 0);
-				local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
-				local mail = DataStore:GetMailItemCount(character, itemId) or 0;
-				
-				totalCount = totalCount + bag + bank + auctionHouse + mail;
-			end
-		end
-		
-		return totalCount or -1;
-	end
-	
-	local function GetCharacterCount(itemId)
-		local character = DataStore:GetCharacter();
-		
-		local bag, bank = DataStore:GetContainerItemCount(character, itemId);
-		bag = (bag or 0); bank = (bank or 0);
-		local auctionHouse = DataStore:GetAuctionHouseItemCount(character, itemId) or 0;
-		local mail = DataStore:GetMailItemCount(character, itemId) or 0;
-		
-		return bag, bank, auctionHouse, mail;
-	end
-	
-	local function IsEnabled()
-		return (DataStore and DataStore.GetContainerItemCount and DataStore.GetAuctionHouseItemCount and DataStore.GetMailItemCount);
-	end
-	
-	IMRegisterItemCountAddon("DataStore (without guilds)", GetTotalCount, GetCharacterCount, IsEnabled);
-	
-end
--- a/Plugins/ItemCountAddons/ItemCountAddons.xml	Sat Jan 22 02:57:08 2011 +0100
+++ b/Plugins/ItemCountAddons/ItemCountAddons.xml	Sat Jan 22 19:24:48 2011 +0100
@@ -1,8 +1,7 @@
 <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/
 ..\FrameXML\UI.xsd">
 	<Script file="Altoholic.lua"/>
+	<Script file="DataStore (all accounts).lua"/>
 	<Script file="DataStore (current account only).lua"/>
-	<Script file="DataStore (with guilds).lua"/>
-	<Script file="DataStore (without guilds).lua"/>
 	<Script file="ItemCount.lua"/>
 </Ui>
\ No newline at end of file