예제 #1
0
        public ConfirmationScreen(ScreenSystem screenSystem, SpriteFont font, string text, Action onCancel, Action onOkay)
            : base(screenSystem, ScreenType.Confirmation)
        {
            _spriteBatch = screenSystem.spriteBatch;
            _font = font;
            _onCancel = onCancel;
            _onOkay = onOkay;

            Vector2 titleSize = _font.MeasureString(text);
            int padding = 16;

            _overlay = new Overlay(this, Color.Black);

            _pane = new StonePane(
                this,
                UIAlignment.MiddleCenter,
                0,
                -padding,
                (int)titleSize.X + padding * 2,
                100);

            _label = new Label(
                this,
                _font,
                UIAlignment.MiddleCenter,
                0,
                -50,
                TextAlignment.Center,
                text,
                2);

            _cancelButton = new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                (int)(titleSize.X / 2f) - 285,
                15,
                ResourceManager.getTexture("cancel_button_over"),
                ResourceManager.getTexture("cancel_button"),
                new Rectangle(0, 0, 152, 33),
                () => { _onCancel(); });

            _okayButton = new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                (int)(titleSize.X / 2f) - 125,
                15,
                ResourceManager.getTexture("okay_button_over"),
                ResourceManager.getTexture("okay_button"),
                new Rectangle(0, 0, 152, 33),
                () => { _onOkay(); });
        }
예제 #2
0
        private void createInterfaceElements()
        {
            Rectangle  categoryButtonHitBox = new Rectangle(20, 0, 198, 68);
            Rectangle  confirmButtonHitBox  = new Rectangle(0, 0, 152, 33);
            Point      categoryButtonOffset = new Point(-527, -160);
            Func <int> yOffset = () => { return(categoryButtonOffset.Y + 81 * _generalButtons.Count); };

            _pane = new BluePane(
                this,
                UIAlignment.MiddleCenter,
                0,
                0,
                620,
                360);

            _generalButtons.Add(new TextureButton(
                                    this,
                                    _spriteBatch,
                                    UIAlignment.MiddleCenter,
                                    categoryButtonOffset.X,
                                    yOffset(),
                                    _content.Load <Texture2D>("options_menu/video_button_over"),
                                    _content.Load <Texture2D>("options_menu/video_button"),
                                    categoryButtonHitBox,
                                    () => { switchCategory(OptionsCategory.Video); }));

            _generalButtons.Add(new TextureButton(
                                    this,
                                    _spriteBatch,
                                    UIAlignment.MiddleCenter,
                                    categoryButtonOffset.X,
                                    yOffset(),
                                    _content.Load <Texture2D>("options_menu/audio_button_over"),
                                    _content.Load <Texture2D>("options_menu/audio_button"),
                                    categoryButtonHitBox,
                                    () => { switchCategory(OptionsCategory.Audio); }));

            _generalButtons.Add(new TextureButton(
                                    this,
                                    _spriteBatch,
                                    UIAlignment.MiddleCenter,
                                    categoryButtonOffset.X,
                                    yOffset(),
                                    _content.Load <Texture2D>("options_menu/controls_button_over"),
                                    _content.Load <Texture2D>("options_menu/controls_button"),
                                    categoryButtonHitBox,
                                    () => { switchCategory(OptionsCategory.Controls); }));

            _generalButtons.Add(new TextureButton(
                                    this,
                                    _spriteBatch,
                                    UIAlignment.MiddleCenter,
                                    170,
                                    158,
                                    _content.Load <Texture2D>("shared_ui/save_button_over"),
                                    _content.Load <Texture2D>("shared_ui/save_button"),
                                    confirmButtonHitBox,
                                    () =>
            {
                saveSettings();
                _game.closeOptionsMenu();
                _game.openMainMenu();
            }));

            _generalButtons.Add(new TextureButton(
                                    this,
                                    _spriteBatch,
                                    UIAlignment.MiddleCenter,
                                    6,
                                    158,
                                    _content.Load <Texture2D>("shared_ui/cancel_button_over"),
                                    _content.Load <Texture2D>("shared_ui/cancel_button"),
                                    confirmButtonHitBox,
                                    () =>
            {
                _game.closeOptionsMenu();
                _game.openMainMenu();
            }));
        }
예제 #3
0
        private void createInterfaceElements()
        {
            Rectangle categoryButtonHitBox = new Rectangle(20, 0, 198, 68);
            Rectangle confirmButtonHitBox = new Rectangle(0, 0, 152, 33);
            Point categoryButtonOffset = new Point(-527, -160);
            Func<int> yOffset = () => { return categoryButtonOffset.Y + 81 * _generalButtons.Count; };

            _pane = new BluePane(
                this,
                UIAlignment.MiddleCenter,
                0,
                0,
                620,
                360);

            _generalButtons.Add(new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                categoryButtonOffset.X,
                yOffset(),
                _content.Load<Texture2D>("options_menu/video_button_over"),
                _content.Load<Texture2D>("options_menu/video_button"),
                categoryButtonHitBox,
                () => { switchCategory(OptionsCategory.Video); }));

            _generalButtons.Add(new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                categoryButtonOffset.X,
                yOffset(),
                _content.Load<Texture2D>("options_menu/audio_button_over"),
                _content.Load<Texture2D>("options_menu/audio_button"),
                categoryButtonHitBox,
                () => { switchCategory(OptionsCategory.Audio); }));

            _generalButtons.Add(new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                categoryButtonOffset.X,
                yOffset(),
                _content.Load<Texture2D>("options_menu/controls_button_over"),
                _content.Load<Texture2D>("options_menu/controls_button"),
                categoryButtonHitBox,
                () => { switchCategory(OptionsCategory.Controls); }));

            _generalButtons.Add(new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                170,
                158,
                _content.Load<Texture2D>("shared_ui/save_button_over"),
                _content.Load<Texture2D>("shared_ui/save_button"),
                confirmButtonHitBox,
                () =>
                {
                    saveSettings();
                    _game.closeOptionsMenu();
                    _game.openMainMenu();
                }));

            _generalButtons.Add(new TextureButton(
                this,
                _spriteBatch,
                UIAlignment.MiddleCenter,
                6,
                158,
                _content.Load<Texture2D>("shared_ui/cancel_button_over"),
                _content.Load<Texture2D>("shared_ui/cancel_button"),
                confirmButtonHitBox,
                () =>
                {
                    _game.closeOptionsMenu();
                    _game.openMainMenu();
                }));
        }