X-Git-Url: https://www.aleksib.fi/git/wowui.git/blobdiff_plain/d180f82975c6b13a3380bd8df5ab47df70112c49..290e5ed3b990ff79225e9048b24166614bf1f8a1:/OmaRF/Events.lua diff --git a/OmaRF/Events.lua b/OmaRF/Events.lua index 4316a82..faeff80 100644 --- a/OmaRF/Events.lua +++ b/OmaRF/Events.lua @@ -13,24 +13,28 @@ local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; local UnitHasIncomingResurrection = UnitHasIncomingResurrection; local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs; local UnitHasVehicleUI, UnitTargetsVehicleInRaidUI = UnitHasVehicleUI, UnitTargetsVehicleInRaidUI; +local GetReadyCheckTimeLeft, GetReadyCheckStatus = GetReadyCheckTimeLeft, GetReadyCheckStatus; local UnitGroupRolesAssigned = UnitGroupRolesAssigned; 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 checkIndicators = OmaRFIndicators.CheckIndicators; local Settings = OmaRFSettings; -local width = Settings.Character.Width; local baseColor = Settings.BaseColor; local overlayColorDispel = Settings.OverlayColorDispel; local overlayColorCharm = Settings.OverlayColorCharm; local overlayColorAlert = Settings.OverlayColorAlert; local powerColors = Settings.PowerColors; +local width = 10; local M = {}; OmaRFEvents = M; function M.RegisterEvents(frame) -- events are taken from FrameXML/CompactUnitFrame.lua - -- TODO ready check support, raid marker support, + -- TODO raid marker support, -- player flags support (/afk, /dnd) local displayed = frame.unit ~= frame.displayed and frame.displayed or nil; frame:RegisterUnitEvent("UNIT_HEALTH", frame.unit, displayed); @@ -80,8 +84,10 @@ local function updateText(frame, unit) local healthLost = max - current; if UnitIsDeadOrGhost(unit) then frame.text:SetText("Dead"); + frame.text:Show(); elseif not UnitIsConnected(unit) then frame.text:SetText("DC"); + frame.text:Show(); elseif healthLost > 0 then if healthLost > 1200000000 then -- 1.2B frame.text:SetFormattedText("-%.1fB", healthLost / 1000000000); @@ -253,6 +259,23 @@ local function updateRole(frame, unit) end end +local function updateReadyCheck(frame, unit) + if GetReadyCheckTimeLeft() <= 0 then return end + 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 eventFuncs = { ["UNIT_HEALTH"] = function(frame) updateHealth(frame, frame.displayed); @@ -310,6 +333,9 @@ local eventFuncs = { ["PLAYER_ROLES_ASSIGNED"] = function(frame) updateRole(frame, frame.unit); end, + ["READY_CHECK"] = function(frame) + updateReadyCheck(frame, frame.unit); + end, ["UPDATE_ALL_BARS"] = function(frame) updateVehicle(frame); updateMaxHealth(frame, frame.displayed); @@ -323,6 +349,7 @@ local eventFuncs = { updateHealAbsorb(frame, frame.displayed); updatePowerColor(frame, frame.displayed); updateIncomingRes(frame, frame.unit); + updateReadyCheck(frame, frame.unit); updateAggro(frame, frame.displayed); updateName(frame, frame.displayed); updateRole(frame, frame.unit); @@ -330,10 +357,18 @@ local eventFuncs = { }; eventFuncs["UNIT_HEALTH_FREQUENT"] = eventFuncs["UNIT_HEALTH"]; eventFuncs["PARTY_MEMBER_DISABLE"] = eventFuncs["PARTY_MEMBER_ENABLE"]; +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"]; + function M.UnitEvent(self, event) eventFuncs[event](self); end + +function M.LoadChar() + width = Settings.Character.Width; +end