/Tukui/modules/datatext/currency.lua
http://github.com/Asphyxia/Tukui · Lua · 43 lines · 34 code · 6 blank · 3 comment · 9 complexity · e3b6d17bed512357ea220a8f712a5b67 MD5 · raw file
- local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
- --------------------------------------------------------------------
- -- CURRENCY
- --------------------------------------------------------------------
- if C["datatext"].currency and C["datatext"].currency > 0 then
- local Stat = CreateFrame("Frame")
- Stat:EnableMouse(true)
- Stat:SetFrameStrata("BACKGROUND")
- Stat:SetFrameLevel(3)
- local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
- Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
- T.PP(C["datatext"].currency, Text)
-
- local function update()
- local _text = T.datacolor.."---"
- for i = 1, MAX_WATCHED_TOKENS do
- local name, count, _, _, _ = GetBackpackCurrencyInfo(i)
- if name and count then
- if(i ~= 1) then _text = _text .. " " else _text = "" end
- words = { strsplit(" ", name) }
- for _, word in ipairs(words) do
- _text = _text .. string.sub(word,1,1)
- end
- _text = _text .. ": " .. T.datacolor .. count .. "|r"
- end
- end
-
- Text:SetText(_text)
- end
-
- local function OnEvent(self, event, ...)
- update()
- self:SetAllPoints(Text)
- Stat:UnregisterEvent("PLAYER_LOGIN")
- end
- Stat:RegisterEvent("PLAYER_LOGIN")
- hooksecurefunc("BackpackTokenFrame_Update", update)
- Stat:SetScript("OnEvent", OnEvent)
- Stat:SetScript("OnMouseDown", function() ToggleCharacter("TokenFrame") end)
- end