Quantcast

Revamping Item Count Display

Xruptor [09-01-16 - 16:02]
Revamping Item Count Display
-It's been a really long time but I'm going to change how the item counts are displayed.  Primarily their colors.
-It's much easier to read the item counts now.  Before everything was one color for certain items which made it difficult to read sometimes.
-If someone has a problem with the colors, they can always change it in the BagSync config now.
Filename
BagSync.lua
locale/deDE.lua
locale/enUS.lua
locale/esES.lua
locale/frFR.lua
locale/koKR.lua
locale/ptBR.lua
locale/ruRU.lua
locale/zhCN.lua
locale/zhTW.lua
diff --git a/BagSync.lua b/BagSync.lua
index 887e65e..0ff5b2e 100644
--- a/BagSync.lua
+++ b/BagSync.lua
@@ -60,23 +60,24 @@ local dataobj = ldb:NewDataObject("BagSyncLDB", {
 ----------------------

 local function rgbhex(r, g, b)
-  if type(r) == "table" then
-	if r.r then
-	  r, g, b = r.r, r.g, r.b
-	else
-	  r, g, b = unpack(r)
+	if type(r) == "table" then
+		if r.r then
+			r, g, b = r.r, r.g, r.b
+		else
+			r, g, b = unpack(r)
+		end
 	end
-  end
-  return string.format("|cff%02x%02x%02x", (r or 1) * 255, (g or 1) * 255, (b or 1) * 255)
+	return string.format("|cff%02x%02x%02x", (r or 1) * 255, (g or 1) * 255, (b or 1) * 255)
 end

 local function tooltipColor(color, str)
-  return string.format("|cff%02x%02x%02x%s|r", (color.r or 1) * 255, (color.g or 1) * 255, (color.b or 1) * 255, str)
+	return string.format("|cff%02x%02x%02x%s|r", (color.r or 1) * 255, (color.g or 1) * 255, (color.b or 1) * 255, tostring(str))
 end

 local function ToShortLink(link)
 	if not link then return nil end
 	if tonumber(link) then return link end
+	--local itemString = string.match(link, "item[%-?%d:]+")
 	return link:match("item:(%d+):") or nil
 end

@@ -136,7 +137,7 @@ function BSYC:StartupDB()
 	--setup the default colors
 	if self.options.colors == nil then self.options.colors = {} end
 	if self.options.colors.first == nil then self.options.colors.first = { r = 128/255, g = 1, b = 0 }  end
-	if self.options.colors.second == nil then self.options.colors.second = { r = 199/255, g = 199/255, b = 207/255 }  end
+	if self.options.colors.second == nil then self.options.colors.second = { r = 1, g = 1, b = 1 }  end
 	if self.options.colors.total == nil then self.options.colors.total = { r = 244/255, g = 164/255, b = 96/255 }  end
 	if self.options.colors.guild == nil then self.options.colors.guild = { r = 101/255, g = 184/255, b = 192/255 }  end
 	if self.options.colors.cross == nil then self.options.colors.cross = { r = 1, g = 125/255, b = 10/255 }  end
@@ -814,7 +815,7 @@ function BSYC:CreateItemTotals(countTable)
 		local count = countTable[list[i][1]]
 		if count > 0 then
 			grouped = grouped + 1
-			info = info..L.TooltipDelimiter..list[i][2]:format(count)
+			info = info..L.TooltipDelimiter..tooltipColor(self.options.colors.first, list[i][2]).." "..tooltipColor(self.options.colors.second, count)
 			total = total + count
 		end
 	end
@@ -825,12 +826,10 @@ function BSYC:CreateItemTotals(countTable)

 	--if it's groupped up and has more then one item then use a different color and show total
 	if grouped > 1 then
-		local totalStr = tooltipColor(self.options.colors.first, total)
-		return totalStr .. tooltipColor(self.options.colors.second, format(" (%s)", info))
-	else
-		return tooltipColor(self.options.colors.first, info)
+		info = tooltipColor(self.options.colors.second, total).." ("..info..")"
 	end

+	return info
 end

 function BSYC:GetClassColor(sName, sClass)
@@ -910,7 +909,8 @@ function BSYC:AddItemToTooltip(frame, link) --workaround
 			for i = 1, #self.PreviousItemTotals do
 				local ename, ecount  = strsplit("@", self.PreviousItemTotals[i])
 				if ename and ecount then
-					frame:AddDoubleLine(ename, ecount)
+					local color = self.options.colors.total
+					frame:AddDoubleLine(ename, ecount, color.r, color.g, color.b, color.r, color.g, color.b)
 				end
 			end
 		end
@@ -1038,7 +1038,8 @@ function BSYC:AddItemToTooltip(frame, link) --workaround
 		for i = 1, #self.PreviousItemTotals do
 			local ename, ecount  = strsplit("@", self.PreviousItemTotals[i])
 			if ename and ecount then
-				frame:AddDoubleLine(ename, ecount)
+				local color = self.options.colors.total
+				frame:AddDoubleLine(ename, ecount, color.r, color.g, color.b, color.r, color.g, color.b)
 			end
 		end
 	end
diff --git a/locale/deDE.lua b/locale/deDE.lua
index a976594..432ce3a 100644
--- a/locale/deDE.lua
+++ b/locale/deDE.lua
@@ -6,14 +6,14 @@ if not L then return end

 --special thanks to GrimPala from wowinterface.com

-L.TooltipBag = "Taschen: %d"
-L.TooltipBank = "Bank: %d"
-L.TooltipEquip = "Angelegt: %d"
-L.TooltipGuild = "Gilde: %d"
-L.TooltipMail = "Post: %d"
-L.TooltipVoid = "Leerenlager"
-L.TooltipReagent = "Materiallager: %d"
-L.TooltipAuction = "AH: %d"
+L.TooltipBag = "Taschen:"
+L.TooltipBank = "Bank:"
+L.TooltipEquip = "Angelegt:"
+L.TooltipGuild = "Gilde:"
+L.TooltipMail = "Post:"
+L.TooltipVoid = "Leerenlager:"
+L.TooltipReagent = "Materiallager:"
+L.TooltipAuction = "AH:"
 L.Search = "Suche"
 L.TooltipTotal = "Gesamt:"
 L.Profiles = "Profile"
diff --git a/locale/enUS.lua b/locale/enUS.lua
index 33fdd45..0bbb64a 100644
--- a/locale/enUS.lua
+++ b/locale/enUS.lua
@@ -2,14 +2,14 @@
 local L = LibStub("AceLocale-3.0"):NewLocale("BagSync", "enUS", true)
 if not L then return end

-L.TooltipBag = "Bags: %d"
-L.TooltipBank = "Bank: %d"
-L.TooltipEquip = "Equip: %d"
-L.TooltipGuild = "Guild: %d"
-L.TooltipMail = "Mail: %d"
-L.TooltipVoid = "Void: %d"
-L.TooltipReagent = "Reagent: %d"
-L.TooltipAuction = "AH: %d"
+L.TooltipBag = "Bags:"
+L.TooltipBank = "Bank:"
+L.TooltipEquip = "Equip:"
+L.TooltipGuild = "Guild:"
+L.TooltipMail = "Mail:"
+L.TooltipVoid = "Void:"
+L.TooltipReagent = "Reagent:"
+L.TooltipAuction = "AH:"
 L.TooltipTotal = "Total:"
 L.TooltipDelimiter = ", "
 L.Search = "Search"
diff --git a/locale/esES.lua b/locale/esES.lua
index f18eeff..7d539bc 100644
--- a/locale/esES.lua
+++ b/locale/esES.lua
@@ -6,14 +6,14 @@ if not L then return end

 --special thanks to annthizze at Curse for the esES translations!

-L.TooltipBag = "Bolsas: %d"
-L.TooltipBank = "Banco: %d"
-L.TooltipEquip = "Equipo: %d"
-L.TooltipGuild = "Hermandad: %d"
-L.TooltipMail = "Correo: %d"
-L.TooltipVoid = "Cofre Etéreo: %d"
-L.TooltipReagent = "Reagentes: %d"
-L.TooltipAuction = "Subasta: %d"
+L.TooltipBag = "Bolsas:"
+L.TooltipBank = "Banco:"
+L.TooltipEquip = "Equipo:"
+L.TooltipGuild = "Hermandad:"
+L.TooltipMail = "Correo:"
+L.TooltipVoid = "Cofre Etéreo:"
+L.TooltipReagent = "Reagentes:"
+L.TooltipAuction = "Subasta:"
 L.Search = "Buscar"
 L.TooltipTotal = "Total:"
 L.Profiles = "Perfiles"
diff --git a/locale/frFR.lua b/locale/frFR.lua
index 9f3c8c3..9e53298 100644
--- a/locale/frFR.lua
+++ b/locale/frFR.lua
@@ -6,7 +6,7 @@ if not L then return end

 --Really wish someone would do the french translation

-L.TooltipBag = "Sacs: %d"
-L.TooltipBank = "Banque: %d"
-L.TooltipEquip = "Équipé: %d"
-L.TooltipGuild = "Guilde: %d"
\ No newline at end of file
+L.TooltipBag = "Sacs:"
+L.TooltipBank = "Banque:"
+L.TooltipEquip = "Équipé:"
+L.TooltipGuild = "Guilde:"
\ No newline at end of file
diff --git a/locale/koKR.lua b/locale/koKR.lua
index 18ea9d6..34b10de 100644
--- a/locale/koKR.lua
+++ b/locale/koKR.lua
@@ -4,14 +4,14 @@ if not L then return end

 --PLEASE LOOK AT enUS.lua for a complete localization list

-L.TooltipBag = "가방: %d"
-L.TooltipBank = "은행: %d"
-L.TooltipEquip = "착용중: %d"
-L.TooltipGuild = "길드은행: %d"
-L.TooltipMail = "우편함: %d"
-L.TooltipVoid = "공허보관소: %d"
-L.TooltipReagent = "재료은행: %d"
-L.TooltipAuction = "경매장: %d"
+L.TooltipBag = "가방:"
+L.TooltipBank = "은행:"
+L.TooltipEquip = "착용중:"
+L.TooltipGuild = "길드은행:"
+L.TooltipMail = "우편함:"
+L.TooltipVoid = "공허보관소:"
+L.TooltipReagent = "재료은행:"
+L.TooltipAuction = "경매장:"
 L.Search = "검색"
 L.TooltipTotal = "총:"
 L.Profiles = "프로필"
diff --git a/locale/ptBR.lua b/locale/ptBR.lua
index 4ea77c2..209534b 100644
--- a/locale/ptBR.lua
+++ b/locale/ptBR.lua
@@ -6,16 +6,16 @@ if not L then return end

 --special thanks to kubito from wowinterface.com

-L.TooltipBag = "Bolsa: %d"
-L.TooltipBank = "Banco: %d"
-L.TooltipEquip = "Equipado: %d"
-L.TooltipGuild = "Guilda: %d"
-L.TooltipMail = "Correio: %d"
-L.TooltipVoid = "Cofre Etéreo: %d"
-L.TooltipReagent = "Banco de Reagentes: %d"
-L.TooltipAuction = "Casa de Leilão: %d"
+L.TooltipBag = "Bolsa:"
+L.TooltipBank = "Banco:"
+L.TooltipEquip = "Equipado:"
+L.TooltipGuild = "Guilda:"
+L.TooltipMail = "Correio:"
+L.TooltipVoid = "Cofre Etéreo:"
+L.TooltipReagent = "Reagentes:"
+L.TooltipAuction = "Leilão:"
 L.Search = "Pesquisar"
-L.TooltipTotal = "Total"
+L.TooltipTotal = "Total:"
 L.Profiles = "Perfis"
 L.Professions = "Profissões"
 L.Blacklist = "Lista Negra"
diff --git a/locale/ruRU.lua b/locale/ruRU.lua
index 1e42d77..1d3e4f5 100644
--- a/locale/ruRU.lua
+++ b/locale/ruRU.lua
@@ -6,13 +6,13 @@ if not L then return end

 --special thanks to senryo

-L.TooltipBag = "В сумке: %d"
-L.TooltipBank = "В банке: %d"
-L.TooltipEquip = "На персонаже: %d"
-L.TooltipGuild = "В гильдбанке: %d"
-L.TooltipMail = "На почте: %d"
-L.TooltipReagent = "Банк материалов: %d"
-L.TooltipAuction = "Аукцион: %d"
+L.TooltipBag = "В сумке:"
+L.TooltipBank = "В банке:"
+L.TooltipEquip = "На персонаже:"
+L.TooltipGuild = "В гильдбанке:"
+L.TooltipMail = "На почте:"
+L.TooltipReagent = "Банк материалов:"
+L.TooltipAuction = "Аукцион:"
 L.Search = "Поиск"
 L.TooltipTotal = "Всего:"
 L.Profiles = "Профили"
diff --git a/locale/zhCN.lua b/locale/zhCN.lua
index 3c014b2..006d69f 100644
--- a/locale/zhCN.lua
+++ b/locale/zhCN.lua
@@ -6,15 +6,15 @@ if not L then return end

 --special thanks to ytzyt at Curse for the zhCN and zhTW translations!

-L.TooltipBag = "背包: %d"
-L.TooltipBank = "银行: %d"
-L.TooltipEquip = "已装备: %d"
-L.TooltipMail = "信箱: %d"
-L.TooltipVoid = "虚空仓库: %d"
-L.TooltipReagent = "材料银行: %d"
-L.TooltipAuction = "拍卖: %d"
+L.TooltipBag = "背包:"
+L.TooltipBank = "银行:"
+L.TooltipEquip = "已装备:"
+L.TooltipMail = "信箱:"
+L.TooltipVoid = "虚空仓库:"
+L.TooltipReagent = "材料银行:"
+L.TooltipAuction = "拍卖:"
 L.Search = "搜索"
-L.TooltipTotal = "总计: "
+L.TooltipTotal = "总计:"
 L.Profiles = "设定档"
 L.Professions = "专业"
 L.Blacklist = "忽略例表"
diff --git a/locale/zhTW.lua b/locale/zhTW.lua
index bdc432d..98e9786 100644
--- a/locale/zhTW.lua
+++ b/locale/zhTW.lua
@@ -6,16 +6,16 @@ if not L then return end

 --special thanks to ytzyt at Curse for the zhCN and zhTW translations!

-L.TooltipBag = "背包: %d"
-L.TooltipBank = "銀行: %d"
-L.TooltipEquip = "已裝備: %d"
-L.TooltipGuild = "公會倉: %d"
-L.TooltipMail = "信箱: %d"
-L.TooltipVoid = "虛空倉庫: %d"
-L.TooltipReagent = "材料銀行: %d"
-L.TooltipAuction = "拍賣: %d"
+L.TooltipBag = "背包:"
+L.TooltipBank = "銀行:"
+L.TooltipEquip = "已裝備:"
+L.TooltipGuild = "公會倉:"
+L.TooltipMail = "信箱:"
+L.TooltipVoid = "虛空倉庫:"
+L.TooltipReagent = "材料銀行:"
+L.TooltipAuction = "拍賣:"
 L.Search = "搜索"
-L.TooltipTotal = "總: "
+L.TooltipTotal = "總:"
 L.Profiles = "設定檔"
 L.Professions = "專業"
 L.Blacklist = "忽略例表"