Custom UI Elements

[[Category:UI]

Creating custom UI requires decent knowledge of XAML, which was created by Microsoft as part of WPF framework. Most knowledge should be transferable, but there are some differences based on library that Relic used to convert XAML to C++ & DirectX. Older version of that library can be found at https://github.com/KevinW1998/wpfg/tree/master/WPFLib/src

Basic explanation how to create:


 * Create _mod_data that contains field data_context, which will be holding all data that UI will use.
 * Create XAML UI and save it to variable


 * Call in function UI_AddChild


 * Following this continue by looking at example and setting up more complicated things such as update rules, bindings etc., NOTE: if UI should be synchronized between players, then you will need to learn more about NetworkEvent (example can be found in official diplomacy.scar)

Common Issues
Binding game objects is not possible and will end up in AVUI to LUA error ingame. To bind ingame data, its best to convert them to plain string first.

Example
Following code (scar script) creates simple button in middle of match viewport/screen. It should serve as starting point for anyone who wants to dive deeper into creating more complex custom UI for mods.