Skip to content

Commit

Permalink
PhaseIcon: Add a tooltip for the phase reason
Browse files Browse the repository at this point in the history
  • Loading branch information
nebularg committed Jul 30, 2020
1 parent 2e82a09 commit b88e986
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ globals = {
"C_AzeriteItem",
"C_CreatureInfo",
"C_IncomingSummon",
"C_PvP",
"C_Timer",
"CancelItemTempEnchantment",
"CancelUnitBuff",
Expand Down Expand Up @@ -107,6 +108,7 @@ globals = {
"IsSpellKnown",
"LoadAddOn",
"MainMenuBar_UpdateExperienceBars",
"PartyUtil",
"PlaySound",
"PlaySoundFile",
"RegisterStateDriver",
Expand Down
53 changes: 53 additions & 0 deletions Modules/PhaseIcon/PhaseIcon.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PitBull4_PhaseIcon:SetDefaults({
attach_to = "root",
location = "edge_top_left",
position = 1,
click_through = false,
})

function PitBull4_PhaseIcon:OnEnable()
Expand All @@ -22,6 +23,37 @@ function PitBull4_PhaseIcon:OnEnable()
end


function PitBull4_PhaseIcon:GetEnableMouse(frame)
local db = self:GetLayoutDB(frame)
return not db.click_through
end

function PitBull4_PhaseIcon:OnEnter()
local unit = self:GetParent().unit
local tooltip = _G.PARTY_PHASED_MESSAGE
if wow_900 then
local phaseReason = UnitPhaseReason(unit)
if phaseReason then
tooltip = PartyUtil.GetPhasedReasonString(phaseReason, unit)
end
else
if UnitIsWarModePhased(unit) then
if C_PvP.IsWarModeDesired() then
tooltip = _G.PARTY_PLAYER_WARMODE_DISABLED
else
tooltip = _G.PARTY_PLAYER_WARMODE_ENABLED
end
end
end
GameTooltip:SetOwner(self, "ANCHOR_RIGHT")
GameTooltip:SetText(tooltip, nil, nil, nil, nil, true)
GameTooltip:Show()
end

function PitBull4_PhaseIcon:OnLeave()
GameTooltip:Hide()
end

function PitBull4_PhaseIcon:GetTexture(frame)
local unit = frame.unit
-- Note the UnitInPhase function doesn't work for pets.
Expand Down Expand Up @@ -53,3 +85,24 @@ end
function PitBull4_PhaseIcon:PARTY_MEMBER_ENABLE(_, unit)
self:UpdateAll()
end


PitBull4_PhaseIcon:SetLayoutOptionsFunction(function(self)
return 'click_through', {
type = 'toggle',
name = L["Click-through"],
desc = L["Disable capturing clicks on icons, allowing the click to fall through to the window underneath the icon."],
get = function(info)
return PitBull4.Options.GetLayoutDB(self).click_through
end,
set = function(info, value)
PitBull4.Options.GetLayoutDB(self).click_through = value

for frame in PitBull4:IterateFrames() do
self:Clear(frame)
self:Update(frame)
end
end,
order = 100,
}
end)

0 comments on commit b88e986

Please sign in to comment.