Exemplo n.º 1
0
        public UIButton InsertButton( int index, String text, MouseButtonEventHandler clickHandler = null )
        {
            float y = ButtonMargin;
            if ( _buttons.Count != 0 && index != 0 )
                y = _buttons[ index - 1 ].Bottom + ButtonSpacing;

            for ( int i = index; i < _buttons.Count; ++i )
                _buttons[ i ].Top += _buttons[ i ].Height + ButtonSpacing;

            UIButton newButton = new UIButton( new Vector2( InnerWidth - ButtonMargin * 2, ButtonHeight ), new Vector2( ButtonMargin, y ) )
            {
                Text = text,
                CentreText = true
            };
            _buttons.Insert( index, newButton );
            AddChild( newButton );

            if ( clickHandler != null )
                newButton.Click += clickHandler;

            return newButton;
        }
Exemplo n.º 2
0
        public override void OnEnter(bool firstTime)
        {
            base.OnEnter(firstTime);

            MainWindow.IsPaused = true;

            if (firstTime) {
                _filter = new UIPanel(new Vector2(Width, Height)) {
                    Colour = new Color4(0, 0, 0, 191)
                };

                AddChild(_filter);

                _worldSizeLbl = new UILabel(Graphics.PixelFont.Large) {
                    Text = "World Size",
                    Colour = Color4.White
                };

                AddChild(_worldSizeLbl);

                _worldSizeTxt = new UINumericTextBox(new Vector2(48, 20)) {
                    Minimum = 32,
                    Maximum = 256,
                    Value = 128
                };

                AddChild(_worldSizeTxt);

                _humanCountLbl = new UILabel(Graphics.PixelFont.Large) {
                    Text = "Survivor Count",
                    Colour = Color4.White
                };

                AddChild(_humanCountLbl);

                _humanCountTxt = new UINumericTextBox(new Vector2(48, 20)) {
                    Minimum = 0,
                    Maximum = 512,
                    Value = 192
                };

                AddChild(_humanCountTxt);

                _zombieCountLbl = new UILabel(Graphics.PixelFont.Large) {
                    Text = "Zombie Count",
                    Colour = Color4.White
                };

                AddChild(_zombieCountLbl);

                _zombieCountTxt = new UINumericTextBox(new Vector2(48, 20)) {
                    Minimum = 0,
                    Maximum = 512,
                    Value = 64
                };

                AddChild(_zombieCountTxt);

                _generateBtn = new UIButton(new Vector2(96, 32)) {
                    Text = "Start New",
                    CentreText = true
                };

                _generateBtn.Click += (sender, e) => {
                    if (_gameScene != null) _gameScene.Dispose();

                    _gameScene = new GameScene(GameWindow, this);
                    MainWindow.SetScene(_gameScene);
                };

                AddChild(_generateBtn);

                _quitBtn = new UIButton(_generateBtn.Size) {
                    Text = "Quit",
                    CentreText = true
                };

                _quitBtn.Click += (sender, e) => {
                    GameWindow.Close();
                };

                AddChild(_quitBtn);

                _continueBtn = new UIButton(new Vector2(_quitBtn.Width + _generateBtn.Width + 8, _generateBtn.Height)) {
                    Text = "Continue",
                    CentreText = true,
                    IsEnabled = false
                };

                _continueBtn.Click += (sender, e) => {
                    MainWindow.SetScene(_gameScene);
                };

                AddChild(_continueBtn);
            }

            RepositionElements();
            
            _continueBtn.IsEnabled = _gameScene != null;
        }
Exemplo n.º 3
0
 public void RemoveButton( UIButton button )
 {
     RemoveButton( _buttons.IndexOf( button ) );
 }