Download
(5 Kb)
Download
Updated: 10/29/23 01:07 PM
Pictures
File Info
Compatibility:
Endless Archive (9.2.5)
base-game patch (9.1.5)
Updated:10/29/23 01:07 PM
Created:11/03/15 08:20 PM
Monthly downloads:17,164
Total downloads:1,004,813
Favorites:670
MD5:
Circonians LibNotifications  Popular! (More than 5000 hits)
Version: 1.0.11
by: sirinsidiator [More]
Who is it for?
Developers.
What does it do?
Allows you to add messages to the games notification area.

How do I use it?
Register the library in your code file:
Lua Code:
  1. local libNotification = LibNotification

After your addon is initialized call the libraries CreateProvider() function.
Lua Code:
  1. local provider = libNotification:CreateProvider()

The provider will have a notifications table. This is where you put your messages.
Lua Code:
  1. provider.notifications
How do I create a Message?

Messages need to be written in a certain format, the following is an example:
Warning: Spoiler


Create your messages and add them to your provider notifications table:
Lua Code:
  1. table.insert(provider.notifications, msg)
It is up to you to add & remove your messages from the notifications table when you are done with them.
WARNING:
The table must be numerically indexed & there can be no missing indices. I recommend using table.insert() & table.remove() for adding/removing messages

After you are done making changes Adding/Removing messages, call the update function:
Lua Code:
  1. provider:UpdateNotifications()
Try not to call this anymore than necessary.
It fires off ALL of the BuildNotificationList functions for every notification provider in the game!

Other Information
Just In case anyone needs to know for creating/selecting icons. The icon on the keyboard rowControl is 32 x 32.
The code can be found on github: https://github.com/sirinsidiator/ESO-LibNotification.
1.0.11--

- removed LibStub support
- switched to semantic versioning
- updated for Secret of the Telvanni
r10--

- fixed incorrect string id for gamepad notification header (Thanks ZOSDanBatson!)
- updated for Markarth
r9--

- added LICENSE and put the code on github
r8--

- updated for Harrowstorm and Greymoor
- added a second global variable "LibNotification" to match the ingame addon name
r7--

