9720910 - Bump TOCs for 9.1
[wowui.git] / OmaTMW / GiftTracker.lua
1 -- GiftTracker.lua
2 local _;
3 local GetTime = GetTime;
4 local frame = CreateFrame("Cooldown", "OmaGiftCD", UIParent, "CooldownFrameTemplate");
5 local line = CreateFrame("Frame", "OmaLine", UIParent);
6 local playerGuid = nil;
7
8 local function clog(ts, event, _, source, _, _, _, dest, _, _, _, spellid, ...)
9     if event == "SPELL_AURA_APPLIED" and spellid == 312406 and dest == playerGuid then
10         line:Show();
11     elseif event == "SPELL_AURA_REMOVED" and spellid == 312406 and dest == playerGuid then
12         line:Hide();
13     end
14 end
15
16 local function gift()
17     frame:SetPoint("TOPLEFT", UIParent, "TOPLEFT", 500, -400);
18     frame:SetPoint("BOTTOMRIGHT", UIParent, "TOPLEFT", 580, -480);
19     frame.base = frame:CreateTexture(nil, "BACKGROUND");
20     frame.base:SetAllPoints();
21     frame.base:SetColorTexture(0, 0, 0, 0.5);
22     frame.stone = frame:CreateTexture(nil, "BORDER");
23     frame.stone:SetPoint("TOPLEFT", frame.base, "TOPLEFT", 1, -1);
24     frame.stone:SetPoint("BOTTOMRIGHT", frame.base, "BOTTOMRIGHT", -1, 1);
25     frame.stone:SetTexCoord(0.07, 0.93, 0.07, 0.93);
26     frame.stone:SetTexture(2000853); -- Gift Texture
27     frame:Hide();
28
29     playerGuid = UnitGUID("player");
30     frame:UnregisterAllEvents();
31     frame:SetScript("OnEvent", function()
32         return clog(CombatLogGetCurrentEventInfo());
33     end);
34     frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
35 end
36
37 frame:SetScript("OnEvent", gift);
38 frame:RegisterEvent("PLAYER_LOGIN");
39
40 local function lineConf()
41     line:SetPoint("CENTER", UIParent, "CENTER", 0, 100);
42     line:SetHeight(350);
43     line:SetWidth(5);
44     line.base = line:CreateTexture(nil, "BACKGROUND");
45     line.base:SetAllPoints();
46     line.base:SetColorTexture(1, 1, 1, 0.85);
47     line:Hide();
48     line:UnregisterAllEvents();
49     line:SetScript("OnEvent", function()
50         return clog(CombatLogGetCurrentEventInfo());
51     end);
52     line:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
53 end
54
55 line:SetScript("OnEvent", lineConf);
56 line:RegisterEvent("PLAYER_LOGIN");