Exemplo n.º 1
0
        protected void AddMenuItem(string str, GameEngine.Helpers.Input.Action action)
        {
            menuItems.Add(new StringToDraw(game, str, new Vector2(), font));
            if (menuItems.Count == 1)
            {
                UpdateSelected();
            }

            AddAction(menuItems.Count - 1, action);

            height    = 0;
            maxLength = 0;
            foreach (StringToDraw s in menuItems)
            {
                Vector2 v = s.StringSize();
                height   += v.Y;
                maxLength = MathHelper.Max(maxLength, v.X);
            }

            float startY    = (game.Height() - height) / 2 + ((StringToDraw)menuItems[0]).StringSize().Y / 2;
            float rowHeight = height / menuItems.Count;

            for (int ii = 0; ii < menuItems.Count; ii++)
            {
                ((StringToDraw)menuItems[ii]).Position = new Vector2(0.5f, (startY + ii * rowHeight) / game.Height());
            }
        }
Exemplo n.º 2
0
 private void AddAction(int menuItem, GameEngine.Helpers.Input.Action action)
 {
     menuActions.Add(menuItem, action);
 }