refresh UI and font without a reloadui?
Hey! I'm looking for a way to basically refresh the UI or something to update font settings. Im working on a feature in my addon that bumps up the nameplate font size a touch, but I cant seem to get it to update it right away without reloadui which I'd really like to avoid for a more pleasant user experience. Any ideas? Ive added a chat feedback and a 1sec delay so the user can see it was changed and then a reload to activate the larger font but ideally it would just activate instantly some other way.
Heres most of what im working with: Code:
-- Nameplate Font Boost Toggle |
Anyone have any idea on this? Im just trying to get that code when executed to redraw or refresh the screen or whatever would cause the font to redraw or update..
|
I'm not sure how you're setting the font for the nameplate, but font face and size changes do not require a ui refresh of any kind. They happen instantly when you use the :SetFont(...) function on the relevant control.
For example, if you type the following into the chat window: Code:
/script ZO_ChatWindowTextEntryLabel:SetFont("ZoFontCallout") Code:
/script ZO_ChatWindowTextEntryLabel:SetFont("ZoFontChat") |
Quote:
Im setting it like this as its just an on/off function: Code:
function RidinDirty.PlayerActivated() |
I just tried the following:
Code:
/script SetNameplateKeyboardFont(string.format("%s|%d", "EsoUI/Common/Fonts/Univers67.otf", "26"),FONT_STYLE_SHADOW) Two things, 1) (not the problem but...) I think it's better practice to use named constants rather than their values, as I've done above (i.e. FONT_STYLE_SHADOW rather than 1) 2) Your code snippet implies that it only runs in response the to the Player Activated event - are you calling a similar function after you've set your new font? |
Quote:
|
I had another question as well.. I read someplace in an old post from way back in 2014/15 directly from a DEV its no longer nessisary to "Unregister" events unless your specifically disabling the event..is this correct still? I had several unregister on addonload just to make sure they were i suppose "reset" on addon load. is this not nessisary for sure still?
|
The way you have your code right now means that it will only change the font each time the Player Activated event is triggered, which only happens each time you zone in to somewhere.
If you want it to also change as soon as it's toggled, you need to refactor your code to something like this: Code:
function RidinDirty.AdjustFont() Code:
function BS.OnAddonLoaded(_, addonName) |
Oh got the font updating instantly finally.. somehow i completely missed putting the setkeybameplate... into the actual switch rather than just onplayeractivate().
I am still curious about the Uregistering events tho... ive removed them for the moment to see if i have any issues. |
EVENT_MANAGER:UnregisterForEvent(BS.Name, _G.EVENT_ADD_ON_LOADED)
Should always be done unless you need to read other addons' EVENT_ADD_ON_LOADED too! This event fires for each of your addons and libraries and as your's is found you can stop it by unregistering in 99%. EVENT_PLAYER_ACTVATED fires after login the first time, as chat is ready. You should register it at your EVENT_ADD_ON_LOADED and either keep it registered, because it also fires at a reloadUI, zone change with a loading screem (port into dungeon e.g., or port to someone in another zone ...). Or you unregister it and it will only fire once after login then. Depends on your usecase and needs. Register, unregister, re-register is not needed each time an event fires! If you want events to be triggered each time it fires just keep it registered then. But Make sure the events are not registered before your EVENT_ADD_ON_LOADED was fired, as else you might run into issues where your event's callback function is executed but your code was not ready yet as it will be initialized at your EVENT_ADD_ON_LOADED first. |
Quote:
I think my addon is basically complete now except id like still to get an oroboros logo rotating onscreen possibly with a label as a sort of hourglass for one of my functions. Once i get that its everything and more id ever hoped for :) |
A ReloadUI does clear stuff from before, you do not carry anything over.
All that could be carried over is saved in your addons SavedVariables as they are written to disk at the reloadui and read afterwards again. So if you experience bugs you should check them (SVs) first ;) But the user interface and events etc. do not save old states unless there is something saved on server side outside of the addons. If you reload the UI your addon will be loaded totally new -> EVENT_ADD_ON_LOADED -> other events and code etc. |
ok perfect ty :)
|
All times are GMT -6. The time now is 11:28 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI