X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/82ce2fc4623897a0b8ca99baac27f7c433226366..66faadbf3b25d28e4a41306ccaa6284c9eb20d5e:/OmaUF/BossFrames.lua?ds=sidebyside diff --git a/OmaUF/BossFrames.lua b/OmaUF/BossFrames.lua index dd6b2aa..3e74dec 100644 --- a/OmaUF/BossFrames.lua +++ b/OmaUF/BossFrames.lua @@ -2,8 +2,9 @@ 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; @@ -16,8 +17,6 @@ local bgColor = Settings.BgColor; 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; -- placeholders with visible values when error happens @@ -50,6 +49,17 @@ local function hideTooltip(secure) GameTooltip:FadeOut(); 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); @@ -107,11 +117,6 @@ local function createFrame(framename, securename, parent, unit, anchorX, anchorY frame.shieldhl:SetPoint("BOTTOMRIGHT", frame.healthback, "BOTTOMRIGHT", 1, 0); frame.shieldhl:SetColorTexture(unpack(shieldhlColor)); frame.shieldhl:Hide(); - frame.healabsorb = frame:CreateTexture(nil, "ARTWORK"); - frame.healabsorb:SetPoint("TOPRIGHT", frame.health, "TOPRIGHT"); - frame.healabsorb:SetPoint("BOTTOMRIGHT", frame.health, "BOTTOMRIGHT"); - frame.healabsorb:SetColorTexture(unpack(healabsorbColor)); - frame.healabsorb:Hide(); frame.name = frame:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); frame.name:SetPoint("LEFT", frame.healthback, "LEFT", 2, 1); frame.name.count = 10; @@ -130,34 +135,42 @@ local function createFrame(framename, securename, parent, unit, anchorX, anchorY 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); - 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