Quantcast

-Added new option /bgs guildname

Xruptor [06-21-10 - 13:29]
-Added new option /bgs guildname
-guildname will toggle the displaying of Guild Names and total rather then just guild total per character.
-Note: guildname is toggled off by default
Filename
BagSync.lua
localization/localization.lua
diff --git a/BagSync.lua b/BagSync.lua
index 76635d0..8697ec0 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -31,6 +31,7 @@ local doTokenUpdate = 0
 local SILVER = '|cffc7c7cf%s|r'
 local MOSS = '|cFF80FF00%s|r'
 local TTL_C = '|cFFF4A460%s|r'
+local GN_C = '|cFF65B8C0%s|r'

 local BagSync = CreateFrame("frame", "BagSync", UIParent)

@@ -148,6 +149,15 @@ function BagSync:PLAYER_LOGIN()
 					print("|cFFFF0000BagSync: "..BAGSYNC_SEARCH_TOTAL.." "..BAGSYNC_SWITCH_ON)
 				end
 				return true
+			elseif c and c:lower() == BAGSYNC_SLASH_CMD8 then
+				if BagSyncOpt.showGuildNames then
+					BagSyncOpt.showGuildNames = false
+					print("|cFFFF0000BagSync: "..BAGSYNC_SLASH_CMD8.." "..BAGSYNC_SWITCH_OFF)
+				else
+					BagSyncOpt.showGuildNames = true
+					print("|cFFFF0000BagSync: "..BAGSYNC_SLASH_CMD8.." "..BAGSYNC_SWITCH_ON)
+				end
+				return true
 			elseif c and c:lower() ~= "" then
 				--do an item search
 				if BagSync_SearchFrame then
@@ -167,6 +177,7 @@ function BagSync:PLAYER_LOGIN()
 		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH5)
 		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH6)
 		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH7)
+		DEFAULT_CHAT_FRAME:AddMessage(BAGSYNC_SLASH8)
 	end

 	DEFAULT_CHAT_FRAME:AddMessage("|cFF99CC33BagSync|r [v|cFFDF2B2B"..ver.."|r] loaded: /bgs, /bagsync")
@@ -264,6 +275,7 @@ function BagSync:StartupDB()

 	BagSyncOpt = BagSyncOpt or {}
 	if BagSyncOpt.showTotal == nil then BagSyncOpt.showTotal = true end
+	if BagSyncOpt.showGuildNames == nil then BagSyncOpt.showGuildNames = false end

 	BagSyncGUILD_DB = BagSyncGUILD_DB or {}
 	BagSyncGUILD_DB[currentRealm] = BagSyncGUILD_DB[currentRealm] or {}
