View Single Post
08/08/23, 07:05 AM   #46
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 5,000
Originally Posted by Masteroshi430 View Post
OK, what I don't get yet is why do we have to set it to the same value if it is already set :

...
Is our XML totally overwriting the vanilla XML to the point we have to set all the variables that are in the tags again?

As far as I know:
Yes. It's the same for lua and all other codes.
If someone defined some code (ZOs vanillla, or any other addon) but you need to change it again "later" you need to hook it, or overwrite it to add new code, or to change it somehow.
For lua you can prehook or posthook it to add your additional code.

For XML there is no such feature so if you define the same "name" you will overwrite existing XML code.
Normally this fails and says "Control already exists with same name" (if you were using a <Control> xml tag e.g.).
But for some xml tags like the <Bindings> <Layer> you will just redefine (if it exists in vanilla code, or another addon which was loaded before your's was loaded) the layer data then.
> This will overwrite the parts you did specify in your xml data then.

e.g. if you redefine
Code:
<Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
        <Category name="SI_KEYBINDINGS_CATEGORY_MOVEMENT">
            <Action name="MOVE_FORWARD">
It either fails and says not allowed as some of the keybinds are protected afaik.
Or it will overwrite the MOVE_FORWARD with your definition then.

And if you add a new one which didn't exist yet
Code:
<Layer name="SI_KEYBINDINGS_LAYER_GENERAL">
        <Category name="SI_KEYBINDINGS_CATEGORY_MOVEMENT">
            <Action name="MOVE_BACKFLIPP">
You define the surrounding tags and attributes and create a new keybind possibility that way, which is named "MOVE_BACKFLIPP".
Nothing overwritten.

Why this second language, in what cases I should use it over LUA...
In the case of keybindings as you cannot define keybindings via lua only.
And in any other case where you feel it's more easy to create UI elements via XML instead of using lua do dynamically create the controls.
And in any case where you define virtual templates for lua controls in XML and just load them via lua functions then that accept virtual template names as parameters (as virtual templates cannot be created without XML, in lua, afaik).



In your example with "<Layer name="GamepadUIMode" allowFallthrough="false">"
It was defined with that attribute allowFallthrough="false" and if you redefine (overwrite) that row again by removing allowFallthrough="false" it will fail to work properly as this was not intended to work/is not supported. (no client crash and no error message, just silently fails).
Same if you change that to "true" -> client crash (maybe error message in the future).

I'm not sure if there is any list which atributes in the XML behave like that.
e.g. would it behave the same if it would haven been hideAction="true" in original definition and you overwrite it with hideAction="false" or just remove the hideAction attribute in total? I don't know but I think it would behave the same (hopefully except the "client crash" :-)).
Else you might be able to change the general idea/usage of those keybinds by just removing info like "do not allow to be pressed while dead" etc.

Last edited by Baertram : 08/08/23 at 07:41 AM.
  Reply With Quote