local _;
local unpack, pairs = unpack, pairs;
local format = string.format;
-local GameTooltip = nil;
-local GameTooltip_SetDefaultAnchor = nil;
+local UnitExists, ShowBossFrameWhenUninteractable = UnitExists, ShowBossFrameWhenUninteractable;
+local GameTooltip = GameTooltip;
+local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor;
local registerUnitEvents = OmaUFEvents.RegisterUnitEvents;
local registerCastEvents = OmaUFCastBar.RegisterCastEvents;
GameTooltip:FadeOut();
end
+function OmaUnitFrames.UpdateBossTooltips()
+ GameTooltip = _G["GameTooltip"];
+ 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);
secure:SetScript("OnLeave", hideTooltip);
-- 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
+ --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);
- RegisterUnitWatch(frame);
- RegisterUnitWatch(secure);
+ -- 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)
- GameTooltip = _G["GameTooltip"];
- GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"];
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