- updated for Dragonhold
- made LibStub dependency optional (it's now recommended to use the LibNotifications global variable to access it)
- fixed typo in "keyboardDeclineCallback" (was "keybaordDeclineCallback" before. The incorrect spelling still works, but I recommend you fix it in your addons!)
- added IsLibrary flag to manifest
r6--

- updated for Murkmire
- switched to standalone package structure (developers: make sure you remove it from the manifest and change to DependsOn!)
- permanently fixed the errors that occur when ZOS adds new notification types (thanks Chip for making these tables global!)
r5--

- updated for Summerset
r4--

- updated for Morrowind
r3--

- updated for Homestead
r2--

- updated for Dark Brotherhood
- gamepad support seems to be broken and will be updated in a future version
Version 1.2--

Gamepad Support Added

WARNING: In order to add support for notifications in gamepad mode the entire library was rewritten. There have been some changes to the required structure of the message table. Please read the new instructions for creating a message table on the addons main page.

WARNING: To avoid errors if you wish to store extra data with your message store all of your custom data in a data table inside the message table. Read the new instructions for creating a message table on the addons main page.
Archived Files (12)
File Name
Version
Size
Uploader
Date
10
5kB
sirinsidiator
12/23/20 10:47 AM
9
5kB
sirinsidiator
05/28/20 03:16 PM
8
2kB
sirinsidiator
04/24/20 03:16 PM
7
2kB
sirinsidiator
09/29/19 02:43 PM
6
2kB
sirinsidiator
09/22/18 12:28 PM
5
4kB
sirinsidiator
05/21/18 02:39 AM
4
4kB
sirinsidiator
05/23/17 02:25 AM
3
4kB
sirinsidiator
02/14/17 11:15 AM
2
4kB
sirinsidiator
06/11/16 01:58 AM
1.2
2kB
circonian
11/06/15 09:17 PM
1.1
1kB
circonian
11/04/15 07:39 PM
1.0
1kB
circonian
11/03/15 08:20 PM


Post A Reply Comment Options
Unread 11/04/15, 02:49 AM  
CaptainBlagbird
 
CaptainBlagbird's Avatar
AddOn Author - Click to view AddOns

Forum posts: 53
File comments: 177
Uploads: 23
Minor issue

Ok, here's a minor bug/imperfection I found so far :
When there is no acceptCallback or declineCallback function defined it correctly hides the relative button, but the keybind options are still displayed and working.

Edit: data.index on line 17 seems to be nil always. Is that code junk from a previous version or something that is necessary for specific cases? I thought I could use it in the callback functions to remove the correct notification.

Edit 2: Here's (probably) the first add-on using this library: Friend Removed Notification
Last edited by CaptainBlagbird : 11/04/15 at 05:10 PM.
Report comment to moderator  
Reply With Quote
Unread 11/04/15, 05:13 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Re: Minor issue

Originally Posted by CaptainBlagbird
Ok, here's a minor bug/imperfection I found so far :
When there is no acceptCallback or declineCallback function defined it correctly hides the relative button, but the keybind options are still displayed and working.

Edit: data.index on line 17 seems to be nil always. Is that code junk from a previous version or something that is necessary for specific cases? I thought I could use it in the callback functions to remove the correct notification.
ah I didn't think of the keybinds. Its an easy fix.

As for the other though, that's a very good question. It comes from the game code and I have absolutely no idea why its there so I left it in there.

When a row control is created it sets control.index to the data's visibleDataIndex. But, in the notification code data there is no data.index, so this always nils out the control.index. Why they would want to do that I do not know and in my opinion it looks like a bug. Although I can change it so you can use the key index in your data table.

One thing I noticed that I forgot to post though is that you can not use the keys sortIndex or provider in your message table. sortIndex is used by the ZO_SortFilterList which places the key sortIndex into (a copy of) your data table for sorting purposes. The table key provider is used by the notification manager so that when working with the row controls it knows which provider the control came from so it can release the control properly when its done with it.
Last edited by circonian : 11/04/15 at 08:34 PM.
Report comment to moderator  
Reply With Quote
Unread 11/04/15, 07:53 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Re: Minor issue

Originally Posted by CaptainBlagbird
Edit 2: Here's (probably) the first add-on using this library: Friend Removed Notification
Nice !
Report comment to moderator  
Reply With Quote
Unread 11/05/15, 01:53 AM  
CaptainBlagbird
 
CaptainBlagbird's Avatar
AddOn Author - Click to view AddOns

Forum posts: 53
File comments: 177
Uploads: 23
Re: Re: Minor issue

Originally Posted by circonian
Although I can change it so you can use the key index in your data table.
I made an "own" key notificationId that reflects the index of the provider.notifications for easier removal of the element (every time I remove an element from that table, I update notificationId with the new index for all elements that followed the removed element). I do this because that way I'm sure the order stays intact. I noticed that the visual order of the notifications isn't the same order they were added. Also the controls seems to be in yet an other order.

Example with 5 notifications (1=first added notification, 5=last):
Visual order: 3 4 1 2 5 (top to bottom)
Order of the controls (ZO_NotificationsList347Row*): 3 1 4 2 5 (top to bottom)

Example with 2 notifications (1=first added notification, 2=second):
Visual order: 1 2 (top to bottom)
Order of the controls (ZO_NotificationsList347Row*): 1 3 (top to bottom)

I don't know if Zenimax does this for a reason, or if they have a bug in their code..

Originally Posted by circonian
ah I didn't think of the keybinds. Its an easy fix.
Can you please also change the tooltip/keybind text of the decline button to SI_NOTIFICATIONS_DELETE when only this button is used (as it is when using the dataType NOTIFICATION_ALERT_DATA). Or maybe you want to add other keys to the table (or maybe another argument of the callback function?) to get/set custom tooltips.

EDIT

Noticed another bug:
When there are already custom notifications pending and an official notification is added (only tested with guild MotD), then the number near the icon in the chat window is reset to 1 (or probably as many official notifications as added). When a new custom one then is added the number is again displayed correctly. But on removing an official notification, it is again wrongly 0. Also when there are both custom and official notifications (only tested with guild MotD) and any notification is removed, the notification-added-sound is played (probably because the notifications are added again in BuildNotificationList())
Last edited by CaptainBlagbird : 11/05/15 at 04:12 AM.
Report comment to moderator  
Reply With Quote
Unread 11/05/15, 02:36 AM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4912
File comments: 5988
Uploads: 78
This is awesome! Thanks circonian and all the others who tested and invented the idea (@CaptainBlagbird e.g.).

It will help to keep messages clear in the notification area without spamming the game too much with onscreen messages (in some cases like friends addons, guild addons, etc.).
Especially the callback functions will help to "show the error place/react on the particular case directly" and I like this a lot as you could "collect some messages" and work on them later on (after you finished your current dungeon e.g.).

I'll try it out, thanks again.
Last edited by Baertram : 11/05/15 at 02:36 AM.
Report comment to moderator  
Reply With Quote
Unread 11/05/15, 04:06 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Re: Re: Re: Minor issue

Originally Posted by CaptainBlagbird
Example with 5 notifications (1=first added notification, 5=last):
Visual order: 3 4 1 2 5 (top to bottom)
Order of the controls (ZO_NotificationsList347Row*): 3 1 4 2 5 (top to bottom)

Example with 2 notifications (1=first added notification, 2=second):
Visual order: 1 2 (top to bottom)
Order of the controls (ZO_NotificationsList347Row*): 1 3 (top to bottom)

I don't know if Zenimax does this for a reason, or if they have a bug in their code.
No, its my fault. There is a sortKey I left out of the instructions. The sortIndex, that I mentioned, that is added to the table is the order they get sorted in, but it sorts the table by the key secsSinceRequest. You can use (but read the new instructions I posted under creating a message, this keyName is misleading !!) :
Lua Code:
  1. secsSinceRequest = ZO_NormalizeSecondsSince(0),
In your msg table and they will be ordered as the most recent messages on top.
However, if you add more than one message at the same time the precision is not great enough to keep them in the proper sort order, so keep that in mind.

As for the control number, you can never count on (know) what that number will be. The controls come from a virtual control pool. When a row control is needed it checks the pool. If a free control exists it grabs it, if not it creates a new one. When your done with a control it gets released back into the pool. When a new one is needed it grabs one from the free pool (or creates another if there is no free control), exc...exc.... For this reason the order/number of the controls that you will get is not possible to determine. The number for the control you will get is based off of whichever controls are free. This way the game does not have to keep creating new controls for every single notification. The game does the same with a lot of controls.
WARNING:
This also means DO NOT modify any part of the row control object or save anything to it (like rowControl.xxxx). If you do those changes will remain every time that control is reused and it will mess up everyone elses notifications.
If you have some reason for wanting a custom row control let me know & I can add the ability for you to create & use your own custom row controls.



Originally Posted by CaptainBlagbird
Can you please also change the tooltip/keybind text of the decline button to SI_NOTIFICATIONS_DELETE when only this button is used (as it is when using the dataType NOTIFICATION_ALERT_DATA). Or maybe you want to add other keys to the table (or maybe another argument of the callback function?) to get/set custom tooltips.
I will leave it as it is (for default text), but I will add a some keys to the table for the accept & decline buttons to allow you to set custom text. If you want to use localized text you will have to handle the localization of the string before it is set in the table. That way if the addon doesn't handle localization they can just set it as any string.


Originally Posted by CaptainBlagbird
Noticed another bug:
When there are already custom notifications pending and an official notification is added (only tested with guild MotD), then the number near the icon in the chat window is reset to 1 (or probably as many official notifications as added). When a new custom one then is added the number is again displayed correctly. But on removing an official notification, it is again wrongly 0. Also when there are both custom and official notifications (only tested with guild MotD) and any notification is removed, the notification-added-sound is played (probably because the notifications are added again in BuildNotificationList())
These sound like they are related. That sound is played by the CHAT_SYSTEM only if the total number of notifications increases. It sounds like its getting reset to 0 and then when it find the old notifications that are really there (just not counted) the count increases, so it plays the sound when the count increases.

That count code is handled by the games notification manager, I don't see anything wrong with the zos code. Hopefully, if I'm lucky, I can find someone to send me notifications later when I get home & I'll see if I can't figure out whats causing it.
Last edited by circonian : 11/05/15 at 04:28 PM.
Report comment to moderator  
Reply With Quote
Unread 11/05/15, 11:53 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Re: Re: Re: Minor issue

Originally Posted by CaptainBlagbird
Noticed another bug:
When there are already custom notifications pending and an official notification is added (only tested with guild MotD), then the number near the icon in the chat window is reset to 1 (or probably as many official notifications as added). When a new custom one then is added the number is again displayed correctly. But on removing an official notification, it is again wrongly 0. Also when there are both custom and official notifications (only tested with guild MotD) and any notification is removed, the notification-added-sound is played (probably because the notifications are added again in BuildNotificationList())
Well I found the problem. The problem is there are three different notification managers. One is a common notification manager, one is a keyboard notification manager, & one is a gamepad notification manager.

The BuildNotificationList is getting run for both the keyboard & gamepad notification managers, which I did not expect. I expected only the manager for the mode you were in (keyboard/gamepad) would run, but it doesn't work that way. The keyboard one runs first, but then the gamepad one runs, which LibNotifications does not have a provider for, so that 0's the count back out because the messages do not exist in the gamepad notification manager.

That seems like a bug to me. I don't know why they would run the BuildNotificationList() for both managers, it should only run for the mode your in. Not to mention the way its calculating & setting the notification count, twice, using different sets of providers. I guess they just assumed all notifications would always exist in both managers.

It looks like I'm going to have to build a notification provider for the gamepad and find a way to manage both of them at the same time so addons don't have to handle both of the providers. That might take a while. It will have to wait until tomorrow night when I get home from work.
Last edited by circonian : 11/05/15 at 11:56 PM.
Report comment to moderator  
Reply With Quote
Unread 11/06/15, 06:29 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
WARNING:
I know this was just released, but due to some requests, some problems, & to enable the ability to add notifications for gamepad mode as well there will be an update soon that will require some very minor changes on the part of any addon using this library. Since there is little work required for your addon to use the library it wont be a big deal, but since I know it is coming I thought I would make a post warning you about it. The next update (coming soon: tonight/tomorrow as soon as I finish rewriting it & test it) will very likely change the required structure of the message table.
Last edited by circonian : 11/06/15 at 06:29 PM.
Report comment to moderator  
Reply With Quote
Unread 11/06/15, 09:30 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Added support for gamepad notifications. Notifications will now show up in both keyboard & gamepad mode.

You don't have to do anything extra for gamepad notifications, the library handles both the keyboard & gamepad providers for you. BUT, the message table has changed slightly. The message table changes were done for gamepad support, to allow the use of different types of row controls, & to prevent future problems.
Please read the NEW instructions I posted on how to create a message table on the main page.
If you have any questions or problems just let me know.

Posted Version 1.2
Last edited by circonian : 11/06/15 at 09:41 PM.
Report comment to moderator  
Reply With Quote
Unread 11/06/15, 09:46 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Originally Posted by Baertram
This is awesome! Thanks circonian and all the others who tested and invented the idea (@CaptainBlagbird e.g.).

It will help to keep messages clear in the notification area without spamming the game too much with onscreen messages (in some cases like friends addons, guild addons, etc.).
Especially the callback functions will help to "show the error place/react on the particular case directly" and I like this a lot as you could "collect some messages" and work on them later on (after you finished your current dungeon e.g.).

I'll try it out, thanks again.
Errors...While writing code (or for users) it could be used for debugging messages, that is an awesome idea !!!
Report comment to moderator  
Reply With Quote
Unread 11/07/15, 03:12 PM  
CaptainBlagbird
 
CaptainBlagbird's Avatar
AddOn Author - Click to view AddOns

Forum posts: 53
File comments: 177
Uploads: 23
Originally Posted by circonian
Added support for gamepad notifications. Notifications will now show up in both keyboard & gamepad mode.
Awesome thanks
I've updated my add-on with the new library version.

Originally Posted by circonian
The BuildNotificationList is getting run for both the keyboard & gamepad notification managers, which I did not expect.
Originally Posted by circonian
That seems like a bug to me. I don't know why they would run the BuildNotificationList() for both managers, it should only run for the mode your in.
Yeah that's strange.. I wonder why there are two managers anyway. Sure, sometimes it might be necessary to do something different in one case, but this could also be done with GetCVar("GamepadPreferredEnabled") (I don't know about all the stuff that happens in the background though, they probably call the functions directly from C++ or whatever the base language is).
Last edited by CaptainBlagbird : 11/07/15 at 03:14 PM.
Report comment to moderator  
Reply With Quote
Unread 11/07/15, 03:39 PM  
CaptainBlagbird
 
