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 function showTooltip(frame)
11 GameTooltip_SetDefaultAnchor(GameTooltip, frame);
12 GameTooltip:SetUnit(frame:GetAttribute("unit"));
15 local function hideTooltip()
16 GameTooltip:FadeOut();
21 local function initBoss(parent, y, width, height, update, event)
22 assert(type(parent) == "table", "Boss frame creation missing parent!");
23 assert(type(y) == "number", "Boss frame creation missing Y offset!");
24 assert(type(width) == "number", "Boss frame creation missing width!");
25 assert(type(height) == "number", "Boss frame creation missing height!");
26 assert(type(update) == "function",
27 "Boss frame creation missing update function!");
28 assert(type(event) == "function",
29 "Boss frame creation missing event function!");
31 local unit = "boss"..id;
32 local f = CreateFrame("Button", "kehysBoss"..id, parent,
33 "SecureUnitButtonTemplate,SecureHandlerStateTemplate");
36 f:SetPoint("CENTER", parent, "CENTER", 540, y+200);
39 f.barwidth = width - 2; -- 1px padding
40 f:SetAttribute("unit", unit);
41 f:SetAttribute("displayed", unit);
47 updaters[f] = function()
49 CTimerAfter(0.1, updaters[f]);
53 f:SetScript("OnEvent", event);
54 f:SetScript("OnHide", function()
55 f:UnregisterAllEvents();
59 f:SetScript("OnShow", function()
60 addon.RegisterEvents(f);
61 addon.RegisterUnitEvents(f);
62 event(f, "UPDATE_ALL_BARS");
66 f:SetScript("OnEnter", showTooltip);
67 f:SetScript("OnLeave", hideTooltip);
68 f:RegisterForClicks("AnyDown");
69 f:SetAttribute("*type1", "target");
70 f:SetAttribute("*type2", "togglemenu");
71 f:SetAttribute("toggleForVehicle", false);
74 f.base = f:CreateTexture(nil, "BACKGROUND");
75 f.base:SetAllPoints();
76 f.base:SetColorTexture(0, 0, 0, 0.5);
77 f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1);
78 f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1);
79 f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1);
80 f.health = f:CreateTexture(nil, "BORDER");
81 f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT");
82 f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8);
83 f.health:SetTexture(barTexture);
84 f.health:SetVertexColor(0.7, 0.7, 0.7);
86 f.mana = f:CreateTexture(nil, "BORDER");
87 f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8);
88 f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT");
89 f.mana:SetTexture(barTexture);
90 f.mana:SetVertexColor(0.1, 0.5, 0.9);
92 f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
93 f.manatext:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT", -2, 1);
94 f.manatext:SetFont(STANDARD_TEXT_FONT, 10);
96 f.shield = f:CreateTexture(nil, "BORDER");
97 f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
98 f.shield:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
99 f.shield:SetTexture(barTexture);
100 f.shield:SetVertexColor(0, 0.7, 1);
102 f.shieldhl = f:CreateTexture(nil, "ARTWORK");
103 f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0);
104 f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT", 0, -height/8);
105 f.shieldhl:SetColorTexture(0.5, 0.8, 1);
107 f.healpred = f:CreateTexture(nil, "ARTWORK");
108 f.healpred:SetPoint("TOPLEFT", f.health, "TOPRIGHT");
109 f.healpred:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT");
110 f.healpred:SetColorTexture(0.5, 0.6, 0.5);
112 f.healabsorb = f:CreateTexture(nil, "ARTWORK");
113 f.healabsorb:SetPoint("TOPRIGHT", f.health, "TOPRIGHT");
114 f.healabsorb:SetPoint("BOTTOMRIGHT", f.health, "BOTTOMRIGHT");
115 f.healabsorb:SetColorTexture(0.1, 0.1, 0.1);
117 f.name = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
118 f.name:SetPoint("LEFT", f, "LEFT", 2, 6);
119 f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
120 f.text:SetPoint("RIGHT", f, "RIGHT", -2, 6);
121 f.text:SetFont(STANDARD_TEXT_FONT, 13);
123 f.targeticon = f:CreateTexture(nil, "OVERLAY");
124 f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1);
125 f.targeticon:SetWidth(12);
126 f.targeticon:SetHeight(12);
127 f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
129 -- Use Blizzard Alt Power Bar
130 local powerbar = _G[format("Boss%iTargetFramePowerBarAlt", string.sub(unit, 5, 5))];
131 powerbar:SetParent(f);
132 powerbar:ClearAllPoints();
133 powerbar:SetPoint("RIGHT", f, "LEFT");
135 RegisterUnitWatch(f);
140 CFrame:SetScript("OnEvent", function(self)
141 self:UnregisterAllEvents();
142 CFrame:SetFrameStrata("LOW");
143 CFrame:SetPoint("CENTER", nil, "CENTER");
146 for i =1,MAX_BOSS_FRAMES do
147 initBoss(self, -(i*36), 160, 32, addon.FrameUpdate, addon.UnitEvent);
150 CFrame:RegisterEvent("PLAYER_LOGIN");