From 69e9bdce8b43ba48899156575100f90a3ec65d12 Mon Sep 17 00:00:00 2001 From: shagu Date: Thu, 21 Dec 2017 15:41:46 +0100 Subject: [PATCH] updatenotify: add update notification --- modules/updatenotify.lua | 33 +++++++++++++++++++++++++++++++++ pfUI.toc | 1 + 2 files changed, 34 insertions(+) create mode 100644 modules/updatenotify.lua diff --git a/modules/updatenotify.lua b/modules/updatenotify.lua new file mode 100644 index 00000000..0061d98d --- /dev/null +++ b/modules/updatenotify.lua @@ -0,0 +1,33 @@ +pfUI:RegisterModule("updatenotify", function () + local alreadyshown = false + local localversion = tonumber(pfUI.version.major*10000 + pfUI.version.minor*100 + pfUI.version.fix) + local remoteversion = tonumber(pfUI_init.updateavailable) or 0 + + pfUI.updater = CreateFrame("Frame") + pfUI.updater:RegisterEvent("CHAT_MSG_ADDON") + pfUI.updater:RegisterEvent("PLAYER_ENTERING_WORLD") + pfUI.updater:SetScript("OnEvent", function() + if event == "CHAT_MSG_ADDON" and arg1 == "pfUI" then + local v, remoteversion = pfUI.api.strsplit(":", arg2) + local remoteversion = tonumber(remoteversion) + if v == "VERSION" and remoteversion then + if remoteversion > localversion then + pfUI_init.updateavailable = remoteversion + end + end + end + + if event == "PLAYER_ENTERING_WORLD" then + if not alreadyshown and localversion < remoteversion then + DEFAULT_CHAT_FRAME:AddMessage(T["|cff33ffccpf|rUI: New version available! Have a look at http://shagu.org !"]) + 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({ "BATTLEGROUND", "RAID", "GUILD" }) do + SendAddonMessage("pfUI", "VERSION:" .. localversion, chan) + end + end + end) +end) diff --git a/pfUI.toc b/pfUI.toc index 1b854315..970f4a25 100644 --- a/pfUI.toc +++ b/pfUI.toc @@ -44,6 +44,7 @@ modules\firstrun.lua modules\gui.lua modules\unlock.lua modules\hoverbind.lua +modules\updatenotify.lua modules\actionbar.lua modules\hunterbar.lua modules\rangecheck.lua