From: Aleksi Blinnikka Date: Thu, 7 May 2020 14:44:03 +0000 (+0300) Subject: Working player frame X-Git-Url: https://www.aleksib.fi/git/wowui.git/commitdiff_plain/3ce401749aaa236c206a034549ab161bd8bd1ec9 Working player frame --- diff --git a/kehys/auras.lua b/kehys/auras.lua index 07b28da..ec03f42 100644 --- a/kehys/auras.lua +++ b/kehys/auras.lua @@ -19,6 +19,9 @@ local watchedAuras = { [287280] = {1, "buff1"}, -- Glimmer of Light [194384] = {1, "buff1"}, -- Atonement [61295] = {1, "buff1"}, -- Riptide + [53563] = {1, "buff2"}, -- Beacon of Light + [156910] = {1, "buff2"}, -- Beacon of Faith + [200025] = {1, "buff2"}, -- Beacon of Virtue -- Tank defensives [6940] = {1, "tankcd"}, -- Blessing of Sacrifice [33206] = {1, "tankcd"}, -- Pain Suppression diff --git a/kehys/events.lua b/kehys/events.lua index 3c15fcf..f7ad732 100644 --- a/kehys/events.lua +++ b/kehys/events.lua @@ -33,7 +33,9 @@ local width = 80; function addon.RegisterEvents(frame) frame:RegisterEvent("PLAYER_ENTERING_WORLD"); frame:RegisterEvent("RAID_TARGET_UPDATE"); + if frame.unit == "player" then frame:RegisterEvent("PLAYER_ALIVE") end if frame.unit == "focus" then frame:RegisterEvent("PLAYER_FOCUS_CHANGED") end + if frame.unit == "target" then frame:RegisterEvent("PLAYER_TARGET_CHANGED") end if not frame.nonraid then frame:RegisterEvent("PLAYER_REGEN_DISABLED"); frame:RegisterEvent("READY_CHECK"); @@ -48,7 +50,10 @@ function addon.RegisterUnitEvents(frame) frame:RegisterUnitEvent("UNIT_ENTERED_VEHICLE", frame.unit, displayed); frame:RegisterUnitEvent("UNIT_EXITED_VEHICLE", frame.unit, displayed); frame:RegisterUnitEvent("UNIT_PET", frame.unit, displayed); - if frame.unit ~= "player" then + if frame.unit == "focus" or frame.unit == "target" then + frame:RegisterUnitEvent("UNIT_TARGETABLE_CHANGED", frame.unit, displayed); + end + if not frame.nonraid or frame.unit ~= "player" then frame:RegisterUnitEvent("UNIT_NAME_UPDATE", frame.unit, displayed); end if not frame.nonraid then @@ -176,13 +181,14 @@ local eventFuncs = { frame.stacks = {}; frame.heal = {}; frame.buff1 = {}; + frame.buff2 = {}; addon.SetAuras(frame.unit, frame.guid); end end, ["UPDATE_ALL_BARS"] = function(frame) updateVehicle(frame); updateRaidMarker(frame, frame.displayed); - if frame.unit ~= "player" then + if not frame.nonraid or frame.unit ~= "player" then updateName(frame, frame.unit); end if not frame.nonraid then @@ -201,6 +207,7 @@ local eventFuncs = { frame.stacks = {}; frame.heal = {}; frame.buff1 = {}; + frame.buff2 = {}; addon.SetAuras(frame.unit, frame.guid); end end, @@ -213,6 +220,9 @@ 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"]; +eventFuncs["PLAYER_TARGET_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["UNIT_TARGETABLE_CHANGED"] = eventFuncs["UPDATE_ALL_BARS"]; +eventFuncs["PLAYER_ALIVE"] = eventFuncs["UPDATE_ALL_BARS"]; function addon.UnitEvent(self, event) return eventFuncs[event](self); diff --git a/kehys/frame.lua b/kehys/frame.lua index 0e17ed7..84a8c2d 100644 --- a/kehys/frame.lua +++ b/kehys/frame.lua @@ -55,6 +55,7 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes, f.tankcd = {}; -- tank CD auras f.stacks = {}; -- stacking aura tracking f.buff1 = {}; -- custom buff indicator 1 + f.buff2 = {}; -- custom buff indicator 2 f.incoming = {}; -- incoming ability indicator f.rounds = 0; -- set up periodic updates @@ -153,18 +154,24 @@ function addon.NewRaidFrame(parent, width, height, unit, attributes, f.ready:SetPoint("TOPLEFT", f, "BOTTOMLEFT", 1, 15); f.ready:SetPoint("BOTTOMRIGHT", f, "BOTTOMLEFT", 15, 1); f.ready:Hide(); - f.defensive = f:CreateTexture(nil, "OVERLAY"); - f.defensive:SetPoint("TOPLEFT", f.background, "TOPLEFT", 1, -1); - f.defensive:SetWidth(6); - f.defensive:SetHeight(6); - f.defensive:SetColorTexture(1, 0.3, 0); - f.defensive:Hide(); f.buffind1 = f:CreateTexture(nil, "OVERLAY"); f.buffind1:SetPoint("TOPRIGHT", f.background, "TOPRIGHT", -1, -1); f.buffind1:SetWidth(6); f.buffind1:SetHeight(6); f.buffind1:SetColorTexture(0.8, 0.1, 0.1); f.buffind1:Hide(); + f.buffind2 = f:CreateTexture(nil, "OVERLAY"); + f.buffind2:SetPoint("TOPLEFT", f.background, "TOPLEFT", 1, -1); + f.buffind2:SetWidth(4); + f.buffind2:SetHeight(4); + f.buffind2:SetColorTexture(0.8, 0.7, 0.1); + f.buffind2:Hide(); + f.defensive = f:CreateTexture(nil, "OVERLAY", nil, 1); + f.defensive:SetPoint("TOPLEFT", f.background, "TOPLEFT", 1, -1); + f.defensive:SetWidth(6); + f.defensive:SetHeight(6); + f.defensive:SetColorTexture(1, 0.3, 0); + f.defensive:Hide(); f.targeticon = f:CreateTexture(nil, "OVERLAY"); f.targeticon:SetPoint("CENTER", f, "TOP", 0, -1); f.targeticon:SetWidth(12); diff --git a/kehys/hideblizz.lua b/kehys/hideblizz.lua index 6ab3de1..e33db33 100644 --- a/kehys/hideblizz.lua +++ b/kehys/hideblizz.lua @@ -48,6 +48,47 @@ local function hideBlizzardRaid() end end +local uf_hidden = false; +local function hideBlizzardUnitFrames() + if uf_hidden then return end + uf_hidden = true; + + local frames = { + PlayerFrame, PaladinPowerBarFrame, WarlockPowerFrame, + PlayerFrameAlternateManaBar, + }; + --local frames = {PlayerFrame, TargetFrame, TargetFrameToT, PetFrame, + -- PlayerFrameAlternateManaBar, ComboFrame, PriestBarFrame, RuneFrame, + -- WarlockPowerFrame, MonkHarmonyBarFrame, PaladinPowerBarFrame, + -- MageArcaneChargesFrame, CastingBarFrame, PetCastingBarFrame}; + --for i = 1,MAX_BOSS_FRAMES do + -- table.insert(frames, _G["Boss"..i.."TargetFrame"]); + -- table.insert(frames, _G["Boss"..i.."TargetFrameHealthBar"]); + -- table.insert(frames, _G["Boss"..i.."TargetFrameManaBar"]); + -- -- keep boss frame powerBarAlt + --end + for _, frame in pairs(frames) 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 + + -- from ShadowedUF, re-register vehicle events for default auras + PlayerFrame:RegisterEvent("PLAYER_ENTERING_WORLD"); + PlayerFrame:RegisterEvent("UNIT_ENTERING_VEHICLE"); + PlayerFrame:RegisterEvent("UNIT_ENTERED_VEHICLE"); + PlayerFrame:RegisterEvent("UNIT_EXITING_VEHICLE"); + PlayerFrame:RegisterEvent("UNIT_EXITED_VEHICLE"); + PlayerFrame:SetMovable(true); + PlayerFrame:SetUserPlaced(true); + PlayerFrame:SetDontSavePosition(true); + CastingBarFrame:ClearAllPoints(); + CastingBarFrame:SetPoint("BOTTOM", UIParent, "CENTER", -300, -146); +end + local hider = CreateFrame("Frame"); hider:Hide(); hider:RegisterEvent("PLAYER_LOGIN"); @@ -59,5 +100,6 @@ hider:SetScript("OnEvent", function(self, event) hideBlizzardRaidButton(); elseif event == "PLAYER_LOGIN" then hideBlizzardRaid(); + hideBlizzardUnitFrames(); end end); diff --git a/kehys/player.lua b/kehys/player.lua index ce390f5..89e15af 100644 --- a/kehys/player.lua +++ b/kehys/player.lua @@ -3,8 +3,9 @@ local _, addon = ...; local unpack = unpack; local format = string.format; local CFrame = CreateFrame("Frame", "kehysPlayerInit", UIParent); +local CTimerAfter = C_Timer.After; -local barTexture = "Interface\\AddOns\\OmaRF\\images\\minimalist"; +local barTexture = "Interface\\AddOns\\kehys\\images\\minimalist"; local vehicletoggle = [=[ if newstate == "vehicle" then self:SetAttribute("displayed", self:GetAttribute("vehicle")); @@ -14,7 +15,7 @@ local vehicletoggle = [=[ ]=] local updater = nil; -function addon.PlayerFrame(parent, width, height, update, event) +local function initPlayer(parent, width, height, update, event) assert(type(parent) == "table", "Player frame creation missing parent!"); assert(type(width) == "number", "Player frame creation missing width!"); assert(type(height) == "number", "Player frame creation missing height!"); @@ -26,28 +27,25 @@ function addon.PlayerFrame(parent, width, height, update, event) local f = CreateFrame("Button", "kehysPlayer", parent, "SecureUnitButtonTemplate,SecureHandlerStateTemplate"); f:Hide(); - f:SetPoint("CENTER", parent, "CENTER", 10, 10); + f:SetPoint("CENTER", parent, "CENTER", -300, -178); f:SetWidth(width); f:SetHeight(height); f.barwidth = width - 2; -- 1px padding f:SetAttribute("unit", "player"); f:SetAttribute("displayed", "player"); f:SetAttribute("vehicle", "vehicle"); + f.unit = "player"; + f.displayed = "player"; + f.vehicle = "vehicle" f.nonraid = true; f.prev = {}; - -- empty, just to be able to use general updater - f.alert = {}; - f.heal = {}; - f.tankcd = {}; - f.stacks = {}; - f.buff1 = {}; - f.incoming = {}; updater = function() CTimerAfter(0.1, updater); update(f); end f:SetScript("OnEvent", event); + f:RegisterForClicks("AnyDown"); f:SetAttribute("*type1", "target"); f:SetAttribute("*type2", "togglemenu"); f:SetAttribute("toggleForVehicle", true); @@ -57,26 +55,24 @@ function addon.PlayerFrame(parent, width, height, update, event) -- 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, 2); + f.base:SetColorTexture(0, 0, 0, 0.5); + 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, "LEFT", 0, 1); + f.health:SetPoint("BOTTOMLEFT", f.background, "LEFT", 0, -height/8); f.health:SetTexture(barTexture); - f.health:SetVertexColor(0.3, 0.3, 0.3); + f.health:SetVertexColor(0.8, 0.8, 0.8); f.health:Hide(); f.mana = f:CreateTexture(nil, "BORDER"); - f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -1); + f.mana:SetPoint("TOPLEFT", f.background, "LEFT", 0, -height/8); f.mana:SetPoint("BOTTOMLEFT", f.background, "BOTTOMLEFT"); f.mana:SetTexture(barTexture); - f.mana:SetVertexColor(0.3, 0.4, 0.7); + f.mana:SetVertexColor(0.1, 0.5, 0.9); f.mana:Hide(); f.manatext = f:CreateFontString(nil, "ARTWORK", "GameFontHighlight"); - f.manatext:SetPoint("RIGHT", frame.background, "RIGHT", -2, -height/4); + f.manatext:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMRIGHT", -2, 4); f.manatext:Hide(); f.shield = f:CreateTexture(nil, "BORDER"); f.shield:SetPoint("TOPLEFT", f.health, "TOPRIGHT"); @@ -86,7 +82,7 @@ function addon.PlayerFrame(parent, width, height, update, event) f.shield:Hide(); f.shieldhl = f:CreateTexture(nil, "ARTWORK"); f.shieldhl:SetPoint("TOPLEFT", f, "TOPRIGHT", -2, 0); - f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT"); + f.shieldhl:SetPoint("BOTTOMRIGHT", f, "RIGHT", 0, -height/8); f.shieldhl:SetColorTexture(0.5, 0.8, 1); f.shieldhl:Hide(); f.healpred = f:CreateTexture(nil, "ARTWORK"); @@ -109,12 +105,17 @@ function addon.PlayerFrame(parent, width, height, update, event) f.targeticon:SetHeight(12); f.targeticon:SetTexture("Interface\\TARGETINGFRAME\\UI-RaidTargetingIcons"); f.targeticon:Hide(); + f.status = f:CreateTexture(nil, "OVERLAY"); + f.status:SetPoint("TOPLEFT", f.background, "BOTTOMLEFT", -8, 8); + f.status:SetPoint("BOTTOMRIGHT", f.background, "BOTTOMLEFT", 8, -8); + f.status:SetTexture("Interface\\CHARACTERFRAME\\UI-StateIcon"); + f.status:Hide(); - registerEvents(f); - registerUnitEvents(f); + addon.RegisterEvents(f); + addon.RegisterUnitEvents(f); event(f, "UPDATE_ALL_BARS"); updater(); - f.Show(); + f:Show(); end CFrame:SetScript("OnEvent", function(self) @@ -123,6 +124,6 @@ CFrame:SetScript("OnEvent", function(self) CFrame:SetPoint("CENTER", nil, "CENTER"); CFrame:SetWidth(2); CFrame:SetHeight(2); - initPlayer(self, 180, 100, addon.FrameUpdate, addon.UnitEvent); + initPlayer(self, 160, 48, addon.FrameUpdate, addon.UnitEvent); end); CFrame:RegisterEvent("PLAYER_LOGIN"); diff --git a/kehys/updater.lua b/kehys/updater.lua index be908d2..96e9f49 100644 --- a/kehys/updater.lua +++ b/kehys/updater.lua @@ -13,7 +13,7 @@ local UnitIsAFK, UnitIsDND = UnitIsAFK, UnitIsDND; local UnitGetIncomingHeals, UnitGetTotalAbsorbs = UnitGetIncomingHeals, UnitGetTotalAbsorbs; local UnitIsDeadOrGhost, UnitIsConnected = UnitIsDeadOrGhost, UnitIsConnected; local UnitGetTotalHealAbsorbs = UnitGetTotalHealAbsorbs; -local IsResting = IsResting; +local InCombatLockdown, IsResting = InCombatLockdown, IsResting; local dispelcolor = addon.Colors.OverlayColorDispel; local charmcolor = addon.Colors.OverlayColorCharm; @@ -24,6 +24,14 @@ local ignoredAuras = { [315176] = true, -- Grasping Tendrils }; +local powerColors = { + [Enum.PowerType.Mana] = {0.1, 0.5, 0.9}, + [Enum.PowerType.Rage] = {1, 0, 0}, + [Enum.PowerType.Focus] = {1, 0.5, 0}, + [Enum.PowerType.Energy] = {1, 0.8, 0}, + [Enum.PowerType.RunicPower] = {0.8, 0, 0.2}, +}; + function addon.FrameUpdate(frame) assert(type(frame) == "table", "FrameUpdate received invalid frame parameter!"); @@ -66,12 +74,20 @@ function addon.FrameUpdate(frame) elseif UnitIsDND(unit) then frame.text:SetText("dnd"); if not frame.text:IsShown() then frame.text:Show() end - elseif frame.nonraid and frame.unit == "player" and IsResting() then - frame.text:SetText("zzz"); - if not frame.text:IsShown() then frame.text:Show() end else if frame.text:IsShown() then frame.text:Hide() end end + if frame.nonraid and frame.unit == "player" then + if InCombatLockdown() then + frame.status:SetTexCoord(0.5, 1, 0, 0.484375); + frame.status:Show(); + elseif IsResting() then + frame.status:SetTexCoord(0, 0.5, 0, 0.421875); + frame.status:Show(); + elseif frame.status:IsShown() then + frame.status:Hide(); + end + end -- TODO incoming res, maybe just with events? -- health local current, hmax = UnitHealth(unit), UnitHealthMax(unit); @@ -135,6 +151,11 @@ function addon.FrameUpdate(frame) -- mana, if present if frame.mana ~= nil then local current, max = UnitPower(unit), UnitPowerMax(unit); + local ptype = UnitPowerType(unit); + if frame.mana.ptype ~= ptype then + frame.mana.ptype = ptype; + frame.mana:SetVertexColor(unpack(powerColors[ptype])); + end if frame.prev.mana ~= current or frame.prev.mmax ~= max then frame.prev.mana = current; frame.prev.mmax = max; @@ -149,7 +170,7 @@ function addon.FrameUpdate(frame) else local percent = current/max; frame.mana:SetWidth(percent*width); - frame.manatext:SetText(format("%d", percent*100)); + frame.manatext:SetText(format("%d", percent*100+0.5)); if not frame.mana:IsShown() then frame.mana:Show() end if not frame.manatext:IsShown() then frame.manatext:Show() end end @@ -168,67 +189,75 @@ function addon.FrameUpdate(frame) frame.rounds = 0; end end - -- tank CD marker - if next(frame.tankcd) then - if not frame.defensive:IsShown() then frame.defensive:Show() end - elseif frame.defensive:IsShown() then - frame.defensive:Hide(); - end - -- aura stacks - if next(frame.stacks) then - local _, amount = next(frame.stacks); - frame.stack:SetText(amount); - if not frame.stack:IsShown() then frame.stack:Show() end - elseif frame.stack:IsShown() then - frame.stack:Hide(); - end - -- custom buff indicator 1 - if next(frame.buff1) then - if not frame.buffind1:IsShown() then frame.buffind1:Show() end - elseif frame.buffind1:IsShown() then - frame.buffind1:Hide(); - end - -- incoming ability - if next(frame.incoming) then - if not frame.glow:IsShown() then frame.glow:Show() end - elseif frame.glow:IsShown() then - frame.glow:Hide(); - end - -- overlays - if next(frame.alert) then - -- major - if frame.overlay.color ~= majorcolor then - frame.overlay:SetVertexColor(unpack(majorcolor)); - frame.overlay.color = majorcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end + if not frame.nonraid then + -- tank CD marker + if next(frame.tankcd) then + if not frame.defensive:IsShown() then frame.defensive:Show() end + elseif frame.defensive:IsShown() then + frame.defensive:Hide(); end - elseif frame.overlay ~= nil then - local _, _, _, _, _, _, _, _, _, spellid = UnitDebuff(unit, 1, "RAID"); - if UnitIsCharmed(unit) and frame.unit == frame.displayed then - -- charmed - if frame.overlay.color ~= charmcolor then - frame.overlay:SetVertexColor(unpack(charmcolor)); - frame.overlay.color = charmcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end - end - elseif spellid ~= nil and not ignoredAuras[spellid] then - -- dispellable - if frame.overlay.color ~= dispelcolor then - frame.overlay:SetVertexColor(unpack(dispelcolor)); - frame.overlay.color = dispelcolor; - if not frame.overlay:IsShown() then frame.overlay:Show() end - end - elseif next(frame.heal) then - -- major heals needed - if frame.overlay.color ~= healcolor then - frame.overlay:SetVertexColor(unpack(healcolor)); - frame.overlay.color = healcolor; + -- aura stacks + if next(frame.stacks) then + local _, amount = next(frame.stacks); + frame.stack:SetText(amount); + if not frame.stack:IsShown() then frame.stack:Show() end + elseif frame.stack:IsShown() then + frame.stack:Hide(); + end + -- custom buff indicator 1 + if next(frame.buff1) then + if not frame.buffind1:IsShown() then frame.buffind1:Show() end + elseif frame.buffind1:IsShown() then + frame.buffind1:Hide(); + end + -- custom buff indicator 2 + if next(frame.buff2) then + if not frame.buffind2:IsShown() then frame.buffind2:Show() end + elseif frame.buffind2:IsShown() then + frame.buffind2:Hide(); + end + -- incoming ability + if next(frame.incoming) then + if not frame.glow:IsShown() then frame.glow:Show() end + elseif frame.glow:IsShown() then + frame.glow:Hide(); + end + -- overlays + if next(frame.alert) then + -- major + if frame.overlay.color ~= majorcolor then + frame.overlay:SetVertexColor(unpack(majorcolor)); + frame.overlay.color = majorcolor; if not frame.overlay:IsShown() then frame.overlay:Show() end end else - if frame.overlay.color ~= nil then - frame.overlay.color = nil; - if frame.overlay:IsShown() then frame.overlay:Hide() end + local _, _, _, _, _, _, _, _, _, spellid = UnitDebuff(unit, 1, "RAID"); + if UnitIsCharmed(unit) and frame.unit == frame.displayed then + -- charmed + if frame.overlay.color ~= charmcolor then + frame.overlay:SetVertexColor(unpack(charmcolor)); + frame.overlay.color = charmcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + elseif spellid ~= nil and not ignoredAuras[spellid] then + -- dispellable + if frame.overlay.color ~= dispelcolor then + frame.overlay:SetVertexColor(unpack(dispelcolor)); + frame.overlay.color = dispelcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + elseif next(frame.heal) then + -- major heals needed + if frame.overlay.color ~= healcolor then + frame.overlay:SetVertexColor(unpack(healcolor)); + frame.overlay.color = healcolor; + if not frame.overlay:IsShown() then frame.overlay:Show() end + end + else + if frame.overlay.color ~= nil then + frame.overlay.color = nil; + if frame.overlay:IsShown() then frame.overlay:Hide() end + end end end end