# HG changeset patch # User Zerotorescue # Date 1295720688 -3600 # Node ID e136c99fe5bb96b3ef42b5f8483b42fd4f6f38b2 # Parent 3149439631552a87badfe824506db1c50f0862af 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. diff -r 314943963155 -r e136c99fe5bb Core.lua --- 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; diff -r 314943963155 -r e136c99fe5bb Modules/Config.lua --- 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", diff -r 314943963155 -r e136c99fe5bb Plugins/ItemCountAddons/DataStore (all accounts).lua --- /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 diff -r 314943963155 -r e136c99fe5bb Plugins/ItemCountAddons/DataStore (with guilds).lua --- 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 diff -r 314943963155 -r e136c99fe5bb Plugins/ItemCountAddons/DataStore (without guilds).lua --- 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 diff -r 314943963155 -r e136c99fe5bb Plugins/ItemCountAddons/ItemCountAddons.xml --- 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 @@