WoW LibNotify-1.0 addon Dragonflight/Wrath of the Lich King Classic 2024
logo
wow addon LibNotify-1.0

LibNotify-1.0

Game Version: 9.0.1
Total Downloads: 1,018
Updated: Oct 15, 2020
Created: Jan 24, 2017
download LibNotify-1.0Download Earlier Versions

Earlier Versions

Name Size Uploaded Game Version Downloads
1.0.3 release 5.93 KB Oct 15, 2020 9.0.1 0 download LibNotify-1.0 1.0.3 releaseDownload
1.0.2 release 6.00 KB Feb 12, 2017 7.1.5 648 download LibNotify-1.0 1.0.2 releaseDownload
1.0.1 release 4.99 KB Jan 25, 2017 7.1.5 114 download LibNotify-1.0 1.0.1 releaseDownload
1.0.1 release 4.99 KB Jan 25, 2017 7.1.5 34 download LibNotify-1.0 1.0.1 releaseDownload
1.0.0 release 5.04 KB Jan 25, 2017 7.0.3 34 download LibNotify-1.0 1.0.0 releaseDownload
1.0.0 release 5.04 KB Jan 25, 2017 7.0.3 44 download LibNotify-1.0 1.0.0 releaseDownload
r13-alpha alpha 5.93 KB Oct 15, 2020 9.0.1 0 download LibNotify-1.0 r13-alpha alphaDownload
r12-alpha alpha 5.90 KB Oct 15, 2020 7.1.5 0 download LibNotify-1.0 r12-alpha alphaDownload
r11-alpha alpha 5.63 KB Oct 15, 2020 7.1.5 0 download LibNotify-1.0 r11-alpha alphaDownload
r9-alpha alpha 6.00 KB Feb 12, 2017 7.1.5 48 download LibNotify-1.0 r9-alpha alphaDownload
r6-alpha alpha 4.74 KB Jan 25, 2017 7.1.5 32 download LibNotify-1.0 r6-alpha alphaDownload
r4-alpha alpha 4.74 KB Jan 25, 2017 7.1.5 30 download LibNotify-1.0 r4-alpha alphaDownload
r4-alpha alpha 5.04 KB Jan 24, 2017 7.0.3 34 download LibNotify-1.0 r4-alpha alphaDownload

Description

Share this:

This library provides a simple way to show somewhat tolerable notifications. The library also provides a way to remember if the user has already seen a notification. Typical use cases:

 

Version checks - instead of spamming the chat window, pop a notification with "NotifyOnce", supplying your new version number as ID. If the user has seen the version notification before, it will be ignored.

 

Addon changelog – you can supply a table of notifications, one for each addon update you wish to inform the user about. Again, use "NotifyOnce" to only show it once. Each item in the table you supply is checked individually.

 

Other – spam away. The user will only ever see one notification at once.

 

API

self:Notify(title, message/function, icon) or self:Notify(table)

Queues a notification or a list of notifications to be shown. If supplying a table, the same keys should be supplied for each item. Message and icon can both be omitted.

If the title is too long for the notification window, it will be truncated.

The message can be HTML formatted, but note that WoW's HTML parser is very limited.

A function can be supplied instead of a message. The function will be executed when the user clicks on the notification.

 

self:NotifyOnce(title, message, icon, id) or self:Notify(table)

Queues a notification or a list of notifications to be shown.

 

The "id" parameter is used to identify notifications. If omitted, the title is used.

 

The storage must have been set first with SetNotifyStorage.

 

self:SetNotifyIcon(icon_path)

Sets the default icon to be used.

 

self:SetNotifyStorage(table)
Sets the storage to be used for saving which of your addon's notifications have been seen by the user. This would typically be somewhere in your user's saved variables. Technically you can of course also use a non-persistant storage if you wish for these notifications to possibly be shown in another playing session.

 

Examples

Basic usage

The library can be used standalone or embedded in an Ace3 addon.

 

Embedded example:

local addon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "LibNotify-1.0")
addon:Notify("Hello world!")

Standalone example:

local libnotify = LibStub("LibNotify-1.0")
libnotify.Notify(myaddon, "Hello world!")

Addon changelog

local addon = LibStub("AceAddon-3.0"):NewAddon("MyAddon", "LibNotify-1.0")
local seen_versions = {} -- This would probably point to your user's active profile
local versions = {
   {
     title = "MyAddon 1.1",
     message = "Added more stuff! Also, crackers.<br/>Fixed previous stuff."
   },
   {
     title = "MyAddon 1.0",
     message = "Added a lot of stuff."
   }
}
addon:SetNotifyIcon("Interface\\Icons\\Spell_Lightning_LightningBolt01")
addon:SetNotifyStorage(seen_versions)
addon:NotifyOnce(versions)

 

New version notification

-- find out the new version number by way of addon communication channel
-- and then notify user
local version = "1.0.0"
addon:NotifyOnce("MyAddon version " + version + " available!", "Be sure to check out the newest version, which has extra features and cats. Meow!", nil,version)

One-off notification

addon:Notify("Smurf alert!", "The smurfs are coming, lock your doors!", "Some fancy icon")

Locale support

This is out of the library's scope. You can simply pass in notification tables/parameters based on the user's locale. The library currently has one line of text by itself, the instructions in the notification frame, which is translated for most locales.

Comments

Add a comment