mirror of
https://github.com/brues-code/pfUI.git
synced 2026-10-31 07:56:57 +00:00
pfUI.events was a bare CallbackRegistry for pfUI's custom events. Build it from ClassicAPI's EventRegistry instead, so the same object also takes game events through RegisterFrameEventAndCallback, sharing one frame for all of them. Move the frames that existed only to listen for a few events onto it: libspell, focus, pixelperfect, innervatecall, loothistory, unusable, equipmentmanager (bank + window refresh), the actionbar grid, updatenotify, turtle-wow's steady shot, nampower's spell queue, superwow's group tracking and unitxp's notifications, plus newitem and mapreveal, which used the global EventRegistry. Handlers take their payload as arguments instead of the event/arg globals, and the per-frame PLAYER_LOGOUT teardown goes away, since the registry unregisters its frame on logout.
53 lines
2.0 KiB
Lua
53 lines
2.0 KiB
Lua
pfUI:RegisterModule("updatenotify", function ()
|
|
if pfUI.version.string == "dev" then return end
|
|
|
|
local alreadyshown
|
|
local localversion = tonumber(pfUI.version.major*10000 + pfUI.version.minor*100 + pfUI.version.fix)
|
|
local remoteversion = tonumber(pfUI_init.updateavailable) or 0
|
|
local loginchannels = { "BATTLEGROUND", "RAID", "GUILD" }
|
|
local groupchannels = { "BATTLEGROUND", "RAID" }
|
|
|
|
local ADDON_PREFIX = "pfUI-brues"
|
|
|
|
local localbranch = "main"
|
|
local versionmsg = "VERSION:" .. localversion .. ":" .. localbranch
|
|
|
|
pfUI.events:RegisterFrameEventAndCallback("CHAT_MSG_ADDON", function(_, prefix, message)
|
|
if prefix ~= ADDON_PREFIX then return end
|
|
|
|
local v, rv, branch = pfUI.api.strsplit(":", message)
|
|
rv = tonumber(rv)
|
|
-- only process VERSION messages from the same branch
|
|
-- messages without a branch tag (old versions) are ignored
|
|
if v == "VERSION" and rv and branch == localbranch then
|
|
if rv > localversion then
|
|
pfUI_init.updateavailable = rv
|
|
end
|
|
end
|
|
end)
|
|
|
|
local group = 0
|
|
pfUI.events:RegisterFrameEventAndCallback("PARTY_MEMBERS_CHANGED", function()
|
|
local groupsize = IsInRaid() and GetNumRaidMembers() or IsInGroup() and GetNumPartyMembers() or 0
|
|
if group < groupsize then
|
|
for _, chan in pairs(groupchannels) do
|
|
SendAddonMessage(ADDON_PREFIX, versionmsg, chan)
|
|
end
|
|
end
|
|
group = groupsize
|
|
end)
|
|
|
|
pfUI.events:RegisterFrameEventAndCallback("PLAYER_ENTERING_WORLD", function()
|
|
if not alreadyshown and localversion < remoteversion then
|
|
DEFAULT_CHAT_FRAME:AddMessage(string.format(T["|cff33ffccpf|rUI: New version available! Get it at %s"], GetAddOnMetadata(pfUI.name, "X-Website") .. "/releases"))
|
|
DEFAULT_CHAT_FRAME:AddMessage(T["|cffddddddIt's always safe to upgrade |cff33ffccpf|rUI. |cffddddddYou won't lose any of your configuration."])
|
|
pfUI_init.updateavailable = localversion
|
|
alreadyshown = true
|
|
end
|
|
|
|
for _, chan in pairs(loginchannels) do
|
|
SendAddonMessage(ADDON_PREFIX, versionmsg, chan)
|
|
end
|
|
end)
|
|
end)
|