Example #1
0
 public Menu(Vector2 loc, string[] options, menuAction[] a, int r, int c, string font, ContentManager Content)
 {
     actions = a;
     cursor = 0;
     rows = r;
     cols = c;
     location = loc;
     boop = Content.Load<SoundEffect>("boop");
     bufferedLocation = new Vector2 (loc.X + 4, loc.Y + 4);
     textSystems = new TextSystem[options.Length];
     for (int x = 0; x < options.Length; x++) {
         textSystems [x] = new TextSystem (font, Content);
         foreach (char ch in options[x].ToCharArray()) {
             textSystems[x].addLetter(ch);
         }
     }
     for (int x = 0; x < textSystems.Length; x++) {
         TextSystem ts = textSystems[x];
         ts.location = getTrueLocation (getVectorFromIndex (x));
     }
     int farthestRightOption = textSystems.Length - 1;
     for (int x = 0; x < textSystems.Length; x++) {
         if (x % cols == cols - 1 && textSystems [x].getWidth () > textSystems [farthestRightOption].getWidth ()) {
             farthestRightOption = x;
         }
     }
     size = new Vector2(textSystems[farthestRightOption].location.X + textSystems[farthestRightOption].getWidth() - location.X - 8,
                        textSystems[textSystems.Length - 1].location.Y + textSystems[textSystems.Length - 1].getHeight() - location.Y - 8);
     blackTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
     Color[] blackTextureData = new Color[1];
     blackTextureData[0] = Color.Black;
     blackTexture.SetData(blackTextureData);
     yellowTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
     Color[] yellowTextureData = new Color[1];
     yellowTextureData[0] = Color.Gold;
     yellowTexture.SetData(yellowTextureData);
 }
Example #2
0
 public void SetMenuAction(GameObject button, menuAction act)
 {
     button.GetComponent <Button>().onClick.AddListener(delegate { act.Invoke(); });
 }