From 24a0a17720d738d451757ef086a61a9989bbca7d Mon Sep 17 00:00:00 2001 From: tekkub Date: Sun, 2 May 2010 16:20:55 -0600 Subject: [PATCH] Name that space! --- GnomishVendorShrinker.lua | 24 ++++++------------------ GnomishVendorShrinker.toc | 1 + KnownScanner.lua | 7 +++---- tekFunks/gsc.lua | 19 +++++++++++++++++++ 4 files changed, 29 insertions(+), 22 deletions(-) create mode 100644 tekFunks/gsc.lua diff --git a/GnomishVendorShrinker.lua b/GnomishVendorShrinker.lua index 89fe53f..f45ca4d 100644 --- a/GnomishVendorShrinker.lua +++ b/GnomishVendorShrinker.lua @@ -1,8 +1,8 @@ +local myname, ns = ... + local NUMROWS, ICONSIZE, GAP, SCROLLSTEP = 14, 17, 4, 5 -local knowns = GVS_SCANNER local HONOR_POINTS, ARENA_POINTS = "|cffffffff|Hitem:43308:0:0:0:0:0:0:0:0|h[Honor Points]|h|r", "|cffffffff|Hitem:43307:0:0:0:0:0:0:0:0|h[Arena Points]|h|r" -GVS_SCANNER = nil for _,f in pairs{MerchantNextPageButton, MerchantPrevPageButton, MerchantPageText} do @@ -88,18 +88,6 @@ local function OnLeave() end -local function GSC(cash) - if not cash then return end - local g, s, c = floor(cash/10000), floor((cash/100)%100), cash%100 - if g > 0 and s == 0 and c == 0 then return string.format(" |cffffd700%d", g) - elseif g > 0 and c == 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d", g, s) - elseif g > 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d.|cffeda55f%02d", g, s, c) - elseif s > 0 and c == 0 then return string.format(" |cffc7c7cf%d", s) - elseif s > 0 then return string.format(" |cffc7c7cf%d.|cffeda55f%02d", s, c) - else return string.format(" |cffeda55f%02d", c) end -end - - local function SetValue(self, text, icon, link) self.text:SetText(text) self.icon:SetTexture(icon) @@ -214,7 +202,7 @@ for i=1,NUMROWS do popout.SplitStack = PopoutSplitStack row.popout = popout - local ItemPrice = row:CreateFontString(nil, nil, "NumberFontNormalSmall") + local ItemPrice = row:CreateFontString(nil, nil, "NumberFontNormal") ItemPrice:SetPoint('RIGHT', popout, "LEFT", -2, 0) row.ItemPrice = ItemPrice @@ -268,7 +256,7 @@ local function Refresh() local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link) color = quality_colors[quality] - if class == RECIPE and not knowns[link] then + if class == RECIPE and not ns.knowns[link] then row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads[quality])) row.backdrop:Show() end @@ -291,14 +279,14 @@ local function Refresh() row.link, row.texture, row.extendedCost = link, itemTexture, true end if itemPrice > 0 then - row.ItemPrice:SetText(GSC(itemPrice)) + row.ItemPrice:SetText(ns.GSC(itemPrice)) row.Price = itemPrice end if extendedCost and (itemPrice <= 0) then row.ItemPrice:SetText() row.Price = 0 elseif extendedCost and (itemPrice > 0) then - row.ItemPrice:SetText(GSC(itemPrice)) + row.ItemPrice:SetText(ns.GSC(itemPrice)) else row.ItemName:SetPoint("RIGHT", row.ItemPrice, "LEFT", -GAP, 0) row.extendedCost = nil diff --git a/GnomishVendorShrinker.toc b/GnomishVendorShrinker.toc index 8278996..fe30c7b 100644 --- a/GnomishVendorShrinker.toc +++ b/GnomishVendorShrinker.toc @@ -11,6 +11,7 @@ ## LoadManagers: AddonLoader ## X-LoadOn-Merchant: true +tekFunks\gsc.lua tekKonfig\tekKonfig.xml KnownScanner.lua diff --git a/KnownScanner.lua b/KnownScanner.lua index a2759a8..552ecf4 100644 --- a/KnownScanner.lua +++ b/KnownScanner.lua @@ -1,15 +1,16 @@ +local myname, ns = ... + local tip = CreateFrame("GameTooltip") tip:SetOwner(WorldFrame, "ANCHOR_NONE") local lcache = {} for i=1,40 do lcache[i] = tip:CreateFontString() - -- lcache[i]:SetFontObject(GameFontNormal) tip:AddFontStrings(lcache[i], tip:CreateFontString()) end -local knowns = setmetatable({}, {__index = function(t, i) +ns.knowns = setmetatable({}, {__index = function(t, i) tip:ClearLines() if not tip:IsOwned(WorldFrame) then tip:SetOwner(WorldFrame, "ANCHOR_NONE") end tip:SetHyperlink(i) @@ -20,5 +21,3 @@ local knowns = setmetatable({}, {__index = function(t, i) end end end}) - -GVS_SCANNER = knowns diff --git a/tekFunks/gsc.lua b/tekFunks/gsc.lua new file mode 100644 index 0000000..69ce85e --- /dev/null +++ b/tekFunks/gsc.lua @@ -0,0 +1,19 @@ + +local myname, ns = ... + +function ns.GSC(cash, colorblind) + if not cash then return end + local g, s, c = floor(cash/10000), floor((cash/100)%100), cash%100 + if colorblind or GetCVarBool("colorblindMode") then + if g > 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d.|cffeda55f%02d", g, s, c) + elseif s > 0 then return string.format(" |cffc7c7cf%d.|cffeda55f%02d", s, c) + else return string.format(" |cffeda55f%d", c) end + else + if g > 0 and s == 0 and c == 0 then return string.format(" |cffffd700%d", g) + elseif g > 0 and c == 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d", g, s) + elseif g > 0 then return string.format(" |cffffd700%d.|cffc7c7cf%02d.|cffeda55f%02d", g, s, c) + elseif s > 0 and c == 0 then return string.format(" |cffc7c7cf%d", s) + elseif s > 0 then return string.format(" |cffc7c7cf%d.|cffeda55f%02d", s, c) + else return string.format(" |cffeda55f%d", c) end + end +end