Ejemplo n.º 1
0
 public void AddItem(string text)
 {
     // set position by item order
     Vector2 p = new Vector2(position.X, position.Y + items.Count * height);
     MenuItem item = new MenuItem(text, p);
     items.Add(item);
     // select first item
     if (selectedItem == null)
         selectedItem = item;
 }
Ejemplo n.º 2
0
 public MenuItemComponent(Game game, Vector2 position, Color unselectedColor, Color selectedColor, int height)
     : base(game)
 {
     this.position = position;
     this.game = game;
     this.unselectedColor = unselectedColor;
     this.selectedColor = selectedColor;
     this.height = height;
     items = new List<MenuItem>();
     selectedItem = null;
 }
Ejemplo n.º 3
0
 private void SelectPrevItem()
 {
     int index = items.IndexOf(selectedItem);
     if (index > 0)
         selectedItem = items[index - 1];
     else
         selectedItem = items[items.Count - 1];
 }
Ejemplo n.º 4
0
 private void SelectNextItem()
 {
     int index = items.IndexOf(selectedItem);
     if (index < items.Count - 1)
         selectedItem = items[index + 1];
     else
         selectedItem = items[0];
 }