X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/ad67f41cf4019dca1e2ea587019fe825f92fdcf0..0c898538cf7e4480bd14b1b38d17a48ea2fbb5a0:/OmaUF/BossFrames.lua?ds=sidebyside diff --git a/OmaUF/BossFrames.lua b/OmaUF/BossFrames.lua index 0f9841d..3e74dec 100644 --- a/OmaUF/BossFrames.lua +++ b/OmaUF/BossFrames.lua @@ -2,6 +2,7 @@ local _; local unpack, pairs = unpack, pairs; local format = string.format; +local UnitExists, ShowBossFrameWhenUninteractable = UnitExists, ShowBossFrameWhenUninteractable; local GameTooltip = GameTooltip; local GameTooltip_SetDefaultAnchor = GameTooltip_SetDefaultAnchor; @@ -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,9 +49,15 @@ local function hideTooltip(secure) GameTooltip:FadeOut(); end -function OmaUnitFrames.UpdateBossTooltips() - GameTooltip = _G["GameTooltip"]; - GameTooltip_SetDefaultAnchor = _G["GameTooltip_SetDefaultAnchor"]; +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) @@ -112,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; @@ -135,33 +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); -- 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