Пример #1
0
 /// <summary>
 /// Initialises this menu, sets the selected and previous options to null, sets up the menu and back buttons and sets the back button to non visible. Sets up the previous keyboard state.
 /// Once initialised with this constructor you need to select an option with the select method before the menu will work properly
 /// </summary>
 public Menu()
 {
     this.selectedOption = null;
     this.prevOptions = new Stack<MenuOption>();
     menuButton = new MenuButton(new Vector2(0, 0));
     backButton = new BackButton(new Vector2(menuButton.getWidth() + 1, 0), this);
     backButton.setVisible(false);
     prevState = new KeyboardState();
 }
Пример #2
0
 /// <summary>
 /// Adds an option to the list this object represents
 /// </summary>
 /// <param name="m">The option to add to the list</param>
 public void addOption(MenuOption m)
 {
     options.Add(m);
 }
Пример #3
0
 /// <summary>
 /// Initialses the OptionButton, taking the location, size, texture and option to be associated with and setting the button text to be the default "unset".
 /// </summary>
 /// <param name="topLeft">The location of the top left of the button as a Vector2</param>
 /// <param name="size">The size of the button as a Vector2</param>
 /// <param name="texture">The TextureNames associated with the texture for this button</param>
 /// <param name="option">The option associated with this button</param>
 public OptionButton(Vector2 topLeft, Vector2 size, TextureNames texture, MenuOption option)
     : base("unset", topLeft, size, texture)
 {
     associatedOption = option;
 }
Пример #4
0
 /// <summary>
 /// Sets the specified option as the current option and pushes the previous current option onto the prevoptions Stack
 /// </summary>
 /// <param name="o">The option to select</param>
 public void select(MenuOption o)
 {
     if (selectedOption != null)
     {
         prevOptions.Push(selectedOption);
     }
     selectedOption = o;
 }
Пример #5
0
 /// <summary>
 /// Sets the current element to be the first element popped out of the previous options stack
 /// </summary>
 public void back()
 {
     selectedOption = prevOptions.Pop();
 }