From f01cd2648aae98b2c6c9c5648309cf2bb18418b0 Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 26 Dec 2018 11:31:28 +0100 Subject: [PATCH] unitframes: add resting icon Thanks @AMGarkin (https://gitlab.com/shagu/pfUI/merge_requests/990) --- api/config.lua | 1 + api/unitframes.lua | 26 ++++++++++++++++++++++++-- modules/gui.lua | 1 + 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/api/config.lua b/api/config.lua index ee3b77a0..d4285e19 100644 --- a/api/config.lua +++ b/api/config.lua @@ -186,6 +186,7 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", nil, "clickcast_ctrl", "") pfUI:UpdateConfig("unitframes", "player", "showPVPMinimap", "0") + pfUI:UpdateConfig("unitframes", "player", "showRest", "0") pfUI:UpdateConfig("unitframes", "player", "energy", "1") pfUI:UpdateConfig("unitframes", "player", "visible", "1") diff --git a/api/unitframes.lua b/api/unitframes.lua index 6aedfae9..6c9c8cec 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -343,11 +343,18 @@ function pfUI.uf:UpdateConfig() f.raidIcon:SetWidth(24) f.raidIcon:SetHeight(24) f.raidIcon:SetPoint("TOP", f, "TOP", 0, 6) - f.raidIcon.texture:SetTexture("Interface\\AddOns\\pfUI\\img\\raidicons") f.raidIcon.texture:SetAllPoints(f.raidIcon) f.raidIcon:Hide() + f.restIcon:SetWidth(16) + f.restIcon:SetHeight(16) + f.restIcon:SetPoint("TOP", f, "TOPLEFT", 0, -1) + f.restIcon.texture:SetTexture("Interface\\CharacterFrame\\UI-StateIcon", true) + f.restIcon.texture:SetTexCoord(0, .5, 0, .421875) + f.restIcon.texture:SetAllPoints(f.restIcon) + f.restIcon:Hide() + if f.config.buffs == "off" then for i=1, 32 do if f.buffs and f.buffs[i] then @@ -567,7 +574,8 @@ function pfUI.uf:EnableScripts() f:RegisterEvent("UNIT_INVENTORY_CHANGED") -- label=player && frame=buff f:RegisterEvent("PARTY_MEMBERS_CHANGED") -- label=party, frame=leaderIcon f:RegisterEvent("PARTY_LEADER_CHANGED") -- frame=leaderIcon - f:RegisterEvent("RAID_ROSTER_UPDATE") -- label=raid + f:RegisterEvent("RAID_ROSTER_UPDATE") -- label=raidIcon + f:RegisterEvent("PLAYER_UPDATE_RESTING") -- label=restIcon f:RegisterEvent("PLAYER_TARGET_CHANGED") -- label=target f:RegisterEvent("PARTY_LOOT_METHOD_CHANGED") -- frame=lootIcon f:RegisterEvent("RAID_TARGET_UPDATE") -- frame=raidIcon @@ -597,6 +605,8 @@ function pfUI.uf:EnableScripts() pfUI.uf:RefreshUnit(this, "all") elseif event == "RAID_TARGET_UPDATE" then pfUI.uf:RefreshUnit(this, "raidIcon") + elseif this.label == "player" and event == "PLAYER_UPDATE_RESTING" then + pfUI.uf:RefreshUnit(this, "restIcon") elseif event == "PARTY_LOOT_METHOD_CHANGED" then pfUI.uf:RefreshUnit(this, "lootIcon") elseif event == "PARTY_LEADER_CHANGED" then @@ -781,6 +791,9 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick) f.raidIcon = CreateFrame("Frame", nil, f.hp.bar) f.raidIcon.texture = f.raidIcon:CreateTexture(nil,"ARTWORK") + f.restIcon = CreateFrame("Frame", nil, f.hp.bar) + f.restIcon.texture = f.restIcon:CreateTexture(nil, "BACKGROUND") + f.portrait = CreateFrame("Frame", "pfPortrait" .. f.label .. f.id, f) f.portrait.tex = f.portrait:CreateTexture("pfPortraitTexture" .. f.label .. f.id, "OVERLAY") f.portrait.model = CreateFrame("PlayerModel", "pfPortraitModel" .. f.label .. f.id, f.portrait) @@ -1056,6 +1069,15 @@ function pfUI.uf:RefreshUnit(unit, component) end end + -- Rest Icon + if unit.restIcon and unit:GetName() == "pfPlayer" and ( component == "all" or component == "restIcon" ) then + if C.unitframes.player.showRest == "1" and UnitIsUnit(unitstr, "player") and IsResting() then + unit.restIcon:Show() + else + unit.restIcon:Hide() + end + end + -- Buffs if unit.buffs and ( component == "all" or component == "aura" ) then for i=1, unit.config.bufflimit do diff --git a/modules/gui.lua b/modules/gui.lua index e1e1dc02..00183106 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -939,6 +939,7 @@ pfUI:RegisterModule("gui", function () CreateConfig(nil, this, T["Range Check Interval"], C.unitframes, "rangechecki", "dropdown", pfUI.gui.dropdowns.uf_rangecheckinterval) CreateConfig(nil, this, T["Combopoint Size"], C.unitframes, "combosize") CreateConfig(nil, this, T["Abbreviate Numbers (4200 -> 4.2k)"], C.unitframes, "abbrevnum", "checkbox") + CreateConfig(nil, this, T["Show Resting"], C.unitframes.player, "showRest", "checkbox") CreateConfig(nil, this, T["Enable Energy Ticks"], C.unitframes.player, "energy", "checkbox") this.setup = true end