/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

  1. local T, C, L = unpack(select(2, ...)) -- Import: T - functions, constants, variables; C - config; L - locales
  2. --------------------------------------------------------------------
  3. -- CURRENCY
  4. --------------------------------------------------------------------
  5. if C["datatext"].currency and C["datatext"].currency > 0 then
  6. local Stat = CreateFrame("Frame")
  7. Stat:EnableMouse(true)
  8. Stat:SetFrameStrata("BACKGROUND")
  9. Stat:SetFrameLevel(3)
  10. local Text = TukuiInfoLeft:CreateFontString(nil, "OVERLAY")
  11. Text:SetFont(C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
  12. T.PP(C["datatext"].currency, Text)
  13. local function update()
  14. local _text = T.datacolor.."---"
  15. for i = 1, MAX_WATCHED_TOKENS do
  16. local name, count, _, _, _ = GetBackpackCurrencyInfo(i)
  17. if name and count then
  18. if(i ~= 1) then _text = _text .. " " else _text = "" end
  19. words = { strsplit(" ", name) }
  20. for _, word in ipairs(words) do
  21. _text = _text .. string.sub(word,1,1)
  22. end
  23. _text = _text .. ": " .. T.datacolor .. count .. "|r"
  24. end
  25. end
  26. Text:SetText(_text)
  27. end
  28. local function OnEvent(self, event, ...)
  29. update()
  30. self:SetAllPoints(Text)
  31. Stat:UnregisterEvent("PLAYER_LOGIN")
  32. end
  33. Stat:RegisterEvent("PLAYER_LOGIN")
  34. hooksecurefunc("BackpackTokenFrame_Update", update)
  35. Stat:SetScript("OnEvent", OnEvent)
  36. Stat:SetScript("OnMouseDown", function() ToggleCharacter("TokenFrame") end)
  37. end