Thread Tools Display Modes
09/01/22, 12:13 AM   #1
Toirealach
AddOn Author - Click to view addons
Join Date: Sep 2020
Posts: 18
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?
  Reply With Quote
09/01/22, 01:32 AM   #2
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
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.
  Reply With Quote
09/01/22, 10:28 AM   #3
Toirealach
AddOn Author - Click to view addons
Join Date: Sep 2020
Posts: 18
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!
  Reply With Quote
09/01/22, 01:12 PM   #4
ZOS_DanBatson
ZOS Staff!
 
ZOS_DanBatson's Avatar
Yes this person is from ZeniMax!
Join Date: Jul 2015
Posts: 171
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.
  Reply With Quote
09/01/22, 03:12 PM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,567
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.
  Reply With Quote
09/01/22, 05:27 PM   #6
Calamath
AddOn Author - Click to view addons
Join Date: Aug 2019
Posts: 36
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.
  Reply With Quote
09/01/22, 05:31 PM   #7
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,912
Info from Dan about the EVENT_PLAYER_ACTIVATED "initial" parameter 2:
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.
  Reply With Quote
09/01/22, 05:52 PM   #8
Calamath
AddOn Author - Click to view addons
Join Date: Aug 2019
Posts: 36
Thank you. Just now read gitter too. That was a long name.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Is there a way to detect a /reloadui?

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off