363a2bf - Add Devo missing warning and decrease size of Divine Purpose proc
[wowui.git] / OmaTMW / TirnaHelper.lua
1 -- TirnaHelper.lua
2 local _;
3 local frame = CreateFrame("Frame", "OmaTirna", UIParent);
4
5 local function init()
6     local frames = {};
7     frame:UnregisterAllEvents();
8     frame:SetPoint("TOP", UIParent, "TOP", -300, -250);
9     frame:SetWidth(1);
10     frame:SetHeight(1);
11     for i = 0,2 do
12         for j = 0,3 do
13             local button = CreateFrame("CheckButton", "OmaTirna"..i..j, frame);
14             button:SetPoint("TOPLEFT", frame, "TOPLEFT", i*52, j*42);
15             button:SetWidth(52);
16             button:SetHeight(42);
17             button.bg = button:CreateTexture(nil, "BACKGROUND");
18             button.bg:SetAllPoints();
19             button.bg:SetColorTexture(1, 1, 1);
20             button.bg:SetVertexColor(0.2, 0.2, 0.2, 0.3);
21             button.normal = button:CreateTexture(nil, "BORDER");
22             button.normal:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2);
23             button.normal:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2);
24             button.normal:SetColorTexture(0.5, 0.5, 0.5);
25             button:SetNormalTexture(button.normal);
26             button.check = button:CreateTexture(nil, "BORDER");
27             button.check:SetPoint("TOPLEFT", button, "TOPLEFT", 2, -2);
28             button.check:SetPoint("BOTTOMRIGHT", button, "BOTTOMRIGHT", -2, 2);
29             button.check:SetColorTexture(0.9, 0.9, 0.9);
30             button:SetCheckedTexture(button.check);
31             button:SetScript("OnClick", function(self)
32                 for i = 0,2 do
33                     local x = 0;
34                     local check, notcheck;
35                     for j = 0,3 do
36                         local f = frames[i*4+j+1];
37                         f.bg:SetVertexColor(0.2, 0.2, 0.2, 0.3);
38                         if f:GetChecked() then
39                             x = x + 1;
40                             check = f;
41                         else
42                             notcheck = f;
43                         end
44                     end
45                     if x == 1 then
46                         check.bg:SetVertexColor(1, 0.2, 0.1, 0.9);
47                     elseif x == 3 then
48                         notcheck.bg:SetVertexColor(1, 0.2, 0.1, 0.9);
49                     end
50                 end
51             end);
52             frames[i*4+j+1] = button;
53         end
54     end
55     local button = CreateFrame("Button", "OmaTirnaReset", frame);
56     button:SetPoint("TOPRIGHT", frame, "TOPLEFT", -2, 0);
57     button:SetWidth(52);
58     button:SetHeight(42);
59     button.normal = button:CreateTexture(nil, "BACKGROUND");
60     button.normal:SetAllPoints();
61     button.normal:SetColorTexture(0.4, 0.4, 0.4);
62     button:SetNormalTexture(button.normal);
63     button:SetScript("OnClick", function()
64         for _, f in ipairs(frames) do
65             f:SetChecked(false);
66             f.bg:SetVertexColor(0.2, 0.2, 0.2, 0.3);
67         end
68     end);
69     frame.leaf = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
70     frame.leaf:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 42*3);
71     frame.leaf:SetText("Lehti");
72     frame.fill = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
73     frame.fill:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 52, 42*3);
74     frame.fill:SetText("Täysi");
75     frame.circle = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
76     frame.circle:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 104, 42*3);
77     frame.circle:SetText("Kehä");
78     frame:Hide();
79 end
80
81 frame:SetScript("OnEvent", init);
82 frame:RegisterEvent("PLAYER_LOGIN");
83
84 SLASH_OMATIRNA1 = "/tirna";
85 function SlashCmdList.OMATIRNA()
86     if frame:IsShown() then
87         frame:Hide();
88     else
89         frame:Show();
90     end
91 end