CaptainBlagbird's Avatar
AddOn Author - Click to view AddOns

Forum posts: 53
File comments: 177
Uploads: 23
I'm still a little bit confused about the order. I'm using secsSinceRequest as recommended, I don't use sortKey or sortIndex as they are only for internal sorting, right?
I noticed the list getting unsorted while there is a MotD pending: imgur album
I see that ZO_GuildMotDProvider is the only official provider that doesn't use secsSinceRequest so I guess that's the reason. But I haven't tested with other official notifications yet. I don't care much about the list not being sorted correctly, but I wanted to point it out to you.
Last edited by CaptainBlagbird : 11/07/15 at 03:42 PM.
Report comment to moderator  
Reply With Quote
Unread 11/07/15, 04:02 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Originally Posted by CaptainBlagbird
Originally Posted by circonian
Added support for gamepad notifications. Notifications will now show up in both keyboard & gamepad mode.
Awesome thanks
I've updated my add-on with the new library version.

Originally Posted by circonian
The BuildNotificationList is getting run for both the keyboard & gamepad notification managers, which I did not expect.
Originally Posted by circonian
That seems like a bug to me. I don't know why they would run the BuildNotificationList() for both managers, it should only run for the mode your in.
Yeah that's strange.. I wonder why there are two managers anyway. Sure, sometimes it might be necessary to do something different in one case, but this could also be done with GetCVar("GamepadPreferredEnabled") (I don't know about all the stuff that happens in the background though, they probably call the functions directly from C++ or whatever the base language is).
The reason there are separate keyboard/gamepad managers is because some notifications have popup context menus when you click on a button like Friend/Guild invite. When you click decline a popup appears that gives you choices: Decline, spam, report player exc... Popups are handled differently in gamepad mode than they are in keyboard mode so they require different code in the accept/decline callbacks. Also the gamepad notifications window is built differently than the keyboard mode & requires completely different templates. Having separate managers for each simplifies the selection process when determining what type of row control, icon, exc.. to use.

