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;
+local unregisterCastEvents = OmaUFCastBar.UnregisterCastEvents;
local unitEvent = OmaUFEvents.UnitEvent;
local Settings = OmaUFSettings;
local attributes = {};
local inheritedFrames = "SecureUnitButtonTemplate,SecureHandlerStateTemplate";
+local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist";
local function frameShow(frame)
frame:RegisterEvent("PLAYER_ENTERING_WORLD");
frame:RegisterEvent("UNIT_TARGETABLE_CHANGED");
frame:RegisterUnitEvent("UNIT_LEVEL", frame.unit);
registerUnitEvents(frame);
+ registerCastEvents(frame.castbar);
unitEvent(frame, "UPDATE_ALL_BARS");
end
local function frameHide(frame)
frame:UnregisterAllEvents();
+ unregisterCastEvents(frame.castbar);
end
local function showTooltip(secure)
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);
frame.healthback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
frame.healthback:SetPoint("TOPLEFT", frame, "TOPLEFT", 1, -1);
frame.healthback:SetPoint("BOTTOMRIGHT", frame, "RIGHT", -1, -5);
- frame.healthback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+ frame.healthback:SetTexture(barTexture);
frame.healthback:SetVertexColor(unpack(bgColor));
frame.health = frame:CreateTexture(nil, "BORDER");
frame.health:SetPoint("TOPLEFT", frame.healthback, "TOPLEFT");
frame.health:SetPoint("BOTTOMLEFT", frame.healthback, "BOTTOMLEFT");
- frame.health:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+ frame.health:SetTexture(barTexture);
frame.health:SetVertexColor(unpack(healthColor));
frame.healthText = frame:CreateFontString(nil, "ARTWORK", "GameFontHighlight");
- frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 0);
+ frame.healthText:SetPoint("RIGHT", frame.healthback, "RIGHT", -2, 1);
frame.healthText.percent = true;
frame.manaback = frame:CreateTexture(nil, "BACKGROUND", nil, 1);
frame.manaback:SetPoint("TOPLEFT", frame, "LEFT", 1, -5);
frame.manaback:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", -1, 1);
- frame.manaback:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+ frame.manaback:SetTexture(barTexture);
frame.manaback:SetVertexColor(unpack(bgColor));
frame.mana = frame:CreateTexture(nil, "BORDER");
frame.mana:SetPoint("TOPLEFT", frame.manaback, "TOPLEFT");
frame.mana:SetPoint("BOTTOMLEFT", frame.manaback, "BOTTOMLEFT");
- frame.mana:SetTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill");
+ frame.mana:SetTexture(barTexture);
frame.manaText = frame:CreateFontString(nil, "ARTWORK", "GameFontWhiteTiny");
frame.manaText:SetPoint("RIGHT", frame.manaback, "RIGHT", -2, 0);
frame.manaText:Hide();
frame.shield = frame:CreateTexture(nil, "BORDER");
frame.shield:SetPoint("TOPLEFT", frame.health, "TOPRIGHT");
frame.shield:SetPoint("BOTTOMLEFT", frame.health, "BOTTOMRIGHT");
- frame.shield:SetTexture("Interface\\RaidFrame\\Shield-Fill");
+ frame.shield:SetTexture(barTexture);
frame.shield:SetVertexColor(unpack(shieldColor));
frame.shield:Hide();
frame.shieldhl = frame:CreateTexture(nil, "ARTWORK");
frame.name:SetPoint("LEFT", frame.healthback, "LEFT", 2, 1);
frame.name.count = 10;
frame.level = frame:CreateFontString(nil, "OVERLAY", "GameFontWhiteTiny");
- frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 1);
+ frame.level:SetPoint("LEFT", frame.manaback, "LEFT", 2, 0);
frame.targeticon = frame:CreateTexture(nil, "OVERLAY");
frame.targeticon:SetPoint("CENTER", frame.healthback, "TOP");
frame.targeticon:SetWidth(16);
frame.targeticon:SetHeight(16);
frame.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons");
frame.targeticon:Hide();
+ frame.castbar = OmaUFCastBar.CreateCastBar(frame, unit, -height-24);
-- set scripts
frame:SetScript("OnShow", frameShow);
frame:SetScript("OnHide", frameHide);
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-15);
+ 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-15);
- end
+ createFrame("OmaArena"..i, "OmaArenaSecure"..i, _G["OmaArena"..(i-1)], "arena"..i, 0, -height-26);
+ end--]]
end