3 local unpack, pairs, rawget = unpack, pairs, rawget;
4 local UnitHealthMax, UnitPowerMax = UnitHealthMax, UnitPowerMax;
5 local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
6 local SPELL_POWER_MANA = SPELL_POWER_MANA;
11 -- configurable settings
12 M.Positions = {"TOPRIGHT", "BOTTOMLEFT"};
13 M.Width, M.Height = 80, 40;
14 M.AnchorX, M.AnchorY = 0, -330;
16 M.BaseColor = {0, 0, 0};
17 M.BgColor = {0.7, 0.7, 0.7};
18 M.HealthColor = {0.3, 0.3, 0.3};
19 M.ShieldColor = {0, 0.7, 1};
20 M.ShieldhlColor = {0.5, 0.8, 1};
21 M.HealpredColor = {0.5, 0.6, 0.5};
22 M.HealabsorbColor = {0.1, 0.1, 0.1};
23 M.OverlayColorDispel = {1, 0.5, 0, 0.5};
24 M.OverlayColorCharm = {0.8, 0, 1, 0.5};
25 M.OverlayColorAlert = {1, 0, 0, 0.5};
27 [SPELL_POWER_MANA] = {0, 0.5, 1},
28 [SPELL_POWER_RAGE] = {1, 0, 0},
29 [SPELL_POWER_FOCUS] = {1, 0.5, 0},
30 [SPELL_POWER_ENERGY] = {1, 0.8, 0},
31 [SPELL_POWER_RUNIC_POWER] = {0.9, 0, 0.1},
33 -- watch to not remove mana entry
34 setmetatable(M.PowerColors, {__index = function(t) return rawget(t, SPELL_POWER_MANA) end});
36 local positions = M.Positions;
37 local width, height = M.Width, M.Height;
38 local indSize = M.IndSize;
39 local baseColor = M.BaseColor;
40 local bgColor = M.BgColor;
41 local healthColor = M.HealthColor;
42 local shieldColor = M.ShieldColor;
43 local shieldhlColor = M.ShieldhlColor;
44 local healpredColor = M.HealpredColor;
45 local healabsorbColor = M.HealabsorbColor;
47 local function setupIndicators(frame)
48 frame.inds = CreateFrame("Frame", nil, frame);
49 frame.inds:SetAllPoints();
51 for _, pos in pairs(positions) do
52 frame.inds[pos] = frame.inds:CreateTexture(nil, "OVERLAY");
53 frame.inds[pos]:SetPoint(pos, frame.inds, pos);
54 frame.inds[pos]:SetWidth(indSize);
55 frame.inds[pos]:SetHeight(indSize);
56 frame.inds[pos]:SetTexture("Interface\\AddOns\\OmaRF\\images\\rhomb");
57 frame.inds[pos]:SetVertexColor(1, 0, 0);
58 frame.inds[pos]:Hide();
59 frame.inds[pos].text = frame.inds:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
60 frame.inds[pos].text:SetPoint("BOTTOMRIGHT", frame.inds[pos], "BOTTOMRIGHT");
61 frame.inds[pos].text:Hide();
63 frame.major = CreateFrame("Frame", nil, frame);
64 frame.major:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -indSize + 4);
65 frame.major:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT");
67 frame.major[i] = frame.major:CreateTexture(nil, "OVERLAY");
69 frame.major[i]:SetPoint("TOPLEFT", frame.major, "TOPLEFT");
71 frame.major[i]:SetPoint("TOPLEFT", frame.major[i-1], "TOPLEFT");
73 frame.major[i]:SetWidth(indSize*2);
74 frame.major[i]:SetHeight(indSize*2);
75 frame.major[i]:Hide();
76 frame.major[i].text = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
77 frame.major[i].text:SetPoint("BOTTOMRIGHT", frame.major[i], "BOTTOMRIGHT");
78 frame.major[i].text:Hide();
79 frame.major[i].stack = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
80 frame.major[i].stack:SetPoint("TOPLEFT", frame.major[i], "TOPLEFT");
81 frame.major[i].stack:Hide();
85 local function setupFrame(frame, secure, unit)
87 secure:SetWidth(width+2);
88 frame:SetWidth(width+2);
89 frame.base = frame:CreateTexture(nil, "BACKGROUND");
90 frame.base:SetAllPoints();
91 frame.base:SetColorTexture(unpack(baseColor));
92 frame.background = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
93 frame.background:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
94 frame.background:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
95 frame.background:SetColorTexture(unpack(bgColor));
96 frame.health = frame:CreateTexture(nil, "BORDER");
97 frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
98 frame.health:SetPoint("TOPLEFT", frame.background, "TOPLEFT");
99 frame.health:SetPoint("BOTTOMLEFT", frame.background, "BOTTOMLEFT", 0, 2);
100 frame.health:SetVertexColor(unpack(healthColor));
101 frame.health:SetWidth(width);
102 frame.health.max = UnitHealthMax(unit);
103 frame.mana = frame:CreateTexture(nil, "BORDER");
104 frame.mana:SetPoint("TOPLEFT", frame.background, "BOTTOMLEFT", 0, 2);
105 frame.mana:SetPoint("BOTTOMLEFT", frame.background, "BOTTOMLEFT");
106 frame.mana:SetColorTexture(1, 1, 1);
107 frame.mana:SetWidth(width);
108 frame.mana.max = UnitPowerMax(unit);
109 frame.shield = frame:CreateTexture(nil, "BORDER");
110 frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
111 frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
112 frame.shield:SetColorTexture(unpack(shieldColor));
114 frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
115 frame.shieldhl:SetPoint("TOPLEFT", frame.background, "TOPRIGHT", -1, 0);
116 frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", 1, 0);
117 frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
118 frame.shieldhl:Hide();
119 frame.healpred = frame:CreateTexture(nil, "ARTWORK");
120 frame.healpred:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
121 frame.healpred:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
122 frame.healpred:SetColorTexture(unpack(healpredColor));
123 frame.healpred:Hide();
124 frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
125 frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
126 frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
127 frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
128 frame.healabsorb:Hide();
129 frame.overlay = frame:CreateTexture(nil, "ARTWORK", nil, 1);
130 frame.overlay:SetPoint("TOPLEFT", frame.background, "TOPLEFT");
131 frame.overlay:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", 0, 2);
132 frame.overlay:Hide();
133 frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
134 frame.name:SetPoint("CENTER", frame.background, "CENTER", 0, 11);
135 frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
136 frame.text:SetFont(STANDARD_TEXT_FONT, 13);
137 frame.text:SetPoint("CENTER", frame.background, "CENTER", 0, -1);
139 setupIndicators(frame);
141 secure:RegisterForClicks("AnyDown");
142 secure:SetAttribute("type1", "spell"); -- left click
143 secure:SetAttribute("type2", "spell"); -- right click
144 secure:SetAttribute("shift-type1", "spell"); -- shift left click
145 secure:SetAttribute("shift-type2", "spell"); -- shift right click
146 secure:SetAttribute("ctrl-type1", "spell"); -- ctrl left click
147 secure:SetAttribute("alt-type2", "spell"); -- alt right click
148 secure:SetAttribute("alt-shift-type1", "spell"); -- alt+shift left click
149 secure:SetAttribute("alt-shift-type2", "spell"); -- alt+shift right click
150 secure:SetAttribute("spell1", "Holy Light");
151 secure:SetAttribute("spell2", "Bestow Faith");
152 secure:SetAttribute("shift-spell1", "Flash of Light");
153 secure:SetAttribute("shift-spell2", "Light of the Martyr");
154 secure:SetAttribute("ctrl-spell1", "Cleanse");
155 secure:SetAttribute("alt-spell2", "Lay on Hands");
156 secure:SetAttribute("alt-shift-spell1", "Beacon of Light");
157 secure:SetAttribute("alt-shift-spell2", "Beacon of Faith");
158 -- rest give target and menu
159 secure:SetAttribute("*type1", "target");
160 secure:SetAttribute("*type2", "togglemenu");
163 function M.InitializeParty(parent, party, eventhandler)
164 local secure = CreateFrame("Button", "OmaPartySecure0", parent, "SecureUnitButtonTemplate");
165 local frame = CreateFrame("Frame", "OmaParty0", parent);
166 local unit = "player";
167 secure:SetAttribute("unit", unit);
168 secure:SetPoint("TOPLEFT", parent, "TOPLEFT");
169 secure:SetHeight(height+2);
171 frame:SetPoint("TOPLEFT", parent, "TOPLEFT");
172 frame:SetHeight(height+2);
173 frame:SetScript("OnEvent", eventhandler);
175 setupFrame(frame, secure, unit);
176 RegisterStateDriver(secure, "visibility", "[@player,group:raid] hide; show");
177 party[0] = {secure=secure, frame=frame};
179 local secure = CreateFrame("Button", "OmaPartySecure"..i, parent, "SecureUnitButtonTemplate");
180 local frame = CreateFrame("Frame", "OmaParty"..i, parent);
181 local unit = "party"..i;
182 secure:SetAttribute("unit", unit);
183 secure:SetPoint("TOPLEFT", party[i-1].secure, "TOPRIGHT");
184 secure:SetPoint("BOTTOMLEFT", party[i-1].secure, "BOTTOMRIGHT");
186 frame:SetPoint("TOPLEFT", party[i-1].frame, "TOPRIGHT");
187 frame:SetPoint("BOTTOMLEFT", party[i-1].frame, "BOTTOMRIGHT");
188 frame:SetScript("OnEvent", unitEvent);
190 setupFrame(frame, secure, unit);
191 RegisterUnitWatch(secure);
192 party[i] = {secure=secure, frame=frame};
196 function M.InitializeRaid(parent, raid, eventhandler)
197 local secure = CreateFrame("Button", "OmaRaidSecure1", parent, "SecureUnitButtonTemplate");
198 local frame = CreateFrame("Frame", "OmaRaid1", parent);
199 local unit = "raid1";
200 secure:SetAttribute("unit", unit);
201 secure:SetPoint("TOPLEFT", parent, "TOPLEFT");
202 secure:SetHeight(height+2);
204 frame:SetPoint("TOPLEFT", parent, "TOPLEFT");
205 frame:SetHeight(height+2);
206 frame:SetScript("OnEvent", eventhandler);
208 setupFrame(frame, secure, unit);
209 RegisterUnitWatch(secure);
210 raid[1] = {secure=secure, frame=frame};
213 local secure = CreateFrame("Button", "OmaRaidSecure"..i, parent, "SecureUnitButtonTemplate");
214 local frame = CreateFrame("Frame", "OmaRaid"..i, parent);
215 local unit = "raid"..i;
216 secure:SetAttribute("unit", unit);
217 secure:SetPoint("TOPLEFT", raid[i-5].secure, "BOTTOMLEFT");
218 secure:SetHeight(height+2);
220 frame:SetPoint("TOPLEFT", raid[i-5].frame, "BOTTOMLEFT");
221 frame:SetHeight(height+2);
222 frame:SetScript("OnEvent", unitEvent);
224 setupFrame(frame, secure, unit);
225 RegisterUnitWatch(secure);
226 raid[i] = {secure=secure, frame=frame};
231 local secure = CreateFrame("Button", "OmaRaidSecure"..i, parent, "SecureUnitButtonTemplate");
232 local frame = CreateFrame("Frame", "OmaRaid"..i, parent);
233 local unit = "raid"..i;
234 secure:SetAttribute("unit", unit);
235 secure:SetPoint("TOPLEFT", raid[i-1].secure, "TOPRIGHT");
236 secure:SetPoint("BOTTOMLEFT", raid[i-1].secure, "BOTTOMRIGHT");
238 frame:SetPoint("TOPLEFT", raid[i-1].frame, "TOPRIGHT");
239 frame:SetPoint("BOTTOMLEFT", raid[i-1].frame, "BOTTOMRIGHT");
240 frame:SetScript("OnEvent", unitEvent);
242 setupFrame(frame, secure, unit);
243 RegisterUnitWatch(secure);
244 raid[i] = {secure=secure, frame=frame};