You are correct that they could have just checked if they were in gamepad mode & handled it all in a single accept/decline callback, but I guess they didn't want to have to do that so they created separate providers so that keyboard/gamepad mode would have unique callbacks. Which is also why I followed suit & added separate accept/decline callbacks for keyboard/gamepad mode.
Report comment to moderator  
Reply With Quote
Unread 11/07/15, 06:08 PM  
circonian
AddOn Author - Click to view AddOns

Forum posts: 613
File comments: 804
Uploads: 27
Originally Posted by CaptainBlagbird
I'm still a little bit confused about the order. I'm using secsSinceRequest as recommended, I don't use sortKey or sortIndex as they are only for internal sorting, right?
I noticed the list getting unsorted while there is a MotD pending: imgur album
I see that ZO_GuildMotDProvider is the only official provider that doesn't use secsSinceRequest so I guess that's the reason. But I haven't tested with other official notifications yet. I don't care much about the list not being sorted correctly, but I wanted to point it out to you.
Yes sortIndex Is used for internal sorting. But to avoid that and other keys used by the game in the message table that is why I decided to change the instructions to say that you should just put any custom data in the message.data = { -- here -- } table. That way no matter what you put in there it wont interfere with any other special keys.




You said you "Removed a custom notification (#2)" and it is true that the notification with the heading Added #2 has disappeared, but I also notice that the message text associated with every notification has changed & no longer matches the heading. ONLY removing a notification would not change the heading/text of the other notifications so clearly something else has happened here. The sort problem does indeed exist, but something else is also going on in your test example.





You are indeed correct about the MotD though, the fact that the sort key is missing from the MotD message table is what is messing up the entire sort.
http://www.esoui.com/forums/showthread.php?p=24187#post24187

If you want to test it yourself, just add that key to the MotD BuildNotificationList function (dump this in your code file)
Warning: Spoiler

and that will fix the sort problem. Hopefully they'll fix it though.
Last edited by circonian : 11/07/15 at 06:29 PM.
Report comment to moderator  
Reply With Quote
Unread 11/07/15, 06:54 PM  
CaptainBlagbird
 
CaptainBlagbird's Avatar
AddOn Author - Click to view AddOns

Forum posts: 53
File comments: 177
Uploads: 23
Originally Posted by circonian
I also notice that the message text associated with every notification has changed & no longer matches the heading. ONLY removing a notification would not change the heading/text of the other notifications so clearly something else has happened here.
That's right, on removing I also updated the message with the new table index (because some indices might obviously get changed on removing), I should have clarified that.

Originally Posted by circonian
If you want to test it yourself, just add that key to the MotD BuildNotificationList function (dump this in your code file) and that will fix the sort problem.
Yep, fixes it. I think I'll use this in a temporary add-on until ZOS fixed it
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: