For the past few days I have been working on an XML defined UI system where I define my UI in XML files, parse them and use sprtiebatch(sharpdx.toolkit) to draw the UI elements. I have a texture atlas and xml atlas lookup info so I can draw everything in 3 layers for textures and 3 text layers for each size of font for a max of 6 draw calls depending on how may font(sizes) you can see at once, the other three draw calls are for the different blendstates.
Drawing is very fast!
Here is how I define a window in XML
<MainWindowContainer NodeType= "Container" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="window.xml">
<MainWindow NodeType= "Container" Blend="Alpha" Visible="False" Text="This is a heading" TextSize="Large" TextColor="Red" TextX="96" TextY="25"
bg_gfx=""
fg_gfx="windows/window_background.png"
Width="500" Height="800" X="1409" Y="32" >
<CloseButton NodeType= "Portrait" Parent="MainWindow" Mode="Relitive" Effect="Swap" Blend="Alpha" Action="Hide" ActionTarget="MainWindow" CanClick="True"
fg_gfx="Worldmap/close.png"
bg_gfx="Worldmap/close_hover.png"
Width="32" Height="32" X="16" Y="16" ToolTipText="Close This Window"
/>
<TextBox0 NodeType= "Portrait" Parent="MainWindow" Mode="Relitive"
bg_gfx=""
fg_gfx=""
TextFile="UI\UIText0.txt"
TextSize="Mid"
TextColor="Blue"
Width="0" Height="0" X="0" Y="0" TextX="16" TextY="128">
</TextBox0>
</MainWindow>
I have a few different XML files and one main file called hud.xml that links all the other files under a root node called MainHudView(screen).
All of this works and it works really well, here you can see it in action as well as see how the UI Tree is setout in the treeview on the left side of the window.
Now I'm going to have a "Click" action that will be able to call anything in the engine to loading in a new UI tree for say a loading screen or a full screen world map view and I'm not sure about what the best way to do it would be.
Should I have the MainHudView(screen) reference every screen in the game or have a different UI Tree for each screen and only load a screen from disk as I need?