PageRenderTime 85ms CodeModel.GetById 40ms app.highlight 11ms RepoModel.GetById 29ms app.codeStats 1ms

/Tukui/modules/datatext/profession.lua

http://github.com/Asphyxia/Tukui
Lua | 40 lines | 32 code | 5 blank | 3 comment | 4 complexity | 6b664320640624d5c99f49f1a21fb4ce MD5 | raw file
 1--------------------------------------------------------------------
 2-- Professions
 3--------------------------------------------------------------------
 4local T, C, L = unpack(select(2, ...)) -- Import Functions/Constants, Config, Locales
 5
 6if not C["datatext"].profession or C["datatext"].profession == 0 then return end
 7
 8local Stat = CreateFrame("Frame")
 9Stat:EnableMouse(true)
10Stat:SetFrameStrata("HIGH")
11Stat:SetFrameLevel(3)
12	
13local Text = T.SetFontString(TukuiInfoLeft, C.media.pixelfont, C["datatext"].fontsize, "MONOCHROMEOUTLINE")
14T.PP(C["datatext"].profession, Text)
15
16local function Update(self)
17	for _, v in pairs({GetProfessions()}) do
18		if v ~= nil then
19			local name, texture, rank, maxRank = GetProfessionInfo(v)
20			Text:SetFormattedText(T.datacolor.."Profession")
21		end
22	end
23	self:SetAllPoints(Text)
24end
25
26Stat:SetScript("OnEnter", function()
27	local anchor, panel, xoff, yoff = T.DataTextTooltipAnchor(Text)
28	GameTooltip:SetOwner(panel, anchor, xoff, yoff)
29	GameTooltip:ClearLines()
30	GameTooltip:AddLine(T.myname.."'s Professions", .4,.78,1)
31	for _, v in pairs({GetProfessions()}) do
32		if v ~= nil then
33			local name, texture, rank, maxRank = GetProfessionInfo(v)
34			GameTooltip:AddDoubleLine(name, rank.." / "..maxRank,.75,.9,1,.3,1,.3)
35		end
36	end
37	GameTooltip:Show()
38end)
39Stat:SetScript("OnUpdate", Update)
40Stat:SetScript("OnLeave", function() GameTooltip:Hide() end)