1 -- Based on Simple Holy Power
3 local class = "PALADIN";
4 local ptype = Enum.PowerType.HolyPower;
5 local UnitPower = UnitPower;
6 local GetSpecialization = GetSpecialization;
7 local f = CreateFrame("Frame", "OmaSHP", UIParent);
8 f:SetScript("OnEvent", function(self, event, ...)
9 self[event](self, ...);
13 [0] = function() f[1]:Hide(); f[2]:Hide(); f[3]:Hide(); f[4]:Hide(); f[5]:Hide() end,
14 [1] = function() f[1]:Show(); f[2]:Hide(); f[3]:Hide(); f[4]:Hide(); f[5]:Hide() end,
15 [2] = function() f[1]:Show(); f[2]:Show(); f[3]:Hide(); f[4]:Hide(); f[5]:Hide() end,
16 [3] = function() f[1]:Show(); f[2]:Show(); f[3]:Show(); f[4]:Hide(); f[5]:Hide() end,
17 [4] = function() f[1]:Show(); f[2]:Show(); f[3]:Show(); f[4]:Show(); f[5]:Hide() end,
18 [5] = function() f[1]:Show(); f[2]:Show(); f[3]:Show(); f[4]:Show(); f[5]:Show() end,
20 function f:PLAYER_SPECIALIZATION_CHANGED()
21 if class == "PALADIN" then
22 if GetSpecialization() == 3 then -- ret
24 f:RegisterUnitEvent("UNIT_POWER_UPDATE", "player");
25 updatehp[UnitPower("player", ptype)]();
27 f:UnregisterEvent("UNIT_POWER_UPDATE");
30 elseif class == "WARLOCK" then
32 f:RegisterUnitEvent("UNIT_POWER_UPDATE", "player");
33 updatehp[UnitPower("player", ptype)]();
36 f.PLAYER_ENTERING_WORLD = f.PLAYER_SPECIALIZATION_CHANGED;
38 function f:UNIT_POWER_UPDATE(_, t)
39 if t == "HOLY_POWER" or t == "SOUL_SHARDS" then
40 return updatehp[UnitPower("player", ptype)]();
44 function f:PLAYER_LOGIN()
45 f:UnregisterAllEvents();
47 _, class = UnitClass("player");
48 if class == "PALADIN" then
49 ptype = Enum.PowerType.HolyPower;
50 elseif class == "WARLOCK" then
51 ptype = Enum.PowerType.SoulShards;
55 f:SetFrameStrata("LOW");
56 f:SetPoint("CENTER", UIParent, "CENTER", -308, -217);
60 f[i] = f:CreateTexture("OmaSHP"..i, "ARTWORK");
62 f[i]:SetPoint("TOPLEFT", f, "TOPLEFT", 2, 0)
64 f[i]:SetPoint("TOPLEFT", f[i-1], "TOPRIGHT", 2, 0)
68 if class == "WARLOCK" then
69 f[i]:SetColorTexture(0.7, 0.3, 0.5);
71 -- color is default from SHP
72 f[i]:SetColorTexture(0.9686274509803922, 0.674509803921568, 0.1450980392156863);
76 f:RegisterUnitEvent("UNIT_POWER_UPDATE", "player");
77 f:RegisterEvent("PLAYER_ENTERING_WORLD");
78 f:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED");
81 f:RegisterEvent("PLAYER_LOGIN");