- Added option to view prices from all guilds or a specific guild

Yaron Kfir [06-14-14 - 03:52]
 - Added option to view prices from all guilds or a specific guild
 - Addon version number was outdated
Filename
Changelog
PriceTracker.lua
PriceTracker.txt
PriceTrackerMenu.lua
diff --git a/Changelog b/Changelog
index 3da2f4b..6a8eca2 100644
--- a/Changelog
+++ b/Changelog
@@ -1,8 +1,11 @@
 Changelog

+v1.3
+ - Added option to view prices from all guilds or a specific guild
+
 v1.2
  - Fixed a bug where enchanting an item would throw an exception
-
+
 v1.1
  - Added some color
  - Added price info to enchanting tooltip
diff --git a/PriceTracker.lua b/PriceTracker.lua
index 49fa041..b2bf987 100644
--- a/PriceTracker.lua
+++ b/PriceTracker.lua
@@ -219,9 +219,13 @@ function PriceTracker:GetMatches(itemName)
 		return nil
 	end

+	local limitToGuild = self.settings.limitToGuild or 1
+
 	local matches = {}
 	for k, v in pairs(self.settings.itemList[normalizedName]) do
-		table.insert(matches, v)
+		if limitToGuild == 1 or v.guildId == GetGuildId(limitToGuild - 1) then
+			table.insert(matches, v)
+		end
 	end
 	return matches
 end
diff --git a/PriceTracker.txt b/PriceTracker.txt
index e9bcd4a..bdf4c17 100644
--- a/PriceTracker.txt
+++ b/PriceTracker.txt
@@ -1,6 +1,6 @@
 ## Title: PriceTracker
 ## Author: Barvazon
-## Version: 0.2
+## Version: 1.2
 ## SavedVariables: PriceTrackerSettings
 ## APIVersion: 100004
 ## OptionalDependsOn: LibAddonMenu-1.0
@@ -10,5 +10,5 @@ PriceTracker.lua
 PriceTrackerMenu.lua
 PriceTrackerEnchantingTable.lua
 MathUtils.lua
-lib/LibStub/LibStub.lua
-lib/LibAddonMenu-1.0/LibAddonMenu-1.0
\ No newline at end of file
+lib/Libtub/LibStub.lua
+lib/LibAddonMenu-1.0/LibAddonMenu-1.0.lua
diff --git a/PriceTrackerMenu.lua b/PriceTrackerMenu.lua
index 2218115..80436a7 100644
--- a/PriceTrackerMenu.lua
+++ b/PriceTrackerMenu.lua
@@ -52,6 +52,10 @@ function PriceTrackerMenu:InitAddonMenu(addOnName)
 		self.keyTable,
 		function() return PriceTracker.settings.keyPress or self.keyTable[1] end,
 		function(key) PriceTracker.settings.keyPress = key end)
+	LAM:AddDropdown(addOnMenu, addOnName .. "LimitToGuild", "Limit results to a specific guild", "Check pricing data from all guild, or a specific one",
+		self:GetGuildList(),
+		function() return self:GetGuildList()[PriceTracker.settings.limitToGuild or 1] end,
+		function(...) self:setLimitToGuild(...) end)
 end

 function PriceTrackerMenu:IsKeyPressed()
@@ -61,3 +65,26 @@ function PriceTrackerMenu:IsKeyPressed()
 		(PriceTracker.settings.keyPress == self.keyTable[4] and IsAltKeyDown()) or
 		(PriceTracker.settings.keyPress == self.keyTable[5] and IsCommandKeyDown())
 end
+
+function PriceTrackerMenu:GetGuildList()
+	local guildList = {}
+	guildList[1] = "All Guilds"
+	for i = 1, GetNumGuilds() do
+		guildList[i + 1] = GetGuildName(GetGuildId(i))
+	end
+	return guildList
+end
+
+function PriceTrackerMenu:setLimitToGuild(guildName)
+	d(guildName)
+	local guildList = self:GetGuildList()
+	for i = 1, #guildList do
+		if guildList[i] == guildName then
+			PriceTracker.settings.limitToGuild = i
+			return
+		end
+	end
+	-- Guild not found.  Default to 'All Guilds'
+	PriceTracker.settings.limitToGuild = 1
+end
+