Thread Tools Display Modes
11/15/15, 07:36 PM   #1
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
Is it possible to differentiate a login from a UI reload?

From the perspective of an add-on, what's the difference between a login (you just selected your character) from a /reloadui command?
  Reply With Quote
11/16/15, 12:46 AM   #2
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
GetGameTimeMilliseconds() will be reset to 0 and all client side caches outside of lua will be cleared (e.g. guild history, leaderboards, etc.) when you relog instead of reloadui.
  Reply With Quote
11/16/15, 01:57 AM   #3
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
You can PreHook the ReloadUI() function and set a flag to SV if you need to know if the EVENT_ADD_ON_LOADED follow a reload UI or something else.

but this one should be only used if you want to restore something tht the reloadui wiped.
  Reply With Quote
11/16/15, 05:24 AM   #4
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
Originally Posted by sirinsidiator View Post
GetGameTimeMilliseconds() will be reset to 0 and all client side caches outside of lua will be cleared (e.g. guild history, leaderboards, etc.) when you relog instead of reloadui.
Awesome! Thanks!
  Reply With Quote
11/16/15, 06:43 AM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
Originally Posted by Ayantir View Post
You can PreHook the ReloadUI() function and set a flag to SV if you need to know if the EVENT_ADD_ON_LOADED follow a reload UI or something else.

but this one should be only used if you want to restore something tht the reloadui wiped.
This only works as long as the game does not crash. Otherwise the flag won't be cleared after the UI reload and the next login after the crash will be detected as a reload.

Depending on what you plan to do it will be easier to just check if GetGameTimeMilliseconds() < 300000 assuming that addon loaded does fire within 5 minutes after login and simply ignore that there can be UI reloads in that time. Nobody besides an addon author should reload the UI in the first few minutes after login anyways.
  Reply With Quote
11/16/15, 06:57 AM   #6
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
I want to record a "play session", it being from login until logout. So I must retain data even if the game reloads the UI for any reason. The session is only really finished if the player exits or logs out. Does it make sense?
  Reply With Quote
11/16/15, 10:12 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
In that case, why don't you just collect the data to your saved vars and take care of "closing" the old session when GetGameTimeMilliseconds returns a smaller value than the last value you saved?
  Reply With Quote
11/16/15, 10:44 AM   #8
haggen
 
haggen's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2015
Posts: 137
Originally Posted by sirinsidiator View Post
In that case, why don't you just collect the data to your saved vars and take care of "closing" the old session when GetGameTimeMilliseconds returns a smaller value than the last value you saved?
You nailed it, thank you! I didn't know how GetGameTimeMilliseconds worked exactly. :P

Edit. Hey I just noticed that you're the author of AwesomeGuildStore, so thank you again, excellent add-on, I loved it!

Last edited by haggen : 11/16/15 at 10:49 AM.
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Is it possible to differentiate a login from a UI reload?


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