I have been working on the UI system for my XNA game since most of the added value will be a neat presentation layer. I came up with a fairly simple UI system that builds up on my state machine class I talked about last time. The whole thing is rather straightworward to use. Here is a quick video of it in action:
One of the interesting thing about this UI framework is the ability for any widget to specify its neighours, so when the focus moves, the UI page can figure out who should recieve the focus. Here is a snippet from the UIWidget class which is base for all widgets:
public class UIWidget : StateMachine
{
...
public UIWidget LeftNeighbour
{
get;
set;
}
public UIWidget RightNeighbour
{
get;
set;
}
public UIWidget UpNeighbour
{
get;
set;
}
public UIWidget DownNeighbour
{
get;
set;
}
...
}
Widgets are laid out on UIPage objects. A UIPage keeps track of the focussed widget and processes pad inputs. When recieving a pad message, it picks the right neibour from the focussed widget and transfers focus to it. Note that multiple controls can have the same neighbour for a particular direction, so you can create rather complex layouts with a bit of work.
That's all for today!
No comments:
Post a Comment