Force UI to use changed localization string?
If I change a localization string in-game, is there a way to force the UI elements that use the string, to update themselves?
Specifically, I can successfully change the string for the "N" label on the compass with: Lua Code:
However the compass does not update itself to use the changed string. This does not change if I /reloadui or change zones, etc. |
No there isn't, you need to make sure the text is updated before it is used at any control at the UI.
e.g. try to change the constant early before your EVENT_ADD_ON_LOADED. But it may be that this still is too late as vanilla code lua files always get loaded before your addon files, including your addon files (e.g. via the txt manifest loaded language/Transaltion files) loaded before event_Add_on_loaded. The text is just read from the constant and then passed to a label control e.g.. The label is not touched if you change the constant! You need to update the label again via labelControl:SetText(GetString(SI_CONSTANT_HERE)) to make it show the updated text. So I guess in the end you need to update the label controls at the compass manually via your addon, to show your new text. |
Thanks. Using zgoo I have found that ZO_CompassContainer controls all the compass "contents" (pins and N/S/E/W labels). However, I can't find any child label controls. ZO_CompassContainer has 7 child controls, all of which are custom compass pins that my mod has added. It does not seem to have children for the normal game pins (quest markers etc) or for the direction labels.
Strangely ZO_CompassContainer has 99 children, but all of them are nil except numbers 75-81, which are custom pins as described above. I guess this the large number of empty child slots is in case the compass gets very crowded. |
https://github.com/esoui/esoui/blob/...mpass.lua#L519
Searching for SI_COMPASS_NORTH_ABBREVIATION brought me here. So you should do the same as this function seems to do at vanilla code. Lua Code:
|
You are a star!
Passing nonsense as a font name causes the label to be invisible: Lua Code:
|
Keep in mind that changing the SI_ constants of the vanilla game could make other addons break which rely on it, via string comparison e.g.
Not applicable here I guess but for e.g. some menu entries the descriptors of the menu buttons use those SI_ constants and the only way to identify the ciorrect button/tab would be this constants. And they could be re-used the same time at other coding you would need to change (e.g. the word "Research" or somethign similar). So if you change them you'd change the menu button too by accident (depends on if the menu button is created as the menu opens, then it would be changed, or even before as vanilla code was loaded already -> Gamepad input UI often does create the stuff as it opens!) At best create your own MY_ADDON_CONSTANT = "String here" as only vanilla game string constants should start with SI_, and then apply them ONLY THERE where really needed, so all other constants and code and addons still run fine. That said, in your example here, you could just check the function I've linked above and rebuild it. Lua Code:
This would keep the original string constant alive for other addons use! |
All times are GMT -6. The time now is 04:10 AM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI