Thread Tools Display Modes
09/27/16, 10:47 PM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
LibAnnoyingMessage

Hello,

I wrote a tiny project we were many to want, LibAnnoyingMessage.

To those who don't know, this library as others is intended to be pushed in few addons and will do few things.

This one simply reminds to user to update his addons.

How it works:
  • When library is enabled for the 1st time, this one is initialized.
  • X days after, it checks if there is at least 1 addon enabled and obsolete. for now X = 7d. That's the "grace period" the user will have to download his updates. They can now be pushed by devs 1 month before live release date, so you'll have at least 40d to update your code.
  • If yes, it display a message to update addons
  • After this 1st message, each Y days, the condition is re-evaluated and message is shown if needed. For now, message appears each 17 days. With an API push each 3 months, it'll pop 5+ times per API if user still don't update.

The message itself :
  • For now, it's only a Keyboard Mode dialog. It's disabled for Gamepad. It should be here for first version.
  • Dialog pops at 1st EVENT_PLAYER_ACTIVATED.
  • The picture is a random of the GamepadMode DLCs pictures.
  • If there is no market announcement shown, message is shown. Message is delayed to next EVENT_PLAYER_ACTIVATED if a market announcement is present.
  • It show a message which remind to user to update.
  • Update (or E) lead to http://www.esoui.com
  • Alt (or Esc) close the message.
  • While message is displayed, user can't move or cast or go in any other menus. He can only press Esc, Alt, E or clic on keybind (but his chat is active).


In any case, if there is still obsolete addons Y days after, the message appears again and again.
When an API Update is detected, timer reset, user have X days to update, then the reminder appears each Y days.







Experts can have a look to code, I maybe forget a bug, you'll maybe request a feature.
The lib is use functions which haven't been changed since at least 1 DLC, they're stables and it should be okay for at least 2/3 api updates

Maybe list few addons which require an update ?

The values :
  • http://www.esoui.com
    @Cairenn & Dolby : If you prefer another URL, please give me the good one (not too long if possible).

  • 7d grace: It should cover the whole majority of updates. 90% of addons are updated while this period, and if not, it'll be a good reminder (users going here, maybe forkers for too obsolete addons, etc).

  • 17d reminder loop : it's maybe too short. Discuss?

  • Text: Here my sentences are maybe incorrect. If you think you can do better, don't hesitate. I need a DE translation too.


Even if I can accept this initiative should not be released for some reasons (which ones?) If this one is done I personally would enjoy that no-one write something to avoid this, Thank you.





