I have been attempting to create a notification system that would involve Addins much the same way alpaca's DiploCorner system does.
While I have had pretty solid success, there are still several errors I cannot seem to get past with my hacky lua skills. Primarily, the LuaEvent "LuaEvents.CustomNotification" that is called by any custom notifications seems to run too many times.
Right now, the modder calls the notification with the following variables (based almost entirely on alpaca's Improved Notifications):
name, summary, tooltip, city, plot, highlightcolor, and a true/false boolean for highlighting.
Depending on which variables have values and which are inputted as 0, the LuaEvent will trigger 1 of 3 notification types:
CityZoom: The notification will highlight the plot in plot value, and middle clicking the notification will zoom in on the city
PlotHighlight: The notification will highlight the plot
Basic: Simply shows in the stack
To get this to work, there are 2 Modding Addin points: 1 in NotificationPanel.lua and 1 in CustomNotification.lua. The one in NotificationPanel adds each custom notification's Context files (thus stopping the need to append NotificationPanel.xml) and the one in CustomNotification calls a name and type value to be added to the custom notifications list. There is a third call in CustomNotification which checks to see if NotificationOptions exists, and if so, will add a "is this type of notification hidden?" check if that mod is on.
Attached is a .rar file including the entire solution.
What I ask is that some experienced eyes comb through the code looking for where the problems might exist.
To explain the folders:
The files in CustomNotification and lib.lua are the only files directly needed to add to another mod to allow notifications.
ImprovedEvents contains files that hook in 2 custom notifications from alpaca's Improved Notifications mod.
NotificationOptions contains files to a Notification Options UI that allows the user to choose which notifications should show. This code is also from alpaca.
Thanks again for any help anyone can give at debugging this.
While I have had pretty solid success, there are still several errors I cannot seem to get past with my hacky lua skills. Primarily, the LuaEvent "LuaEvents.CustomNotification" that is called by any custom notifications seems to run too many times.
Right now, the modder calls the notification with the following variables (based almost entirely on alpaca's Improved Notifications):
name, summary, tooltip, city, plot, highlightcolor, and a true/false boolean for highlighting.
Depending on which variables have values and which are inputted as 0, the LuaEvent will trigger 1 of 3 notification types:
CityZoom: The notification will highlight the plot in plot value, and middle clicking the notification will zoom in on the city
PlotHighlight: The notification will highlight the plot
Basic: Simply shows in the stack
To get this to work, there are 2 Modding Addin points: 1 in NotificationPanel.lua and 1 in CustomNotification.lua. The one in NotificationPanel adds each custom notification's Context files (thus stopping the need to append NotificationPanel.xml) and the one in CustomNotification calls a name and type value to be added to the custom notifications list. There is a third call in CustomNotification which checks to see if NotificationOptions exists, and if so, will add a "is this type of notification hidden?" check if that mod is on.
Attached is a .rar file including the entire solution.
What I ask is that some experienced eyes comb through the code looking for where the problems might exist.
To explain the folders:
The files in CustomNotification and lib.lua are the only files directly needed to add to another mod to allow notifications.
ImprovedEvents contains files that hook in 2 custom notifications from alpaca's Improved Notifications mod.
NotificationOptions contains files to a Notification Options UI that allows the user to choose which notifications should show. This code is also from alpaca.
Thanks again for any help anyone can give at debugging this.