3 local unpack, pairs = unpack, pairs;
4 local format = string.format;
5 local GameTooltip = GameTooltip;
6 local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
8 local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
9 local registerCastEvents = OmaUFCastBar.RegisterCastEvents;
10 local unregisterCastEvents = OmaUFCastBar.UnregisterCastEvents;
11 local unitEvent = OmaUFEvents.UnitEvent;
13 local Settings = OmaUFSettings;
14 local baseColor = Settings.BaseColor;
15 local bgColor = Settings.BgColor;
16 local healthColor = Settings.HealthColor;
17 local shieldColor = Settings.ShieldColor;
18 local shieldhlColor = Settings.ShieldhlColor;
19 local healpredColor = Settings.HealpredColor;
20 local healabsorbColor = Settings.HealabsorbColor;
21 local width, height = Settings.Boss.Width, Settings.Boss.Height;
22 local anchorX, anchorY = Settings.Boss.AnchorX, Settings.Boss.AnchorY;
23 -- placeholders with visible values when error happens
24 local attributes = {};
26 local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate";
27 local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist";
29 local function frameShow(frame)
30 frame:RegisterEvent("PLAYER_ENTERING_WORLD");
31 frame:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT");
32 frame:RegisterEvent("UNIT_TARGETABLE_CHANGED");
33 frame:RegisterUnitEvent("UNIT_LEVEL", frame.unit);
34 registerUnitEvents(frame);
35 registerCastEvents(frame.castbar);
36 unitEvent(frame, "UPDATE_ALL_BARS");
39 local function frameHide(frame)
40 frame:UnregisterAllEvents();
41 unregisterCastEvents(frame.castbar);
44 local function showTooltip(secure)
45 GameTooltip_SetDefaultAnchor(GameTooltip, secure);
46 GameTooltip:SetUnit(secure:GetAttribute("unit"));
49 local function hideTooltip(secure)
50 GameTooltip:FadeOut();
53 function OmaUnitFrames.UpdateBossTooltips()
54 GameTooltip = _G["GameTooltip"];
55 GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
58 local function createFrame(framename, securename, parent, unit, anchorX, anchorY)
59 local secure = CreateFrame("Button", securename, parent, inheritedFrames);
60 local frame = CreateFrame("Frame", framename, parent);
61 secure:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
62 secure:SetAttribute("unit", unit);
63 frame:SetPoint("CENTER", parent, "CENTER", anchorX, anchorY);
64 frame:SetAttribute("unit", unit);
66 frame.displayed = unit;
67 -- hide frame to get initial frameShow call
70 secure:SetWidth(width+2);
71 secure:SetHeight(height+2);
72 frame:SetWidth(width+2);
73 frame:SetHeight(height+2);
75 frame.base = frame:CreateTexture(nil, "BACKGROUND");
76 frame.base:SetAllPoints();
77 frame.base:SetColorTexture(1, 1, 1);
78 frame.base:SetVertexColor(unpack(baseColor));
79 frame.healthback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
80 frame.healthback:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
81 frame.healthback:SetPoint("BOTTOMRIGHT", frame, "RIGHT", -1, -5);
82 frame.healthback:SetTexture(barTexture);
83 frame.healthback:SetVertexColor(unpack(bgColor));
84 frame.health = frame:CreateTexture(nil, "BORDER");
85 frame.health:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT");
86 frame.health:SetPoint("BOTTOMLEFT", frame.healthback, "BOTTOMLEFT");
87 frame.health:SetTexture(barTexture);
88 frame.health:SetVertexColor(unpack(healthColor));
89 frame.healthText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
90 frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 1);
91 frame.healthText.percent = true;
92 frame.manaback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
93 frame.manaback:SetPoint("TOPLEFT", frame, "LEFT", 1, -5);
94 frame.manaback:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
95 frame.manaback:SetTexture(barTexture);
96 frame.manaback:SetVertexColor(unpack(bgColor));
97 frame.mana = frame:CreateTexture(nil, "BORDER");
98 frame.mana:SetPoint("TOPLEFT", frame.manaback, "TOPLEFT");
99 frame.mana:SetPoint("BOTTOMLEFT", frame.manaback, "BOTTOMLEFT");
100 frame.mana:SetTexture(barTexture);
101 frame.manaText = frame:CreateFontString(nil, "ARTWORK", "GameFontWhiteTiny");
102 frame.manaText:SetPoint("RIGHT", frame.manaback, "RIGHT", -2, 0);
103 frame.manaText:Hide();
104 frame.shield = frame:CreateTexture(nil, "BORDER");
105 frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
106 frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
107 frame.shield:SetTexture(barTexture);
108 frame.shield:SetVertexColor(unpack(shieldColor));
110 frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
111 frame.shieldhl:SetPoint("TOPLEFT", frame.healthback, "TOPRIGHT", -1, 0);
112 frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT", 1, 0);
113 frame.shieldhl:SetColorTexture(unpack(shieldhlColor));
114 frame.shieldhl:Hide();
115 frame.healabsorb = frame:CreateTexture(nil, "ARTWORK");
116 frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT");
117 frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT");
118 frame.healabsorb:SetColorTexture(unpack(healabsorbColor));
119 frame.healabsorb:Hide();
120 frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight");
121 frame.name:SetPoint("LEFT", frame.healthback, "LEFT", 2, 1);
122 frame.name.count = 10;
123 frame.level = frame:CreateFontString(nil, "OVERLAY", "GameFontWhiteTiny");
124 frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 0);
125 frame.targeticon = frame:CreateTexture(nil, "OVERLAY");
126 frame.targeticon:SetPoint("CENTER", frame.healthback, "TOP");
127 frame.targeticon:SetWidth(16);
128 frame.targeticon:SetHeight(16);
129 frame.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
130 frame.targeticon:Hide();
131 frame.castbar = OmaUFCastBar.CreateCastBar(frame, unit, -height-24);
133 frame:SetScript("OnShow", frameShow);
134 frame:SetScript("OnHide", frameHide);
135 frame:SetScript("OnEvent", unitEvent);
136 secure:SetScript("OnEnter", showTooltip);
137 secure:SetScript("OnLeave", hideTooltip);
139 -- TODO other set of click cast on boss frames possibly
140 --secure:RegisterForClicks("AnyDown");
141 --for attr, val in pairs(attributes) do
142 -- secure:SetAttribute(attr, val);
144 -- rest give target and menu
145 secure:SetAttribute("*type1", "target");
146 secure:SetAttribute("*type2", "togglemenu");
147 --secure:SetAttribute("toggleForVehicle", false); -- TODO run LFR to see if there's boss1pet or something
148 RegisterUnitWatch(frame);
149 RegisterUnitWatch(secure);
150 -- TODO try register visibility state driver with [boss1][boss2][boss3] etc.
153 function OmaUnitFrames.InitializeBoss(parent)
154 attributes = Settings.Character.Clickheal;
156 createFrame("OmaBoss1", "OmaBossSecure1", parent, "boss1", anchorX, anchorY);
157 for i = 2,MAX_BOSS_FRAMES do
158 createFrame("OmaBoss"..i, "OmaBossSecure"..i, _G["OmaBoss"..(i-1)], "boss"..i, 0, -height-26);
160 -- Arena frames are in the same spot
161 createFrame("OmaArena1", "OmaArenaSecure1", parent, "arena1", anchorX, anchorY);
162 -- MAX_ARENA_ENEMIES from AddOns/Blizzard_ArenaUI/Blizzard_ArenaUI.lua not available
163 -- as the addon is not loaded yet, update manually if it changes
165 createFrame("OmaArena"..i, "OmaArenaSecure"..i, _G["OmaArena"..(i-1)], "arena"..i, 0, -height-26);