1. We have added a Gift Upgrades feature that allows you to gift an account upgrade to another member, just in time for the holiday season. You can see the gift option when going to the Account Upgrades screen, or on any user profile screen.
    Dismiss Notice

Adding New Notification with Callback

Discussion in 'Civ5 - Creation & Customization' started by sman1975, Apr 10, 2021.

  1. sman1975

    sman1975 Emperor

    Joined:
    Aug 27, 2016
    Messages:
    1,246
    Location:
    Dallas, TX
    Does anyone know how to make a custom UI unhide by clicking on a Notification button, like the generic "City State" UI does (i.e. the basic popup that asks "What business do you have here?" at the top)?

    Looking over the NotificationPanel.lua (UI), I see 14 notifications (e.g. Found Pantheon/Religion, Enhance Religion, Choose Archaeology, Choose Ideology, Steal Tech, etc.) that have callbacks attached - that generate popups of some kind. The callbacks look like this:

    Controls["FreeTechButton"]:RegisterCallback(Mouse.eLClick, GenericLeftClick); Controls["FreeTechButton"]:RegisterCallback(Mouse.eRClick, GenericRightClick);

    Each of these notifications have a corresponding callback function/popup that performs some meaningful work when the notification button is tickled by the mouse.

    However, the NOTIFICATION_MINOR notification (q.v.) is not one of the 14 notifications in NotificationPanel.lua. This implies there might some way to add a callback to a notification, even if it is defined in a different address space. This approach is counter-intuitive to me (as is much of the UI code), so I'm not following what's going on down in the weeds.


    What I'm looking for is a way to add a notification w/ callback, hopefully without replacing the NotificationPanel.lua if at all possible. Appreciate it if anyone has a suggestion or knows of a mod that already manages this.

    Thanks!

    sman
     
  2. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    sman1975 likes this.
  3. sman1975

    sman1975 Emperor

    Joined:
    Aug 27, 2016
    Messages:
    1,246
    Location:
    Dallas, TX
    Thanks @whoward69 - @Troller0001 recommended that one to me on Discord. I took a cursory look at the code, and it looks pretty straightforward, but for the functionality I need, it's kind of like swatting a fly with a sledgehammer... :lol:

    I suppose it could just strip out the primary functions of the mod (the selectivity of notification visibility), and keep the parts that deal directly with already shown notifications and their callbacks. OTOH, the mod in its entirety is only 17 KB...

    Do you mind if I absorb the contents of "UI - Notification Options" into a reusable icon callback library I can incorporate into some of my mods?

    Thanks!


    EDIT: (question removed - I couldn't fine the entry point type called "CustomNotificationAddin" in the Type drop down menu, but then playing around with the Add Content popup, I realized I could paste the text in the Type entry. So, I created a "Custom" entry point, then simply pasted the text on top of it, and it stayed...)
     
    Last edited: Apr 11, 2021
  4. whoward69

    whoward69 DLL Minion

    Joined:
    May 30, 2011
    Messages:
    8,532
    Location:
    Near Portsmouth, UK
    Answer is in sig ;)
     
    sman1975 likes this.

Share This Page