Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core: Use new ping template and add support for nameplates #670

Merged
merged 2 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ ignore = {
'312/event', -- unused value of argument event
'312/unit', -- unused value of argument unit
'431', -- shadowing an upvalue
'614', -- trailing whitespace in comment (which is valid markdown for our docs)
'631', -- line is too long
}

Expand Down
27 changes: 8 additions & 19 deletions ouf.lua
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,6 @@ local function initObject(unit, style, styleFunc, header, ...)
object:SetAttribute('*type2', 'togglemenu')
object:SetAttribute('toggleForVehicle', true)

--[[ frame.IsPingable
This boolean can be set to false to disable the frame from being pingable. Enabled by default.
--]]
--[[ Override: frame:GetContextualPingType()
Used to define which contextual ping is used for the frame.

By default this wraps `C_Ping.GetContextualPingTypeForUnit(UnitGUID(frame.unit))`.
--]]
object:SetAttribute('ping-receiver', true)

if(isEventlessUnit(objectUnit)) then
oUF:HandleEventlessUnit(object)
else
Expand Down Expand Up @@ -356,8 +346,6 @@ local function initObject(unit, style, styleFunc, header, ...)
func(object)
end

Mixin(object, PingableType_UnitFrameMixin)

-- Make Clique kinda happy
if(not object.isNamePlate) then
_G.ClickCastFrames = _G.ClickCastFrames or {}
Expand Down Expand Up @@ -606,8 +594,6 @@ do
frame:SetAttribute('*type1', 'target')
frame:SetAttribute('*type2', 'togglemenu')
frame:SetAttribute('oUF-guessUnit', unit)

frame:SetAttribute('ping-receiver', true)
end

local body = header:GetAttribute('oUF-initialConfigFunction')
Expand Down Expand Up @@ -638,7 +624,7 @@ do
for possible values.

In addition to the standard group headers, oUF implements some of its own attributes. These can be supplied by the
layout, but are optional.
layout, but are optional. PingableUnitFrameTemplate is inherited for Ping support.

* oUF-initialConfigFunction - can contain code that will be securely run at the end of the initial secure
configuration (string?)
Expand All @@ -653,7 +639,7 @@ do
local name = overrideName or generateName(nil, ...)
local header = CreateFrame('Frame', name, PetBattleFrameHider, template)

header:SetAttribute('template', 'SecureUnitButtonTemplate, SecureHandlerStateTemplate, SecureHandlerEnterLeaveTemplate')
header:SetAttribute('template', 'SecureUnitButtonTemplate, SecureHandlerStateTemplate, SecureHandlerEnterLeaveTemplate, PingableUnitFrameTemplate')
for i = 1, select('#', ...), 2 do
local att, val = select(i, ...)
if(not att) then break end
Expand Down Expand Up @@ -732,7 +718,8 @@ Used to create a single unit frame and apply the currently active style to it.
* overrideName - unique global name to use for the unit frame. Defaults to an auto-generated name based on the unit
(string?)

oUF implements some of its own attributes. These can be supplied by the layout, but are optional.
oUF implements some of its own attributes. These can be supplied by the layout, but are optional.
PingableUnitFrameTemplate is inherited for Ping support.

* oUF-enableArenaPrep - can be used to toggle arena prep support. Defaults to true (boolean)
--]]
Expand All @@ -743,7 +730,7 @@ function oUF:Spawn(unit, overrideName)
unit = unit:lower()

local name = overrideName or generateName(unit)
local object = CreateFrame('Button', name, PetBattleFrameHider, 'SecureUnitButtonTemplate')
local object = CreateFrame('Button', name, PetBattleFrameHider, 'SecureUnitButtonTemplate, PingableUnitFrameTemplate')
Private.UpdateUnits(object, unit)

self:DisableBlizzard(unit)
Expand All @@ -764,6 +751,8 @@ Used to create nameplates and apply the currently active style to them.
the callback are the updated nameplate, if any, the event that triggered the update, and the new unit
(function?)
* variables - list of console variable-value pairs to be set when the player logs in (table?)

PingableUnitFrameTemplate is inherited for Ping support.
--]]
function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars)
argcheck(nameplateCallback, 3, 'function', 'nil')
Expand Down Expand Up @@ -820,7 +809,7 @@ function oUF:SpawnNamePlates(namePrefix, nameplateCallback, nameplateCVars)
if(not nameplate.unitFrame) then
nameplate.style = style

nameplate.unitFrame = CreateFrame('Button', prefix..nameplate:GetName(), nameplate)
nameplate.unitFrame = CreateFrame('Button', prefix..nameplate:GetName(), nameplate, 'PingableUnitFrameTemplate')
nameplate.unitFrame:EnableMouse(false)
nameplate.unitFrame.isNamePlate = true

Expand Down