@@ -892,7 +904,7 @@ local function CountsToInfoString(invCount, bankCount, equipCount, guildCount, m
 		end
 	end

-	if guildCount > 0 then
+	if guildCount > 0 and not BagSyncOpt.showGuildNames then
 		local count = BAGSYNC_NUM_GUILDBANK:format(guildCount)
 		if info then
 			info = strjoin(', ', info, count)
@@ -919,6 +931,21 @@ local function CountsToInfoString(invCount, bankCount, equipCount, guildCount, m
 	end
 end

+--sort by key element rather then value
+local function pairsByKeys (t, f)
+	local a = {}
+		for n in pairs(t) do table.insert(a, n) end
+		table.sort(a, f)
+		local i = 0      -- iterator variable
+		local iter = function ()   -- iterator function
+			i = i + 1
+			if a[i] == nil then return nil
+			else return a[i], t[a[i]]
+			end
+		end
+	return iter
+end
+
 local function AddOwners(frame, link)
 	local itemLink = ToShortLink(link)
 	if not itemLink then
@@ -1008,6 +1035,17 @@ local function AddOwners(frame, link)

 	end

+	--show guildnames last
+	if BagSyncOpt.showGuildNames then
+		for k, v in pairsByKeys(previousGuilds) do
+			--only print stuff higher then zero
+			if v > 0 then
+				frame:AddDoubleLine(format(GN_C, k), format(SILVER, v))
+				table.insert(lastDisplayed, format(GN_C, k).."@"..format(SILVER, v))
+			end
+		end
+	end
+
 	--show grand total if we have something
 	--don't show total if there is only one item
 	if BagSyncOpt.showTotal and grandTotal > 0 and getn(lastDisplayed) > 1 then
diff --git a/localization/localization.lua b/localization/localization.lua
index 3069255..2c5ce59 100644
--- a/localization/localization.lua
+++ b/localization/localization.lua
@@ -29,6 +29,7 @@ if ( GetLocale() == "zhCN" ) then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -36,6 +37,7 @@ if ( GetLocale() == "zhCN" ) then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Opens the profiles window.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 elseif ( GetLocale() == "ruRU" )  then
 	--thanks to senryo from WOWInterface
@@ -65,6 +67,7 @@ elseif ( GetLocale() == "ruRU" )  then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -72,6 +75,7 @@ elseif ( GetLocale() == "ruRU" )  then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Opens the profiles window.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 elseif ( GetLocale() == "zhTW" ) then

@@ -100,6 +104,7 @@ elseif ( GetLocale() == "zhTW" ) then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -107,6 +112,7 @@ elseif ( GetLocale() == "zhTW" ) then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Opens the profiles window.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 elseif ( GetLocale() == "frFR" ) then
 	--thanks to cacahuete from WOWInterface
@@ -136,6 +142,7 @@ elseif ( GetLocale() == "frFR" ) then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -143,6 +150,7 @@ elseif ( GetLocale() == "frFR" ) then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Opens the profiles window.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 elseif ( GetLocale() == "koKR" ) then
 	--thanks to zinzzalimp from WOWInterface
@@ -172,6 +180,7 @@ elseif ( GetLocale() == "koKR" ) then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - 빠른 아이템 찾기'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - 검색창 열기'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - 툴팁에 각 케릭터의 골드량을 표시합니다.'
@@ -179,7 +188,8 @@ elseif ( GetLocale() == "koKR" ) then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - 프로필 창을 엽니다.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
-
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'
+
 elseif ( GetLocale() == "deDE" ) then
 	--thanks to Schnubby from WOWInterface

@@ -208,6 +218,7 @@ elseif ( GetLocale() == "deDE" ) then
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Nach einem Item suchen'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Öffnet das Suchfenster'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Zeigt einen Tooltip mit dem Gold eines jeden Charakters.'
@@ -215,6 +226,7 @@ elseif ( GetLocale() == "deDE" ) then
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Öffnet das Profilfenster.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Führt eine Reparatur der Datenbank (FixDB) aus.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Zeigt/Verbirgt die [Gesamt] Anzeige in Tooltips für Items und in der Goldanzeige.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 else

@@ -243,6 +255,7 @@ else
 	BAGSYNC_SLASH_CMD5 = 'profiles'
 	BAGSYNC_SLASH_CMD6 = 'fixdb'
 	BAGSYNC_SLASH_CMD7 = 'total'
+	BAGSYNC_SLASH_CMD8 = 'guildname'
 	BAGSYNC_SLASH1 = '/bgs '..BAGSYNC_SLASH_CMD1..' - Does a quick search for an item'
 	BAGSYNC_SLASH2 = '/bgs '..BAGSYNC_SLASH_CMD2..' - Opens the search window'
 	BAGSYNC_SLASH3 = '/bgs '..BAGSYNC_SLASH_CMD3..' - Displays a tooltip with the amount of gold on each character.'
@@ -250,5 +263,6 @@ else
 	BAGSYNC_SLASH5 = '/bgs '..BAGSYNC_SLASH_CMD5..' - Opens the profiles window.'
 	BAGSYNC_SLASH6 = '/bgs '..BAGSYNC_SLASH_CMD6..' - Runs the database fix (FixDB) on BagSync.'
 	BAGSYNC_SLASH7 = '/bgs '..BAGSYNC_SLASH_CMD7..' - Toggles the [Total] display in tooltips and gold display.'
+	BAGSYNC_SLASH8 = '/bgs '..BAGSYNC_SLASH_CMD8..' - Toggles the [Guild Name] display in tooltips.'

 end
\ No newline at end of file