3 local unpack, pairs, rawget = unpack, pairs, rawget;
4 local UnitHealthMax, UnitPowerMax = UnitHealthMax, UnitPowerMax;
5 local CreateFrame, RegisterStateDriver, RegisterUnitWatch = CreateFrame, RegisterStateDriver, RegisterUnitWatch;
6 local PowerTypeMana = Enum.PowerType.Mana;
7 local PowerTypeRage = Enum.PowerType.Rage;
8 local PowerTypeFocus = Enum.PowerType.Focus;
9 local PowerTypeEnergy = Enum.PowerType.Energy;
10 local PowerTypeRunic = Enum.PowerType.RunicPower;
15 -- configurable settings
16 M.Positions = {"TOPRIGHT", "BOTTOMLEFT"};
17 M.Width, M.Height = 80, 40;
18 M.AnchorX, M.AnchorY = 0, -330;
20 M.BaseColor = {0, 0, 0};
21 M.BgColor = {0.7, 0.7, 0.7};
22 M.HealthColor = {0.3, 0.3, 0.3};
23 M.ShieldColor = {0, 0.7, 1};
24 M.ShieldhlColor = {0.5, 0.8, 1};
25 M.HealpredColor = {0.5, 0.6, 0.5};
26 M.HealabsorbColor = {0.1, 0.1, 0.1};
27 M.OverlayColorDispel = {1, 0.5, 0, 0.5};
28 M.OverlayColorCharm = {0.8, 0, 1, 0.5};
29 M.OverlayColorAlert = {1, 0, 0, 0.5};
31 [PowerTypeMana] = {0, 0.5, 1},
32 [PowerTypeRage] = {1, 0, 0},
33 [PowerTypeFocus] = {1, 0.5, 0},
34 [PowerTypeEnergy] = {1, 0.8, 0},
35 [PowerTypeRunic] = {0.9, 0, 0.1},
37 -- watch to not remove mana entry
38 setmetatable(M.PowerColors, {__index = function(t) return rawget(t, PowerTypeMana) end});
40 local positions = M.Positions;
41 local width, height = M.Width, M.Height;
42 local indSize = M.IndSize;
43 local baseColor = M.BaseColor;
44 local bgColor = M.BgColor;
45 local healthColor = M.HealthColor;
46 local shieldColor = M.ShieldColor;
47 local shieldhlColor = M.ShieldhlColor;
48 local healpredColor = M.HealpredColor;
49 local healabsorbColor = M.HealabsorbColor;
51 local function setupIndicators(frame)
52 frame.inds = CreateFrame("Frame", nil, frame);
53 frame.inds:SetAllPoints();
55 for _, pos in pairs(positions) do
56 frame.inds[pos] = frame.inds:CreateTexture(nil, "OVERLAY");
57 frame.inds[pos]:SetPoint(pos, frame.inds, pos);
58 frame.inds[pos]:SetWidth(indSize);
59 frame.inds[pos]:SetHeight(indSize);
60 frame.inds[pos]:SetTexture("Interface\\AddOns\\OmaRF\\images\\rhomb");
61 frame.inds[pos]:SetVertexColor(1, 0, 0);
62 frame.inds[pos]:Hide();
63 frame.inds[pos].text = frame.inds:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
64 frame.inds[pos].text:SetPoint("BOTTOMRIGHT", frame.inds[pos], "BOTTOMRIGHT");
65 frame.inds[pos].text:Hide();
67 frame.major = CreateFrame("Frame", nil, frame);
68 frame.major:SetPoint("TOPLEFT", frame, "TOPLEFT", 4, -indSize + 4);
69 frame.major:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT");
71 frame.major[i] = frame.major:CreateTexture(nil, "OVERLAY");
73 frame.major[i]:SetPoint("TOPLEFT", frame.major, "TOPLEFT");
75 frame.major[i]:SetPoint("TOPLEFT", frame.major[i-1], "TOPLEFT");
77 frame.major[i]:SetWidth(indSize*2);
78 frame.major[i]:SetHeight(indSize*2);
79 frame.major[i]:Hide();
80 frame.major[i].text = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
81 frame.major[i].text:SetPoint("BOTTOMRIGHT", frame.major[i], "BOTTOMRIGHT");
82 frame.major[i].text:Hide();
83 frame.major[i].stack = frame.major:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
84 frame.major[i].stack:SetPoint("TOPLEFT", frame.major[i], "TOPLEFT");
85 frame.major[i].stack:Hide();
89 local function setupFrame(frame, secure, unit)
91 secure:SetWidth(width+2);
92 frame:SetWidth(width+2);
93 frame.base = frame:CreateTexture(nil, "BACKGROUND");
94 frame.base:SetAllPoints();
95 frame.base:SetColorTexture(unpack(baseColor));
96 frame.background = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
97 frame.background:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
98 frame.background:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
99 frame.background:SetColorTexture(unpack(bgColor));
100 frame.health = frame:CreateTexture(nil, "BORDER");
101 frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
102 frame.health:SetPoint("TOPLEFT", frame.background, "TOPLEFT");
103 frame.health:SetPoint("BOTTOMLEFT", frame.background, "BOTTOMLEFT", 0, 2);
104 frame.health:SetVertexColor(unpack(healthColor));
105 frame.health:SetWidth(width);
106 frame.health.max = UnitHealthMax(unit);
107 frame.mana = frame:CreateTexture(nil, "BORDER");
108 frame.mana:SetPoint("TOPLEFT", frame.background, "BOTTOMLEFT", 0, 2);
109 frame.mana:SetPoint("BOTTOMLEFT", frame.background, "BOTTOMLEFT");
110 frame.mana:SetColorTexture(1, 1, 1);
111 frame.mana:SetWidth(width);
112 frame.mana.max = UnitPowerMax(unit);
113 frame.shield = frame:CreateTexture(nil, "BORDER");
114 frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
115 frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
116 frame.shield:SetColorTexture(unpack(shieldColor));
118 frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
119 frame.shieldhl:SetPoint("TOPLEFT", frame.background, "TOPRIGHT", -1, 0);
120 frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", 1, 0);
121 frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
122 frame.shieldhl:Hide();
123 frame.healpred = frame:CreateTexture(nil, "ARTWORK");
124 frame.healpred:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
125 frame.healpred:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
126 frame.healpred:SetColorTexture(unpack(healpredColor));
127 frame.healpred:Hide();
128 frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
129 frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
130 frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
131 frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
132 frame.healabsorb:Hide();
133 frame.overlay = frame:CreateTexture(nil, "ARTWORK", nil, 1);
134 frame.overlay:SetPoint("TOPLEFT", frame.background, "TOPLEFT");
135 frame.overlay:SetPoint("BOTTOMRIGHT", frame.background, "BOTTOMRIGHT", 0, 2);
136 frame.overlay:Hide();
137 frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
138 frame.name:SetPoint("CENTER", frame.background, "CENTER", 0, 11);
139 frame.text = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
140 frame.text:SetFont(STANDARD_TEXT_FONT, 13);
141 frame.text:SetPoint("CENTER", frame.background, "CENTER", 0, -1);
143 setupIndicators(frame);
145 frame:RegisterEvent("PARTY_MEMBER_ENABLE");
146 frame:RegisterEvent("PARTY_MEMBER_DISABLE");
147 frame:RegisterUnitEvent("UNIT_HEALTH", unit);
148 frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", unit);
149 frame:RegisterUnitEvent("UNIT_MAXHEALTH", unit);
150 frame:RegisterUnitEvent("UNIT_POWER", unit);
151 frame:RegisterUnitEvent("UNIT_MAXPOWER", unit);
152 frame:RegisterUnitEvent("UNIT_DISPLAYPOWER", unit);
153 frame:RegisterUnitEvent("UNIT_NAME_UPDATE", unit);
154 frame:RegisterUnitEvent("UNIT_AURA", unit);
155 frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", unit);
156 frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", unit);
157 frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", unit);
158 frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", unit);
159 frame:RegisterUnitEvent("UNIT_CONNECTION", unit);
160 frame:RegisterUnitEvent("INCOMING_RESURRECT_CHANGED", unit);
162 secure:RegisterForClicks("AnyDown");
163 secure:SetAttribute("type1", "spell"); -- left click
164 secure:SetAttribute("type2", "spell"); -- right click
165 secure:SetAttribute("shift-type1", "spell"); -- shift left click
166 secure:SetAttribute("shift-type2", "spell"); -- shift right click
167 secure:SetAttribute("ctrl-type1", "spell"); -- ctrl left click
168 secure:SetAttribute("alt-type2", "spell"); -- alt right click
169 secure:SetAttribute("alt-shift-type1", "spell"); -- alt+shift left click
170 secure:SetAttribute("alt-shift-type2", "spell"); -- alt+shift right click
171 secure:SetAttribute("spell1", "Holy Light");
172 secure:SetAttribute("spell2", "Bestow Faith");
173 secure:SetAttribute("shift-spell1", "Flash of Light");
174 secure:SetAttribute("shift-spell2", "Light of the Martyr");
175 secure:SetAttribute("ctrl-spell1", "Cleanse");
176 secure:SetAttribute("alt-spell2", "Lay on Hands");
177 secure:SetAttribute("alt-shift-spell1", "Beacon of Light");
178 secure:SetAttribute("alt-shift-spell2", "Beacon of Faith");
179 -- rest give target and menu
180 secure:SetAttribute("*type1", "target");
181 secure:SetAttribute("*type2", "togglemenu");
184 function M.InitializeParty(parent, party, eventhandler)
185 local secure = CreateFrame("Button", "OmaPartySecure0", parent, "SecureUnitButtonTemplate");
186 local frame = CreateFrame("Frame", "OmaParty0", parent);
187 local unit = "player";
188 secure:SetAttribute("unit", unit);
189 secure:SetPoint("TOPLEFT", parent, "TOPLEFT");
190 secure:SetHeight(height+2);
192 frame:SetPoint("TOPLEFT", parent, "TOPLEFT");
193 frame:SetHeight(height+2);
194 frame:SetScript("OnEvent", eventhandler);
196 setupFrame(frame, secure, unit);
197 RegisterStateDriver(secure, "visibility", "[@player,group:raid] hide; show");
198 party[0] = {secure=secure, frame=frame};
200 local secure = CreateFrame("Button", "OmaPartySecure"..i, parent, "SecureUnitButtonTemplate");
201 local frame = CreateFrame("Frame", "OmaParty"..i, parent);
202 local unit = "party"..i;
203 secure:SetAttribute("unit", unit);
204 secure:SetPoint("TOPLEFT", party[i-1].secure, "TOPRIGHT");
205 secure:SetPoint("BOTTOMLEFT", party[i-1].secure, "BOTTOMRIGHT");
207 frame:SetPoint("TOPLEFT", party[i-1].frame, "TOPRIGHT");
208 frame:SetPoint("BOTTOMLEFT", party[i-1].frame, "BOTTOMRIGHT");
209 frame:SetScript("OnEvent", unitEvent);
211 setupFrame(frame, secure, unit);
212 RegisterUnitWatch(secure);
213 party[i] = {secure=secure, frame=frame};
217 function M.InitializeRaid(parent, raid, eventhandler)
218 local secure = CreateFrame("Button", "OmaRaidSecure1", parent, "SecureUnitButtonTemplate");
219 local frame = CreateFrame("Frame", "OmaRaid1", parent);
220 local unit = "raid1";
221 secure:SetAttribute("unit", unit);
222 secure:SetPoint("TOPLEFT", parent, "TOPLEFT");
223 secure:SetHeight(height+2);
225 frame:SetPoint("TOPLEFT", parent, "TOPLEFT");
226 frame:SetHeight(height+2);
227 frame:SetScript("OnEvent", eventhandler);
229 setupFrame(frame, secure, unit);
230 RegisterUnitWatch(secure);
231 raid[1] = {secure=secure, frame=frame};
234 local secure = CreateFrame("Button", "OmaRaidSecure"..i, parent, "SecureUnitButtonTemplate");
235 local frame = CreateFrame("Frame", "OmaRaid"..i, parent);
236 local unit = "raid"..i;
237 secure:SetAttribute("unit", unit);
238 secure:SetPoint("TOPLEFT", raid[i-5].secure, "BOTTOMLEFT");
239 secure:SetHeight(height+2);
241 frame:SetPoint("TOPLEFT", raid[i-5].frame, "BOTTOMLEFT");
242 frame:SetHeight(height+2);
243 frame:SetScript("OnEvent", unitEvent);
245 setupFrame(frame, secure, unit);
246 RegisterUnitWatch(secure);
247 raid[i] = {secure=secure, frame=frame};
252 local secure = CreateFrame("Button", "OmaRaidSecure"..i, parent, "SecureUnitButtonTemplate");
253 local frame = CreateFrame("Frame", "OmaRaid"..i, parent);
254 local unit = "raid"..i;
255 secure:SetAttribute("unit", unit);
256 secure:SetPoint("TOPLEFT", raid[i-1].secure, "TOPRIGHT");
257 secure:SetPoint("BOTTOMLEFT", raid[i-1].secure, "BOTTOMRIGHT");
259 frame:SetPoint("TOPLEFT", raid[i-1].frame, "TOPRIGHT");
260 frame:SetPoint("BOTTOMLEFT", raid[i-1].frame, "BOTTOMRIGHT");
261 frame:SetScript("OnEvent", unitEvent);
263 setupFrame(frame, secure, unit);
264 RegisterUnitWatch(secure);
265 raid[i] = {secure=secure, frame=frame};