local _;
local unpack, pairs = unpack, pairs;
local format = string.format;
+local UnitExists, ShowBossFrameWhenUninteractable = UnitExists, ShowBossFrameWhenUninteractable;
local GameTooltip = GameTooltip;
local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
local healthColor = Settings.HealthColor;
local shieldColor = Settings.ShieldColor;
local shieldhlColor = Settings.ShieldhlColor;
-local healpredColor = Settings.HealpredColor;
local healabsorbColor = Settings.HealabsorbColor;
local width, height = Settings.Boss.Width, Settings.Boss.Height;
local anchorX, anchorY = Settings.Boss.AnchorX, Settings.Boss.AnchorY;
GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
end
+local function bossEvent(self)
+ -- INSTANCE_ENCOUNTER_ENGAGE_UNIT only
+ for unit, frame in pairs(self.frames) do
+ if UnitExists(unit) or ShowBossFrameWhenUninteractable(unit) then
+ frame:Show();
+ else
+ frame:Hide();
+ end
+ end
+end
+
local function createFrame(framename, securename, parent, unit, anchorX, anchorY)
local secure = CreateFrame("Button", securename, parent, inheritedFrames);
local frame = CreateFrame("Frame", framename, parent);
frame:SetScript("OnEvent", unitEvent);
secure:SetScript("OnEnter", showTooltip);
secure:SetScript("OnLeave", hideTooltip);
+ -- set PowerBarAlt
+ local powerbar = _G[string.format("Boss%iTargetFramePowerBarAlt", string.sub(unit, 5, 5))];
+ powerbar:SetParent(secure);
+ powerbar:ClearAllPoints();
+ powerbar:SetPoint("RIGHT", secure, "LEFT");
-- set attributes
-- TODO other set of click cast on boss frames possibly
- --secure:RegisterForClicks("AnyDown");
- --for attr, val in pairs(attributes) do
- -- secure:SetAttribute(attr, val);
- --end
-- rest give target and menu
secure:SetAttribute("*type1", "target");
secure:SetAttribute("*type2", "togglemenu");
- --secure:SetAttribute("toggleForVehicle", false); -- TODO run LFR to see if there's boss1pet or something
- RegisterUnitWatch(frame);
- RegisterUnitWatch(secure);
- -- TODO try register visibility state driver with [boss1][boss2][boss3] etc.
+ -- TODO dunno how to update frame securely without hiding frame too often
+ -- ShowBossFrameWhenUninteractable not in restricted environment
+ -- this way all frames are clickable, but there's some invisible clickframes
+ RegisterStateDriver(secure, "visibility", "[@boss1,exists][@boss2,exists][@boss3,exists][@boss4,exists][@boss5,exists] show; hide");
+ return frame;
end
function OmaUnitFrames.InitializeBoss(parent)
attributes = Settings.Character.Clickheal;
- createFrame("OmaBoss1", "OmaBossSecure1", parent, "boss1", anchorX, anchorY);
+ -- hidden frame to handle hiding insecure boss frames
+ local bossHeader = CreateFrame("Frame");
+ bossHeader.frames = {};
+ bossHeader:SetScript("OnEvent", bossEvent);
+ bossHeader:RegisterEvent("INSTANCE_ENCOUNTER_ENGAGE_UNIT");
+ bossHeader.frames["boss1"] = createFrame("OmaBoss1", "OmaBossSecure1", parent, "boss1", anchorX, anchorY);
for i = 2,MAX_BOSS_FRAMES do
- createFrame("OmaBoss"..i, "OmaBossSecure"..i, _G["OmaBoss"..(i-1)], "boss"..i, 0, -height-26);
+ bossHeader.frames["boss"..i] = createFrame("OmaBoss"..i, "OmaBossSecure"..i, _G["OmaBossSecure"..(i-1)], "boss"..i, 0, -height-26);
end
+ bossEvent(bossHeader);
+
-- Arena frames are in the same spot
- createFrame("OmaArena1", "OmaArenaSecure1", parent, "arena1", anchorX, anchorY);
+ --[[createFrame("OmaArena1", "OmaArenaSecure1", parent, "arena1", anchorX, anchorY);
-- MAX_ARENA_ENEMIES from AddOns/Blizzard_ArenaUI/Blizzard_ArenaUI.lua not available
-- as the addon is not loaded yet, update manually if it changes
for i = 2,5 do
createFrame("OmaArena"..i, "OmaArenaSecure"..i, _G["OmaArena"..(i-1)], "arena"..i, 0, -height-26);
- end
+ end--]]
end