Beispiel #1
0
        public Settings(Text title, Switch[] switches, Drawable background, SpriteFont font)
            : base(background)
        {
            this.switches = switches;
            for (int i = 0; i < switches.Length; i++)
            {
                base.Add(this.switches[i]);
            }

            this.title = title;
            base.Add(this.title);

            exit = new Button("Back", font, new Vector2(512, 725), Color.Black);
            exit.height = 58;
            base.Add(exit);
        }
Beispiel #2
0
        // menu constructor
        public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont, Drawable checkMark)
            : base(background)
        {
            // gives buttons height & width, adds title, makes buttons & gives position in middle of screen
            buttonHeight = 75;
            buttons = new Button[numberOfButtons];
            buttonAmount = numberOfButtons;
            _checkMark = checkMark;
            base.Add(title);
            title.attributes.position = new Vector2(512, title.height / 2 + 40);
            title.attributes.depth = .01f;
            maxButtonWidth = 0;

            // makes new buttons, adds heights, adds actions and events for if clicked
            for (int i = 0; i < numberOfButtons; i++)
            {
                buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, title.height + 140 + ((800 - title.height - 80 - buttonHeight) / numberOfButtons) * i), Color.Black, _checkMark);
                buttons[i].height = buttonHeight;
                buttons[i].Clicked += buttonActions[i];
                buttons[i].Clicked += delegate()
                {
                    for (int j = 0; j < numberOfButtons; j++)
                    {
                        if (j != i) buttons[j].Remove();
                    }
                };
                if (buttons[i].width > maxButtonWidth) maxButtonWidth = buttons[i].width;
                base.Add(buttons[i]);
                buttons[i].attributes.depth = .01f;
            }

            // sets selected button to the top button
            selected = 0;
            // initializes menu to off, then turns it on after .5 seconds
            myState = menuState.Off;
            keysOff = false;
            Timer state = new Timer(1);
            base.Add(state);
            state.SetTimer(0, .5f, delegate() { myState = menuState.On; });
        }
Beispiel #3
0
        // overloaded constructor to add buttonheight
        public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont, int buttonHeight, bool PAMenuButtonHeight)
            : base(background)
        {
            this.buttonHeight = buttonHeight;
            buttons = new Button[numberOfButtons];
            base.Add(title);
            title.attributes.position = new Vector2(512, title.height / 2 + 40);
            title.attributes.depth = .01f;
            maxButtonWidth = 0;
            for (int i = 0; i < numberOfButtons; i++)
            {
                buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, 550 + (125 * i)), Color.Black);
                buttons[i].height = 100;
                buttons[i].Clicked += buttonActions[i];
                buttons[i].Clicked += delegate()
                {
                    for (int j = 0; j < numberOfButtons; j++)
                    {
                        if (j != i) buttons[j].Remove();
                    }
                };
                if (buttons[i].width > maxButtonWidth) maxButtonWidth = buttons[i].width;
                base.Add(buttons[i]);
                buttons[i].attributes.depth = .01f;
            }

            selected = 0;
            myState = menuState.Off;
            keysOff = false;
            Timer state = new Timer(1);
            base.Add(state);
            state.SetTimer(0, .5f, delegate() { myState = menuState.On; });
        }
Beispiel #4
0
 public void SetButton(Button.ClickHandler process)
 {
     exit.Clicked += process;
 }