ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   General Authoring Discussion (https://www.esoui.com/forums/forumdisplay.php?f=174)
-   -   Is there a way to detect a /reloadui? (https://www.esoui.com/forums/showthread.php?t=10317)

Toirealach 09/01/22 12:13 AM

Is there a way to detect a /reloadui?
 
Is there a way in an addon to detect that the UI is being reloaded via a /reloadui (or Reload UI button) in my OnLoad() function. I'd like to know about initial load of the addon on character load versus a reload. Any way to do that?

Baertram 09/01/22 01:32 AM

EVENT_PLAYER_ACTIVATED fires on login and each reloadui. The parameters of the event are
eventId, firstLoad

The 2nd param firstLoad is a boolean and is true at first event load after login, and false at each following reloadui/zone change etc. afaik.
Or even cleaner:
Just unregister the event again after it has fired the 1st time and run your code that you need, if you only need to run code on first time.

Toirealach 09/01/22 10:28 AM

Ah perfect! This will work. I have users for an addon on which I'm working that want some stats to reset only on firstLoad while others want it to roll over each time the OnLoad event handler is called. Thanks so much!

ZOS_DanBatson 09/01/22 01:12 PM

Also, in U36, a new event will be coming called EVENT_GUI_UNLOADING. This will fire right before the GUI unloads for a reload UI, in case you need to do anything before we destroy everything.

sirinsidiator 09/01/22 03:12 PM

As far as I am aware, the initial flag of the EVENT_PLAYER_ACTIVATED is a bit broken (or at least it was when I checked the last time). It works in that it passes true and false for login and reloadui, but for every other loading screen it passes true too, which may come a bit unexpected if you do not unregister the event handler.
To work around that you'll either have to add an extra variable which tracks if it's the first loading screen after the UI load or make sure the function is only called once by unregistering inside the handler.

Calamath 09/01/22 05:27 PM

Quote:

As far as I am aware, the initial flag of the EVENT_PLAYER_ACTIVATED is a bit broken (or at least it was when I checked the last time). It works in that it passes true and false for login and reloadui, but for every other loading screen it passes true too,
That is still the current spec.
However, if Dan is going to fix it, at least I need to know when that change will be made. :p

Baertram 09/01/22 05:31 PM

Info from Dan about the EVENT_PLAYER_ACTIVATED "initial" parameter 2:
Quote:

It is poorly named. What that bool means to the code is "activateIsNotAResultOfUIReload"
Effectively, if the player activated because you just came into a zone (login or jump) it'll be true. If the player activated because you did a reload ui, but you were already in and didn't jump anywhere, it'll be false.

Reloading UI does not re initialize your player state in the eyes of the client or the server. It just reloads the UI. Jumping basically kills all knowledge of your player state and recreates it from the server, almost as if you just logged in.

Calamath 09/01/22 05:52 PM

Thank you. Just now read gitter too. That was a long name. :p


All times are GMT -6. The time now is 03:34 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI