From 971304090ee92e27a82533041bd6b222b702552c Mon Sep 17 00:00:00 2001 From: Aleksi Blinnikka Date: Sat, 2 Feb 2019 16:41:28 +0200 Subject: [PATCH] Incremental refactor of raid frames --- kehys/events.lua | 329 ++++++++++++++++++++++++++++++++++++ kehys/frame.lua | 143 ++++++++++++++++ kehys/hideblizz.lua | 63 +++++++ kehys/images/minimalist.tga | Bin 0 -> 1304 bytes kehys/kehys.toc | 12 ++ kehys/paladin.lua | 40 +++++ kehys/raid.lua | 138 +++++++++++++++ kehys/setup.lua | 21 +++ 8 files changed, 746 insertions(+) create mode 100644 kehys/events.lua create mode 100644 kehys/frame.lua create mode 100644 kehys/hideblizz.lua create mode 100644 kehys/images/minimalist.tga create mode 100644 kehys/kehys.toc create mode 100644 kehys/paladin.lua create mode 100644 kehys/raid.lua create mode 100644 kehys/setup.lua diff --git a/kehys/events.lua b/kehys/events.lua new file mode 100644 index 0000000..f030057 --- /dev/null +++ b/kehys/events.lua @@ -0,0 +1,329 @@ +-- events.lua +-- 2019 Aleksi Blinnikka +local _; +local unpack = unpack; +local ssub = string.sub; +local min = math.min; +local UnitName, UnitClass, UnitExists = UnitName, UnitClass, UnitExists; +local UnitDebuff, UnitIsCharmed = UnitDebuff, UnitIsCharmed; +local UnitHealth, UnitHealthMax = UnitHealth, UnitHealthMax; +local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND; +local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs; +local UnitThreatSituation, GetThreatStatusColor = UnitThreatSituation, GetThreatStatusColor; +local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; +local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs; +local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI; +local GetReadyCheckTimeLeft, GetReadyCheckStatus = GetReadyCheckTimeLeft, GetReadyCheckStatus; +local UnitGroupRolesAssigned = UnitGroupRolesAssigned; +local GetRaidTargetIndex, SetRaidTargetIconTexture = GetRaidTargetIndex, SetRaidTargetIconTexture; +local RAID_CLASS_COLORS = RAID_CLASS_COLORS; +local READY_CHECK_READY_TEXTURE = READY_CHECK_READY_TEXTURE; +local READY_CHECK_NOT_READY_TEXTURE = READY_CHECK_NOT_READY_TEXTURE; +local READY_CHECK_WAITING_TEXTURE = READY_CHECK_WAITING_TEXTURE; + +local _, addon = ...; +local baseColor = {0, 0, 0}; +local overlayColorDispel = {1, 0.5, 0, 0.5}; +local overlayColorCharm = {0.8, 0, 1, 0.5}; +local overlayColorAlert = {1, 0, 0, 0.5}; +local width = 80; + +function addon.RegisterEvents(frame) + frame:RegisterEvent("PLAYER_ENTERING_WORLD"); + frame:RegisterEvent("PLAYER_ROLES_ASSIGNED"); + frame:RegisterEvent("READY_CHECK"); + frame:RegisterEvent("READY_CHECK_FINISHED"); + frame:RegisterEvent("GROUP_ROSTER_UPDATE"); + frame:RegisterEvent("RAID_TARGET_UPDATE"); + if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end +end + +function addon.RegisterUnitEvents(frame) + -- events are taken from FrameXML/CompactUnitFrame.lua + local displayed = frame.unit ~= frame.displayed and frame.displayed or nil; + frame:RegisterUnitEvent("UNIT_HEALTH_FREQUENT", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_MAXHEALTH", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_AURA", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_HEAL_PREDICTION", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_ABSORB_AMOUNT_CHANGED", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_HEAL_ABSORB_AMOUNT_CHANGED", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_THREAT_SITUATION_UPDATE", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_CONNECTION", frame.unit, displayed); + frame:RegisterUnitEvent("PLAYER_FLAGS_CHANGED", frame.unit, displayed); + frame:RegisterUnitEvent("READY_CHECK_CONFIRM", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", frame.unit, displayed); + frame:RegisterUnitEvent("UNIT_PET", frame.unit, displayed); +end +local registerUnitEvents = addon.RegisterUnitEvents; + +local function updateText(frame, unit) + if UnitIsDeadOrGhost(unit) then + frame.dead = true; + frame.text:SetText("Dead"); + frame.text:Show(); + elseif not UnitIsConnected(unit) then + frame.text:SetText("DC"); + frame.text:Show(); + elseif UnitIsAFK(unit) then + frame.text:SetText("afk"); + frame.text:Show(); + elseif UnitIsDND(unit) then + frame.text:SetText("dnd"); + frame.text:Show(); + else + frame.text:Hide(); + end +end + +local function updateMaxHealth(frame, unit) + frame.health.max = UnitHealthMax(unit); +end + +local function updateHealth(frame, unit) + local current, max = UnitHealth(unit), frame.health.max; + if current > max or max <= 0 then + -- somehow current health has gone over the maximum (missed maxhealth event possibly) + -- just put health bar full and update max health for next event + frame.health:SetWidth(width); + frame.health.width = width; + updateMaxHealth(frame, unit); + frame.health:Show(); + elseif current <= 0 or UnitIsDeadOrGhost(unit) then + frame.health:Hide(); + return updateText(frame, unit); -- update death + else + local w = current/max*width; + frame.health:SetWidth(w); + frame.health.width = w; + frame.health:Show(); + end + + if frame.dead and current > 0 then + frame.dead = nil; + updateText(frame, unit); -- update revive + end +end + +local function updateName(frame, unit) + local name = UnitName(unit); + if not name then return end + name = ssub(name, 1, 6); + if frame.unit == unit then + frame.name:SetText(name); + else + frame.name:SetFormattedText("-%s", name); + end + + local _, class = UnitClass(unit); + local color = RAID_CLASS_COLORS[class]; + if color then frame.name:SetVertexColor(color.r, color.g, color.b) end +end + +local function updateHealPred(frame, unit) + local incoming = UnitGetIncomingHeals(unit) or 0; + if incoming > 0 then + incoming = (incoming / frame.health.max) * width; + -- always at least 1 pixel space for heal prediction + frame.healpred:SetWidth(min(width - frame.health.width + 1, incoming)); + frame.healpred:Show(); + else + frame.healpred:Hide(); + end +end + +local function updateShield(frame, unit) + local shield = UnitGetTotalAbsorbs(unit) or 0; + if shield > 0 then + local space = width - frame.health.width; + shield = (shield / frame.health.max) * width; + if space == 0 then + frame.shield:Hide(); + frame.shieldhl:Show(); + elseif space < shield then + frame.shield:SetWidth(space); + frame.shield:Show(); + frame.shieldhl:Show(); + else + frame.shield:SetWidth(shield); + frame.shield:Show(); + frame.shieldhl:Hide(); + end + else + frame.shield:Hide(); + frame.shieldhl:Hide(); + end +end + +local function updateHealAbsorb(frame, unit) + local absorb = UnitGetTotalHealAbsorbs(unit) or 0; + if absorb > 0 then + absorb = (absorb / frame.health.max) * width; + frame.healabsorb:SetWidth(min(frame.health.width, absorb)); + frame.healabsorb:Show(); + else + frame.healabsorb:Hide(); + end +end + +local function updateAuras(frame, unit) + -- don't overlay charmed when in vehicle + if UnitIsCharmed(unit) and unit == frame.unit then + if frame.overlay.color ~= overlayColorCharm then + frame.overlay:SetVertexColor(unpack(overlayColorCharm)); + frame.overlay.color = overlayColorCharm; + frame.overlay:Show(); + end + elseif UnitDebuff(unit, 1, "RAID") ~= nil then + -- something dispellable + if frame.overlay.color ~= overlayColorDispel then + frame.overlay:SetVertexColor(unpack(overlayColorDispel)); + frame.overlay.color = overlayColorDispel; + frame.overlay:Show(); + end + else + if frame.overlay.color ~= nil then + frame.overlay.color = nil; + frame.overlay:Hide(); + end + end +end + +local function updateAggro(frame, unit) + local status = UnitThreatSituation(unit); + if status and status > 0 then + frame.base:SetVertexColor(GetThreatStatusColor(status)); + else + frame.base:SetVertexColor(unpack(baseColor)); + end +end + +local function updateVehicle(frame) + local shouldTargetVehicle = UnitHasVehicleUI(frame.unit) and + UnitTargetsVehicleInRaidUI(frame.unit) and UnitExists(frame.vehicle); + if shouldTargetVehicle then + if not frame.inVehicle then + frame.inVehicle = true; + frame.displayed = frame.vehicle; + registerUnitEvents(frame); + end + elseif frame.inVehicle then + frame.inVehicle = false; + frame.displayed = frame.unit; + registerUnitEvents(frame); + end +end + +local function updateRole(frame, unit) + local role = UnitGroupRolesAssigned(unit); + if role == "HEALER" then + frame.role:SetTexCoord(0.75, 1, 0, 1); + frame.role:Show(); + elseif role == "TANK" then + frame.role:SetTexCoord(0.5, 0.75, 0, 1); + frame.role:Show(); + else + frame.role:Hide(); + end +end + +local function updateReadyCheck(frame, unit) + local status = GetReadyCheckStatus(unit); + if status == "ready" then + frame.ready:SetTexture(READY_CHECK_READY_TEXTURE); + frame.ready:Show() + elseif status == "notready" then + frame.ready:SetTexture(READY_CHECK_NOT_READY_TEXTURE); + frame.ready:Show() + elseif status == "waiting" then + frame.ready:SetTexture(READY_CHECK_WAITING_TEXTURE); + frame.ready:Show() + else + frame.ready:Hide() + end +end + +local function updateRaidMarker(frame, unit) + local index = GetRaidTargetIndex(unit); + if index then + SetRaidTargetIconTexture(frame.targeticon, index); + frame.targeticon:Show(); + else + frame.targeticon:Hide(); + end +end + +local eventFuncs = { + ["UNIT_HEALTH"] = function(frame) + updateHealth(frame, frame.displayed); + updateShield(frame, frame.displayed); + updateHealAbsorb(frame, frame.displayed); + -- no heal prediction update, that doesn't overflow too much + end, + ["UNIT_AURA"] = function(frame) + updateAuras(frame, frame.displayed); + end, + ["UNIT_HEAL_PREDICTION"] = function(frame) + updateHealPred(frame, frame.displayed); + end, + ["UNIT_ABSORB_AMOUNT_CHANGED"] = function(frame) + updateShield(frame, frame.displayed); + end, + ["UNIT_HEAL_ABSORB_AMOUNT_CHANGED"] = function(frame) + updateHealAbsorb(frame, frame.displayed); + end, + ["UNIT_THREAT_SITUATION_UPDATE"] = function(frame) + updateAggro(frame, frame.displayed); + end, + ["UNIT_MAXHEALTH"] = function(frame) + updateMaxHealth(frame, frame.displayed); + updateHealth(frame, frame.displayed); + updateShield(frame, frame.displayed); + updateHealAbsorb(frame, frame.displayed); + end, + ["UNIT_NAME_UPDATE"] = function(frame) + updateName(frame, frame.unit); + end, + ["UNIT_CONNECTION"] = function(frame) + updateText(frame, frame.displayed); + end, + ["PLAYER_ROLES_ASSIGNED"] = function(frame) + updateRole(frame, frame.unit); + end, + ["READY_CHECK"] = function(frame) + updateReadyCheck(frame, frame.unit); + end, + ["RAID_TARGET_UPDATE"] = function(frame) + updateRaidMarker(frame, frame.displayed); + end, + ["UPDATE_ALL_BARS"] = function(frame) + updateRole(frame, frame.unit); + updateVehicle(frame); + updateMaxHealth(frame, frame.displayed); + updateHealth(frame, frame.displayed); + updateText(frame, frame.displayed); + updateAuras(frame, frame.displayed); + updateShield(frame, frame.displayed); + updateHealPred(frame, frame.displayed); + updateHealAbsorb(frame, frame.displayed); + updateAggro(frame, frame.displayed); + updateName(frame, frame.unit); + updateReadyCheck(frame, frame.unit); + updateRaidMarker(frame, frame.displayed); + end, +}; +eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"]; +eventFuncs["PLAYER_FLAGS_CHANGED"] = eventFuncs["UNIT_CONNECTION"]; +eventFuncs["READY_CHECK_CONFIRM"] = eventFuncs["READY_CHECK"]; +eventFuncs["READY_CHECK_FINISHED"] = eventFuncs["READY_CHECK"]; +eventFuncs["UNIT_ENTERED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["UNIT_EXITED_VEHICLE"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["UNIT_PET"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["GROUP_ROSTER_UPDATE"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["PLAYER_ENTERING_WORLD"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["PLAYER_FOCUS_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"]; + +function addon.UnitEvent(self, event) + return eventFuncs[event](self); +end diff --git a/kehys/frame.lua b/kehys/frame.lua new file mode 100644 index 0000000..2409d26 --- /dev/null +++ b/kehys/frame.lua @@ -0,0 +1,143 @@ +-- frame.lua +-- 2019 Aleksi Blinnikka +local _, addon = ...; +local unpack = unpack; +local format = string.format; +local CreateFrame = CreateFrame; +local CTimerAfter = C_Timer.After; + +local updaters = {}; +local function showTooltip(frame) + GameTooltip_SetDefaultAnchor(GameTooltip, frame); + GameTooltip:SetUnit(frame:GetAttribute("unit")); +end +local function hideTooltip(frame) + if GameTooltip:IsOwned(frame) then GameTooltip:FadeOut() end +end + +local barTexture = "Interface\\AddOns\\kehys\\images\\minimalist"; +local frameid = 1; +function addon.NewRaidFrame(parent, width, height, unit, attributes, + update, event, onshow) + assert(type(parent) == "table", "Frame creation missing parent!"); + assert(type(width) == "number", "Frame creation missing width!"); + assert(type(height) == "number", "Frame creation missing height!"); + assert(type(unit) == "string", "Frame creation missing unit!"); + assert(type(attributes) == "table", + "Frame creation missing attributes table!"); + assert(type(update) == "function", + "Frame creation missing update function!"); + assert(type(event) == "function", + "Frame creation missing event function!"); + assert(type(onshow) == "function", + "Frame creation missing onshow function!"); + + local f = CreateFrame( + "Button", + format("kehys%i", frameid), + parent, + "SecureUnitButtonTemplate,SecureHandlerStateTemplate" + ); + frameid = frameid + 1; + f:Hide(); -- hide frame to have an initial frame:OnShow call + f:SetWidth(width); + f:SetHeight(height); + f:SetAttribute("unit", unit); + f.unit = unit; + f.displayed = unit; + f.vehicle = unit == "player" and "vehicle" or format("%spet", unit); + f.prev = {} -- values stored from previous update + -- set up periodic updates + updaters[f] = function() + if f.updating then + CTimerAfter(0.25, updaters[f]); + return update(f) + end + end + -- set scripts + f:SetScript("OnShow", function() + onshow(f); + f.updating = true; + updaters[f](); + end); + f:SetScript("OnHide", function() + f:UnregisterAllEvents(); + f.updating = false; + end); + f:SetScript("OnEvent", event); + f:SetScript("OnEnter", showTooltip); + f:SetScript("OnLeave", hideTooltip); + -- set attributes + f:RegisterForClicks("AnyDown"); + for attr, val in pairs(attributes) do + f:SetAttribute(attr, val); + end + -- rest give target and menu + f:SetAttribute("*type1", "target"); + f:SetAttribute("*type2", "togglemenu"); + + -- create visuals + f.base = f:CreateTexture(nil, "BACKGROUND"); + f.base:SetAllPoints(); + f.base:SetColorTexture(1, 1, 1); + f.base:SetVertexColor(unpack(addon.Colors.Base)); + f.background = f:CreateTexture(nil, "BACKGROUND", nil, 1); + f.background:SetPoint("TOPLEFT", f, "TOPLEFT", 1, -1); + f.background:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -1, 1); + f.background:SetColorTexture(0.7, 0.7, 0.7); + f.health = f:CreateTexture(nil, "BORDER"); + f.health:SetPoint("TOPLEFT", f.background, "TOPLEFT"); + f.health:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT"); + f.health:SetTexture(barTexture); + f.health:SetVertexColor(0.3, 0.3, 0.3); + f.health:Hide(); + f.shield = f:CreateTexture(nil, "BORDER"); + f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT"); + f.shield:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT"); + f.shield:SetTexture(barTexture); + f.shield:SetVertexColor(0, 0.7, 1); + f.shield:Hide(); + f.shieldhl = f:CreateTexture(nil, "ARTWORK"); + f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0); + f.shieldhl:SetPoint("BOTTOMRIGHT"); + f.shieldhl:SetColorTexture(0.5, 0.8, 1); + f.shieldhl:Hide(); + f.healpred = f:CreateTexture(nil, "ARTWORK"); + f.healpred:SetPoint("TOPLEFT", f.health, "TOPRIGHT"); + f.healpred:SetPoint("BOTTOMLEFT", f.health, "BOTTOMRIGHT"); + f.healpred:SetColorTexture(0.5, 0.6, 0.5); + f.healpred:Hide(); + f.healabsorb = f:CreateTexture(nil, "ARTWORK"); + f.healabsorb:SetPoint("TOPRIGHT", f.health, "TOPRIGHT"); + f.healabsorb:SetPoint("BOTTOMRIGHT", f.health, "BOTTOMRIGHT"); + f.healabsorb:SetColorTexture(0.1, 0.1, 0.1); + f.healabsorb:Hide(); + f.overlay = f:CreateTexture(nil, "ARTWORK", nil, 1); + f.overlay:SetPoint("TOPLEFT", f.background, "TOPLEFT"); + f.overlay:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT"); + f.overlay:SetColorTexture(1, 1, 1); + f.overlay:Hide(); + f.role = f:CreateTexture(nil, "ARTWORK", nil, 2); + f.role:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", -3, 3); + f.role:SetPoint("TOPLEFT", f, "BOTTOMRIGHT", -15, 15); + f.role:SetTexture("Interface\\LFGFRAME\\LFGROLE"); + f.role:Hide(); + f.name = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + f.name:SetPoint("CENTER", f, "CENTER", 0, 11); + f.text = f:CreateFontString(nil, "OVERLAY", "GameFontHighlight"); + f.text:SetPoint("CENTER", f, "CENTER", 0, -1); + f.text:SetFont(STANDARD_TEXT_FONT, 13); + f.text:Hide(); + f.ready = f:CreateTexture(nil, "OVERLAY"); + f.ready:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, 15); + f.ready:SetPoint("BOTTOMRIGHT", f, "BOTTOMLEFT", 15, 1); + f.ready:Hide(); + f.targeticon = f:CreateTexture(nil, "OVERLAY"); + f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1); + f.targeticon:SetWidth(12); + f.targeticon:SetHeight(12); + f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons"); + f.targeticon:Hide(); + + return f; +end diff --git a/kehys/hideblizz.lua b/kehys/hideblizz.lua new file mode 100644 index 0000000..6ab3de1 --- /dev/null +++ b/kehys/hideblizz.lua @@ -0,0 +1,63 @@ +-- hideblizz.lua +-- 2019 Aleksi Blinnikka +local _; +local InCombatLockdown = InCombatLockdown; +-- hiding Blizzard frames somewhat based on ShadowedUF +local function hideBlizzardRaidButton() + if InCombatLockdown() then return end + local manager = CompactRaidFrameManager; + -- remove show and unlock buttons from manager + manager.displayFrame.hiddenModeToggle:Hide(); + manager.displayFrame.lockedModeToggle:Hide(); +end + +local hidden = false; +local function hideBlizzardRaid() + if hidden then return end + hidden = true; + local function hide() + if InCombatLockdown() then return end + CompactRaidFrameContainer:Hide(); + local shown = CompactRaidFrameManager_GetSetting("IsShown"); + if shown and shown ~= "0" then + CompactRaidFrameManager_SetSetting("IsShown", "0"); + end + end + + CompactRaidFrameContainer:UnregisterAllEvents(); + -- there may still be frames created at startup getting events + for i=1,MAX_RAID_MEMBERS do + local frame = _G["CompactRaidFrame"..i]; + if not frame then break end + frame:UnregisterAllEvents(); + end + hooksecurefunc("CompactRaidFrameManager_UpdateShown", hide); + hide(); + CompactRaidFrameContainer:HookScript("OnShow", hide); + hooksecurefunc("CompactRaidFrameManager_UpdateOptionsFlowContainer", hideBlizzardRaidButton); + hideBlizzardRaidButton(); + + -- hide focus frame + for _, frame in pairs({FocusFrame, FocusFrameToT, FocusFrameSpellBar}) do + frame:UnregisterAllEvents(); + if frame.healthbar then frame.healthbar:UnregisterAllEvents() end + if frame.manabar then frame.manabar:UnregisterAllEvents() end + if frame.spellbar then frame.spellbar:UnregisterAllEvents() end + if frame.powerBarAlt then frame.powerBarAlt:UnregisterAllEvents() end + frame:Hide(); + end +end + +local hider = CreateFrame("Frame"); +hider:Hide(); +hider:RegisterEvent("PLAYER_LOGIN"); +hider:RegisterEvent("PLAYER_REGEN_ENABLED"); +hider:SetScript("OnEvent", function(self, event) + if event == "PLAYER_REGEN_ENABLED" then + -- if CompactRaidFrameManager_UpdateOptionsFlowContainer was called in combat + -- couldn't hide the button + hideBlizzardRaidButton(); + elseif event == "PLAYER_LOGIN" then + hideBlizzardRaid(); + end +end); diff --git a/kehys/images/minimalist.tga b/kehys/images/minimalist.tga new file mode 100644 index 0000000000000000000000000000000000000000..030bc83d81c45574cece01ca0bc8af9c03849933 GIT binary patch literal 1304 zcmZwHSx&-G7>40`XIupv&|P3cVl;7zD_|c*pxBAd^FRlN#c;2?`Q_`uV?zFO@#Q&h z+uJJ2jUvz0NEuzzbULNW(RH0@7{f4#Fk90!NwF-82>QX)xGrtm7E+}?8O@otKua;^ zdc79Xq`nyGOf%4YjORFxkR`QdbV}#<{-3&N!)J->xy<DW^jUuIq>}{ppap-EIk_Z;XO# zh0%7qozP5b&S=53C0c^9_WQliN=j#BFwI2sF#h3i5VEBlMlRDlG&&xSm-F}MdwqTz SzfWE!Pmi}B_mhY5o$?DAgJ4(y literal 0 HcmV?d00001 diff --git a/kehys/kehys.toc b/kehys/kehys.toc new file mode 100644 index 0000000..eca895a --- /dev/null +++ b/kehys/kehys.toc @@ -0,0 +1,12 @@ +## Interface: 80100 +## Title: Kehys frames +## Version: 1.0 +## Author: schyrio +## Notes: My frames + +hideblizz.lua +setup.lua +paladin.lua +events.lua +frame.lua +raid.lua diff --git a/kehys/paladin.lua b/kehys/paladin.lua new file mode 100644 index 0000000..79aa7ab --- /dev/null +++ b/kehys/paladin.lua @@ -0,0 +1,40 @@ +-- paladin.lua +local indSize = 14; +local rhomb = "Interface\\AddOns\\kuuttiRaid\\images\\rhomb"; + +local _, addon = ...; +local auras = { + [53563] = "TOPRIGHT", -- Beacon of Light + [156910] = "TOPRIGHT", -- Beacon of Faith + [200025] = "TOPRIGHT", -- Beacon of Virtue +} +addon.ClassAuras["PALADIN"] = auras; +addon.ClassIndicators["PALADIN"] = function(base) + local inds = {}; + inds["TOPRIGHT"] = base:CreateTexture(nil, "OVERLAY"); + inds["TOPRIGHT"]:SetPoint("TOPRIGHT", base, "TOPRIGHT"); + inds["TOPRIGHT"]:SetWidth(indSize); + inds["TOPRIGHT"]:SetHeight(indSize); + inds["TOPRIGHT"]:SetTexture(rhomb); + inds["TOPRIGHT"]:SetVertexColor(1, 0, 0); + inds["TOPRIGHT"]:Hide(); + return inds; +end +addon.Clickheal["PALADIN"] = { + ["type1"] = "spell", + ["type2"] = "spell", + ["shift-type1"] = "spell", + ["shift-type2"] = "spell", + ["ctrl-type1"] = "macro", + ["alt-type2"] = "spell", + ["alt-shift-type1"] = "spell", + ["alt-shift-type2"] = "spell", + ["spell1"] = "Holy Light", + ["spell2"] = "Bestow Faith", + ["shift-spell1"] = "Flash of Light", + ["shift-spell2"] = "Light of the Martyr", + ["ctrl-macro1"] = "Cleansing", + ["alt-spell2"] = "Lay on Hands", + ["alt-shift-spell1"] = "Beacon of Light", + ["alt-shift-spell2"] = "Beacon of Faith", +}; diff --git a/kehys/raid.lua b/kehys/raid.lua new file mode 100644 index 0000000..7a68f90 --- /dev/null +++ b/kehys/raid.lua @@ -0,0 +1,138 @@ +-- raid.lua +-- 2019 Aleksi Blinnikka +local _, addon = ...; +local format = string.format; +local UnitInRange = UnitInRange; +local RegisterStateDriver, RegisterUnitWatch = RegisterStateDriver, RegisterUnitWatch; + +local registerEvents = addon.RegisterEvents; +local registerUnitEvents = addon.RegisterUnitEvents; +local unitEvent = addon.UnitEvent; + +local width, height = 82, 42; +local anchorX, anchorY = 0, -330; +local attributes = {}; + +local CFrame = CreateFrame("Frame", "kehysMain", UIParent); +local class = nil; +local party = {}; +local raid = {}; + +local function unitUpdate(frame) + -- there's no in/out of range event, have to check each frame + -- from FrameXML/CompactUnitFrame.lua + local inRange, checked = UnitInRange(frame.displayed); + if checked and not inRange then + frame:SetAlpha(0.55); + else + frame:SetAlpha(1); + end +end + +local function frameShow(frame) + registerEvents(frame); + registerUnitEvents(frame); + unitEvent(frame, "UPDATE_ALL_BARS"); +end + +-- vehicle toggle from Shadowed Unit Frames +local vehicletoggle = [=[ +local unit = self:GetAttribute("unit"); +if unit and newstate == "vehicle" and not UnitTargetsVehicleInRaidUI(unit) then + self:SetAttribute("toggleForVehicle", false); +else + self:SetAttribute("toggleForVehicle", true); +end +]=] +local vehiclestates = "[@%s,unithasvehicleui] vehicle; no"; + +local function initializeParty(parent) + assert(type(parent) == "table", + "Party initialization missing parent frame!"); + local visibility = "[@%s,exists,group:raid] hide; [@%s,exists] show; hide"; + local unit = "player"; + local frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("TOPLEFT", parent, "TOPLEFT"); + RegisterStateDriver(frame, "visibility", "[@player,group:raid] hide; show"); + RegisterStateDriver(frame, "vehicleui", "[vehicleui] vehicle; no"); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); + party[0] = frame; + for i = 1,4 do + unit = "party"..i; + frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("TOPLEFT", party[i-1], "TOPRIGHT"); + RegisterStateDriver(frame, "visibility", format(visibility, unit, unit)); + RegisterStateDriver(frame, "vehicleui", format(vehiclestates, unit)); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); + party[i] = frame; + end +end + +local function initializeRaid(parent) + assert(type(parent) == "table", + "Raid initialization missing parent frame!"); + local unit = "raid1"; + local frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("TOPLEFT", parent, "TOPLEFT"); + RegisterUnitWatch(frame); + RegisterStateDriver(frame, "vehicleui", format(vehiclestates, unit)); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); + raid[1] = frame; + for y = 1,7 do + local i = y*5+1; + unit = "raid"..i; + frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("TOPLEFT", raid[i-5], "BOTTOMLEFT"); + RegisterUnitWatch(frame); + RegisterStateDriver(frame, "vehicleui", format(vehiclestates, unit)); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); + raid[i] = frame; + end + for y = 0,7 do + for x = 1,4 do + local i = y*5+x+1; + unit = "raid"..i; + frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("TOPLEFT", raid[i-1], "TOPRIGHT"); + RegisterUnitWatch(frame); + RegisterStateDriver(frame, "vehicleui", format(vehiclestates, unit)); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); + raid[i] = frame; + end + end +end + +local function initializeFocus(parent) + assert(type(parent) == "table", + "Focus initialization missing parent frame!"); + local unit = "focus"; + local frame = addon.NewRaidFrame(parent, width, height, unit, attributes, + unitUpdate, unitEvent, frameShow); + frame:SetPoint("BOTTOMLEFT", parent, "TOPLEFT"); + RegisterUnitWatch(frame); + RegisterStateDriver(frame, "vehicleui", format(vehiclestates, unit)); + frame:SetAttribute("_onstate-vehicleui", vehicletoggle); +end + +local function initialize() + _, class = UnitClass("player"); + attributes = addon.Clickheal[class]; + CFrame:SetFrameStrata("LOW"); + CFrame:SetPoint("CENTER", nil, "CENTER", anchorX, anchorY); + CFrame:SetHeight((height+2)*8); + CFrame:SetWidth((width+2)*5); + initializeParty(CFrame); + initializeRaid(CFrame); + initializeFocus(CFrame); +end + +CFrame:SetScript("OnEvent", function(self) + self:UnregisterAllEvents(); + initialize(); +end); +CFrame:RegisterEvent("PLAYER_LOGIN"); diff --git a/kehys/setup.lua b/kehys/setup.lua new file mode 100644 index 0000000..8c47b57 --- /dev/null +++ b/kehys/setup.lua @@ -0,0 +1,21 @@ +-- setup.lua +-- 2019 Aleksi Blinnikka +local _; + +local _, addon = ...; + +addon.ClassAuras = {}; +addon.ClassIndicators = {}; +addon.Clickheal = {}; + +addon.Colors = { + Base = {0, 0, 0}, + HealthColor = {0.3, 0.3, 0.3}, + ShieldColor = {0, 0.7, 1}, + ShieldhlColor = {0.5, 0.8, 1}, + HealpredColor = {0.5, 0.6, 0.5}, + HealabsorbColor = {0.1, 0.1, 0.1}, + OverlayColorDispel = {1, 0.5, 0, 0.5}, + OverlayColorCharm = {0.8, 0, 1, 0.5}, + OverlayColorAlert = {1, 0, 0, 0.5}, +} -- 2.39.5