Lua Code:
  1. --[[
  2. Author: Ayantir
  3. Filename: LibUpdater.lua
  4. Version: 1
  5. ]]--
  6.  
  7. --[[
  8.  
  9. This software is under : CreativeCommons CC BY-NC-SA 4.0
  10. Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0)
  11.  
  12. You are free to:
  13.  
  14.     Share — copy and redistribute the material in any medium or format
  15.     Adapt — remix, transform, and build upon the material
  16.     The licensor cannot revoke these freedoms as long as you follow the license terms.
  17.  
  18.  
  19. Under the following terms:
  20.  
  21.     Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.
  22.     NonCommercial — You may not use the material for commercial purposes.
  23.     ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.
  24.     No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.
  25.  
  26.  
  27. Please read full licence at :
  28. [url]http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode[/url]
  29.  
  30. ]]--
  31.  
  32. local libLoaded
  33. local LIB_NAME, VERSION = "LibUpdater", 0.1 -- temporary. PLEASE ---------> DON'T RELEASE <--------- until it's official.
  34. local LibUpdater, oldminor = LibStub:NewLibrary(LIB_NAME, VERSION)
  35. if not LibUpdater then return end
  36.  
  37. local GRACE_PERIOD = 20 -- 600000 -- 7d
  38. local REPEAT_EVERY = 20 -- 1500000 -- 17d
  39.  
  40. local UPDATE_WEBSITE = "http://www.esoui.com"
  41.  
  42. local SV_HOST = ZO_Ingame_SavedVariables
  43. local wm = WINDOW_MANAGER
  44. local lang = {}
  45.  
  46. local function GetLangStrings(language)
  47.  
  48.     if language == "de" then
  49.         return {
  50.             TITLE = "Obsolete Addons",
  51.             DESC = "Thank you for using Elder Scrolls Online Addons\nIt looks like that some of them are now obsolete\n\nDon't forget to update !",
  52.             NOW = "Update",
  53.             LATER = "Later",
  54.         }
  55.     elseif language == "fr" then
  56.         return {
  57.             TITLE = "Extensions obsolètes",
  58.             DESC = "Merci d'utiliser les extensions d'Elder Scrolls Online\nIl apparait que certaines d'entre elles soient obsolètes\n\nN'oubliez pas de les mettre à jour !",
  59.             NOW = "Mettre à Jour",
  60.             LATER = "Plus tard",
  61.         }
  62.     else
  63.         return {
  64.             TITLE = "Obsolete Addons",
  65.             DESC = "Thank you for using Elder Scrolls Online Addons\nIt looks like that some of them are now obsolete\n\nDon't forget to update !",
  66.             NOW = "Update",
  67.             LATER = "Later",
  68.         }
  69.     end
  70.  
  71. end
  72.  
  73. local function GetDLCTextures()
  74.    
  75.     local picts = {}
  76.     for dlcIndex = 1 , GetTotalCollectiblesByCategoryType(COLLECTIBLE_CATEGORY_TYPE_DLC) do
  77.         local collectibleId = GetCollectibleIdFromType(COLLECTIBLE_CATEGORY_TYPE_DLC, dlcIndex)
  78.         local pict = GetCollectibleGamepadBackgroundImage(collectibleId)
  79.         table.insert(picts, pict)
  80.     end
  81.    
  82.     return picts
  83.    
  84. end
  85.  
  86. local function PushDialog()
  87.     PushActionLayerByName(GetString(SI_KEYBINDINGS_LAYER_DIALOG))
  88. end
  89.  
  90. local function ReleaseDialog()
  91.     ZO_Dialogs_ReleaseDialog("LIBUPDATE", true)
  92.     RemoveActionLayerByName(GetString(SI_KEYBINDINGS_LAYER_DIALOG))
  93. end
  94.  
  95. local function CloseAnnouncement()
  96.     ReleaseDialog()
  97.     if IsGameCameraUIModeActive() then
  98.         SetGameCameraUIMode(false)
  99.     end
  100. end
  101.  
  102. local function GoOnUpdateWebsite()
  103.     RequestOpenUnsafeURL(UPDATE_WEBSITE)
  104. end
  105.  
  106. local function DrawKeyboardUI(tlw)
  107.  
  108.     local textures = GetDLCTextures()
  109.  
  110.     local container = wm:CreateControl("$(parent)Container", tlw, CT_CONTROL)
  111.     container:SetAnchor(RIGHT, nil, RIGHT, -80, 0)
  112.     container:SetDimensions(600, 725)
  113.    
  114.         local background = CreateControlFromVirtual("$(parent)BG", container, "ZO_DefaultBackdrop")
  115.        
  116.         local title = wm:CreateControl("$(parent)Title", container, CT_LABEL)
  117.         title:SetAnchor(TOP, nil, TOP, 0, 15)
  118.         title:SetFont("ZoFontWinH1")
  119.         title:SetModifyTextType(MODIFY_TEXT_TYPE_UPPERCASE)
  120.         title:SetText(lang.TITLE)
  121.        
  122.         local divider = CreateControlFromVirtual("$(parent)Divider", container, "ZO_Options_Divider")
  123.         divider:SetAnchor(TOP, nil, TOP, 0, 50)
  124.        
  125.         local pict = wm:CreateControl("$(parent)Pict", container, CT_TEXTURE)
  126.         pict:SetAnchor(TOP, nil, TOP, 0, 65)
  127.         pict:SetDimensions(575, 550)
  128.         pict:SetTexture(textures[zo_random(1, #textures)])
  129.         pict:SetTextureCoords(0, 407 / 512, 0, 1)
  130.        
  131.         local description = wm:CreateControl("$(parent)Description", container, CT_LABEL)
  132.         description:SetAnchor(BOTTOMLEFT, nil, BOTTOMLEFT, 20, -55)
  133.         description:SetFont("ZoFontGameLargeBold")
  134.         description:SetColor(ZO_NORMAL_TEXT:UnpackRGBA())
  135.         description:SetText(lang.DESC)
  136.        
  137.         local keybinds = wm:CreateControl("$(parent)Keybinds", container, CT_CONTROL)
  138.         keybinds:SetAnchor(BOTTOMRIGHT, nil, BOTTOMRIGHT, -10, -10)
  139.        
  140.             local updatenow = CreateControlFromVirtual("$(parent)UpdateNow", keybinds, "ZO_KeybindButton")
  141.             updatenow:SetAnchor(BOTTOMRIGHT, nil, BOTTOMRIGHT, 0, 0)
  142.             updatenow:SetKeybind("DIALOG_PRIMARY")
  143.             updatenow:SetCallback(GoOnUpdateWebsite)
  144.            
  145.                 local updatenowlbl = GetControl(updatenow, "NameLabel")
  146.                 updatenowlbl:SetText(lang.NOW)
  147.  
  148.             local updatelater = CreateControlFromVirtual("$(parent)UpdateLater", keybinds, "ZO_KeybindButton")
  149.             updatelater:SetAnchor(RIGHT, updatenow, LEFT, -10, 0)
  150.             updatelater:SetKeybind("DIALOG_NEGATIVE")
  151.             updatelater:SetCallback(CloseAnnouncement)
  152.        
  153.                 local updatelaterlbl = GetControl(updatelater, "NameLabel")
  154.                 updatelaterlbl:SetText(lang.LATER)
  155.            
  156. end
  157.  
  158. local function DrawGamepadUI(tlw)
  159.  
  160. end
  161.  
  162. local function InitializeAnnouncement()
  163.  
  164.     local tlw = wm:CreateTopLevelWindow("LibUpdate")
  165.     tlw:SetDrawLayer(DL_OVERLAY)
  166.     tlw:SetDrawTier(DT_HIGH)
  167.     tlw:SetAnchorFill()
  168.     tlw:SetHidden(true)
  169.    
  170.     tlw:SetHandler("OnEffectivelyShown", PushDialog)
  171.     tlw:SetHandler("OnEffectivelyHidden", ReleaseDialog)
  172.    
  173.     lang = GetLangStrings(GetCVar("Language.2"))
  174.    
  175.     if IsInGamepadPreferredMode() then
  176.         DrawGamepadUI(tlw)
  177.     else
  178.         DrawKeyboardUI(tlw)
  179.        
  180.         ZO_Dialogs_RegisterCustomDialog("LIBUPDATE", -- temporary here. should be after the block
  181.         {
  182.             customControl = tlw,
  183.             title =
  184.             {
  185.                 text = lang.TITLE,
  186.             },
  187.             buttons =
  188.             {
  189.                 {
  190.                     control = GetControl(tlw, "ContainerKeybindsUpdateNow"),
  191.                     text = lang.NOW,
  192.                     keybind = "DIALOG_PRIMARY",
  193.                     callback = GoOnUpdateWebsite,
  194.                 },  
  195.                 {
  196.                     control = GetControl(tlw, "ContainerKeybindsUpdateLater"),
  197.                     text = lang.LATER,
  198.                     keybind = "DIALOG_NEGATIVE",
  199.                     callback = CloseAnnouncement,
  200.                 },
  201.             }
  202.         })
  203.        
  204.     end
  205.    
  206. end
  207.  
  208. local function ShowAnnouncement()
  209.     if not IsInGamepadPreferredMode() then -- temporary
  210.         ZO_Dialogs_ShowDialog("LIBUPDATE")
  211.     end
  212. end
  213.  
  214. function HaveOutdatedAddons()
  215.    
  216.     local AddOnManager = GetAddOnManager()
  217.     local haveOutdatedAddons
  218.    
  219.     for addonIndex = 1, AddOnManager:GetNumAddOns() do
  220.         local name, _, _, _, enabled, state, isOutOfDate = AddOnManager:GetAddOnInfo(addonIndex)
  221.         haveOutdatedAddons = enabled and isOutOfDate and state == ADDON_STATE_ENABLED or false -- addons can be enabled and state ~= ADDON_STATE_ENABLED
  222.         if haveOutdatedAddons then
  223.             return haveOutdatedAddons
  224.         end
  225.     end
  226.    
  227.     return haveOutdatedAddons
  228.    
  229. end
  230.  
  231. local function OnPlayerActivated()
  232.     if SCENE_MANAGER:GetCurrentScene():GetName() ~= "marketAnnouncement" then
  233.         EVENT_MANAGER:UnregisterForEvent(LIB_NAME, EVENT_PLAYER_ACTIVATED)
  234.         ShowAnnouncement()
  235.     end
  236. end
  237.  
  238. function LibUpdater:Init()
  239.    
  240.     local apiVersion = GetAPIVersion()
  241.     local now = GetTimeStamp()
  242.     if GetWorldName() ~= "PTS" then
  243.         if not SV_HOST.LibUpdater or apiVersion > SV_HOST.LibUpdater.a then
  244.             SV_HOST.LibUpdater = { t = now, a = apiVersion, d = false } -- time, api, displayed
  245.         elseif HaveOutdatedAddons() then
  246.             local remindPeriod = GRACE_PERIOD
  247.             if SV_HOST.LibUpdater.d then
  248.                 remindPeriod = REPEAT_EVERY
  249.             end
  250.             if now > SV_HOST.LibUpdater.t + remindPeriod then
  251.                 SV_HOST.LibUpdater.t = now
  252.                 SV_HOST.LibUpdater.d = true
  253.                 InitializeAnnouncement()
  254.                 EVENT_MANAGER:RegisterForEvent(LIB_NAME, EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
  255.             end
  256.         end
  257.     end
  258.    
  259. end
  260.  
  261. local function OnAddonLoaded()
  262.     if not libLoaded then
  263.         libLoaded = true
  264.         local LU = LibStub('LibUpdater')
  265.         LU:Init()
  266.         EVENT_MANAGER:UnregisterForEvent(LIB_NAME, EVENT_ADD_ON_LOADED)
  267.     end
  268. end
  269.  
  270. EVENT_MANAGER:RegisterForEvent(LIB_NAME, EVENT_ADD_ON_LOADED, OnAddonLoaded)

Last edited by Ayantir : 09/27/16 at 10:50 PM.
  Reply With Quote
09/30/16, 04:49 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
I like the idea and as the popup won't show very often (or not at all if users keep their addons updated and addon devs are able to do the same ) I guess the users won't complain.

German translation:

Lua Code:
  1. if language == "de" then
  2.         return {
  3.             TITLE = "Veraltete Addons",
  4.             DESC = "Vielen Dank für die Nutzung von Elder Scrolls Online Addons\nEinige deiner Addons scheinen jedoch inzwischen veraltet zu sein\n\nVergiss nicht diese zu aktualisieren!",
  5.             NOW = "Aktualisieren",
  6.             LATER = "Später",
  7.         }

If the button text "Aktualisieren" is too long then just use "Update" as well.
  Reply With Quote
09/30/16, 05:39 AM   #3
Biki
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 34
Nice idea, but I would change "obsolete", which usually means "no longer needed" to "outdated", since that's more fitting.
  Reply With Quote
09/30/16, 06:10 AM   #4
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,913
Yep, that is why I've translated it with "Veraltet" which means "outdated".
  Reply With Quote
09/30/16, 03:45 PM   #5
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Votan and Manavortex provided me a German translation meanwhile.
And I'm agree that Obsolete is not a good word.. and I forget to change it in the title
I'll change it for version 2 of the lib (should come before the 1 displays something).
  Reply With Quote
01/26/18, 03:17 PM   #6
tomtomhotep
 
tomtomhotep's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 21
So YOU'RE the one!

I freeek'n hate this pop up. How do i disable it from ever popping up again ever.

I have "outdated" addons that are no longer being maintained, but still work perfectly for me.

I do not want to see this pop up any more forever!
  Reply With Quote
01/26/18, 03:23 PM   #7
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
http://www.esoui.com/downloads/info1...Reminders.html
  Reply With Quote
01/26/18, 03:31 PM   #8
tomtomhotep
 
tomtomhotep's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2015
Posts: 21
Thanks.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » LibAnnoyingMessage

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off