This project is read-only.

FuncWorks.Xna.UI.Menu namespace

This namespace contains a set of classes used to create on-screen menus.

The main menu class is Menu, and it can contain a number of different menu items. Menu items must inherit from IMenuItem, and several different types of menu items are provided by default.

MenuManager class


public MenuManager(Rectangle rectangle, TextStyle unselected, TextStyle selected, TextStyle disabled, int spacing)
Defines a menu positioned within the given rectangle (it will be centered vertically, with the specified number of spacing pixels between each item), with the specified TextStyles for unselected, selected, and disabled items.


public void MoveUp()
public void MoveDown()
Moves the current selection up or down one item. These classes will not allow you to scroll past the top or bottom of a list, and they handle hidden and disabled items correctly.

public void Activate()
public void MoveLeft()
public void MoveRight()
Handles actions that may affect the currently selected item.

These methods may not be defined for all menu item types. For example, a simple menu item that takes you to another screen should be handled in your code outside of the menu class. But if you have a menu option to turn music off and on, you might want to have it react to the user pressing A, DPadLeft, or DPadRight.

public void Draw(SpriteBatch spriteBatch)
Draws the menu to the screen. Must be called during your game's Draw method.

Fields / Properties

public MenuItemCollection MenuItems
Gives you access to add, remove, or modify menu items.

public int SelectedIndex
The index of the item that's currently selected.

public TextStyle UnselectedStyle
public TextStyle SelectedStyle
public TextStyle DisabledStyle
Defines the text styles used by menu items. These can be changed dynamically as the menu is running.

Types of Menu Items

All menu items inherit from the IMenuItem class, so it's possible to extend the menu by creating new types of items. The IMenuItem class defines the Enabled and Hidden properties that allow you to change the behavior of certain items.


public BooleanItem(string title, TextAlignment alignment, string truevalue, string falsevalue, bool startValue)

Defines an item that has two values: on/off, yes/no, etc. You can define the text shown for the true and false values.

The Activate, MoveLeft, and MoveRight methods toggle these values. The Value property returns the currently selected value.


public ChoiceItem(string title, TextAlignment alignment, IEnumerable<string> options, int startIndex, bool wrap)

Defines an item that allows a user to select from a list of options. You can define the list of options and which one is selected by default. You can also determine whether you can choose between the first and last items in the list.

The Activate, MoveLeft, and MoveRight methods move through the list. The SelectedIndex property returns the index of the currently selected option.


public ImageSelectItem(BlockAlignment alignment, Texture2D unselectedImage, Texture2D selectedImage, Texture2D disabledImage)

Defines a selectable image item in the list.


public IntegerItem(string title, TextAlignment alignment, int minValue, int maxValue, int startValue, int step)

Defines an item that allows a user to select from a list of numbers (for example, to control the volume of sound effects or music). You can define the minimum and maximum range for selection, as well as how much the number increases or decreases each time MoveLeft or MoveRight is caught. The Value property returns the currently selected number.


public SelectItem(string title, BlockAlignment alignment)

Defines a selectable item in the list.

Last edited Jan 4, 2010 at 4:24 AM by dylanwolf, version 1


No comments yet.