4 local format = string.format;
5 local CFrame = CreateFrame("Frame", "kehysBossInit", UIParent);
6 local CTimerAfter = C_Timer.After;
8 local barTexture = "Interface\\AddOns\\kehys\\images\\minimalist";
10 local attributes = {};
12 local function showTooltip(frame)
13 GameTooltip_SetDefaultAnchor(GameTooltip, frame);
14 GameTooltip:SetUnit(frame:GetAttribute("unit"));
17 local function hideTooltip()
18 GameTooltip:FadeOut();
23 local function initBoss(parent, y, width, height, update, event)
24 assert(type(parent) == "table", "Boss frame creation missing parent!");
25 assert(type(y) == "number", "Boss frame creation missing Y offset!");
26 assert(type(width) == "number", "Boss frame creation missing width!");
27 assert(type(height) == "number", "Boss frame creation missing height!");
28 assert(type(update) == "function",
29 "Boss frame creation missing update function!");
30 assert(type(event) == "function",
31 "Boss frame creation missing event function!");
33 local unit = "boss"..id;
34 local f = CreateFrame("Button", "kehysBoss"..id, parent,
35 "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
38 f:SetPoint("CENTER", parent, "CENTER", 540, y+200);
41 f.barwidth = width - 2; -- 1px padding
42 f:SetAttribute("unit", unit);
43 f:SetAttribute("displayed", unit);
49 updaters[f] = function()
51 CTimerAfter(0.1, updaters[f]);
55 f:SetScript("OnEvent", event);
56 f:SetScript("OnHide", function()
57 f:UnregisterAllEvents();
61 f:SetScript("OnShow", function()
62 addon.RegisterEvents(f);
63 addon.RegisterUnitEvents(f);
64 event(f, "UPDATE_ALL_BARS");
68 f:SetScript("OnEnter", showTooltip);
69 f:SetScript("OnLeave", hideTooltip);
71 f:RegisterForClicks("AnyDown");
72 for attr, val in pairs(attributes) do
73 if attr ~= "type1" and attr ~= "spell1" then f:SetAttribute(attr, val) end
75 -- rest give target and menu
76 f:SetAttribute("*type1", "target");
77 f:SetAttribute("*type2", "togglemenu");
78 f:SetAttribute("toggleForVehicle", false);
81 f.base = f:CreateTexture(nil, "BACKGROUND");
82 f.base:SetAllPoints();
83 f.base:SetColorTexture(0, 0, 0, 0.5);
84 f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1);
85 f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
86 f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
87 f.health = f:CreateTexture(nil, "BORDER");
88 f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
89 f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8);
90 f.health:SetTexture(barTexture);
91 f.health:SetVertexColor(0.7, 0.7, 0.7);
93 f.mana = f:CreateTexture(nil, "BORDER");
94 f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8);
95 f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
96 f.mana:SetTexture(barTexture);
97 f.mana:SetVertexColor(0.1, 0.5, 0.9);
99 f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
100 f.manatext:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT", -2, 1);
101 f.manatext:SetFont(STANDARD_TEXT_FONT, 10);
103 f.shield = f:CreateTexture(nil, "BORDER");
104 f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
105 f.shield:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
106 f.shield:SetTexture(barTexture);
107 f.shield:SetVertexColor(0, 0.7, 1);
109 f.shieldhl = f:CreateTexture(nil, "ARTWORK");
110 f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
111 f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT", 0, -height/8);
112 f.shieldhl:SetColorTexture(0.5, 0.8, 1);
114 f.healpred = f:CreateTexture(nil, "ARTWORK");
115 f.healpred:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
116 f.healpred:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
117 f.healpred:SetColorTexture(0.5, 0.6, 0.5);
119 f.healabsorb = f:CreateTexture(nil, "ARTWORK");
120 f.healabsorb:SetPoint("TOPRIGHT", f.health, "TOPRIGHT");
121 f.healabsorb:SetPoint("BOTTOMRIGHT", f.health, "BOTTOMRIGHT");
122 f.healabsorb:SetColorTexture(0.1, 0.1, 0.1);
124 f.name = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
125 f.name:SetPoint("LEFT", f, "LEFT", 2, 6);
126 f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
127 f.text:SetPoint("RIGHT", f, "RIGHT", -2, 6);
128 f.text:SetFont(STANDARD_TEXT_FONT, 13);
130 f.targeticon = f:CreateTexture(nil, "OVERLAY");
131 f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
132 f.targeticon:SetWidth(12);
133 f.targeticon:SetHeight(12);
134 f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
136 -- Use Blizzard Alt Power Bar
137 local powerbar = _G[format("Boss%iTargetFramePowerBarAlt", string.sub(unit, 5, 5))];
138 powerbar:SetParent(f);
139 powerbar:ClearAllPoints();
140 powerbar:SetPoint("RIGHT", f, "LEFT");
142 RegisterUnitWatch(f);
147 CFrame:SetScript("OnEvent", function(self)
148 _, class = UnitClass("player");
149 attributes = addon.Clickheal[class];
150 self:UnregisterAllEvents();
151 CFrame:SetFrameStrata("LOW");
152 CFrame:SetPoint("CENTER", nil, "CENTER");
155 for i =1,MAX_BOSS_FRAMES do
156 initBoss(self, -(i*36), 160, 32, addon.FrameUpdate, addon.UnitEvent);
159 CFrame:RegisterEvent("PLAYER_LOGIN");