Beispiel #1
0
        private void keepInsideViewport(Graphics.Viewport viewport)
        {
            int height = _upperBackground.Height;

            if ((_state & OptionsMenuState.OptionsOrSub) == _state)
            {
                height += _optionsBackground.Height;

                if ((_state & OptionsMenuState.AdvancedOptionOrSub) == _state)
                {
                    height += _advancedBackground.Height;

                    if (_state == OptionsMenuState.GraphicsOptions)
                    {
                        height += _graphicsBackground.Height;
                    }
                }
            }

            int width = _upperBackground.Width;

            int overflowX = (_screenX + width) - viewport.Width;
            int overflowY = (_screenY + height) - viewport.Height;

            if (overflowX > 0)
            {
                _screenX -= overflowX;
            }
            else if (_screenX < 0)
            {
                _screenX = 0;
            }
            if (overflowY > 0)
            {
                _screenY -= overflowY;
            }
            else if (_screenY < 0)
            {
                _screenY = 0;
            }

            foreach (Button btn in _upperButtons)
            {
                btn.CalculateScreenCoordinates();
            }

            foreach (Button btn in _optionsButtons)
            {
                btn.CalculateScreenCoordinates();
            }

            foreach (Button btn in _advancedOptionsButtons)
            {
                btn.CalculateScreenCoordinates();
            }

            _3dDriverDropdown.CalculateScreenCoordinates();
            _resolutionDropdown.CalculateScreenCoordinates();
        }
Beispiel #2
0
        private Graphics.Rect centerBox(Graphics.Viewport viewport, Graphics.Rect size)
        {
            Graphics.Rect result = size;
            result.X = (float)System.Math.Floor((viewport.Width - size.Width) / 2);
            result.Y = (float)System.Math.Floor((viewport.Height - size.Height) / 2);

            return(result);
        }
Beispiel #3
0
        public void Show(int screenX, int screenY, Graphics.Viewport viewport)
        {
            _viewport = viewport;
            _active   = true;
            _screenX  = screenX - _upperBackground.Width / 2;
            _screenY  = screenY - _upperBackground.Height / 2;

            _state = OptionsMenuState.Initial;

            keepInsideViewport(viewport);
        }
Beispiel #4
0
        internal void CalculateScreenCoordinates()
        {
            Graphics.Viewport vp = Graphics.RendererManager.CurrentRenderer.Viewport;

            if (_container != null)
            {
                _screenX = (int)(vp.X + _x.Scale * vp.Width + _x.Offset) + _container.ScreenX;
                _screenY = (int)(vp.Y + _y.Scale * vp.Height + _y.Offset) + _container.ScreenY;
            }
            else
            {
                _screenX = (int)(vp.X + _x.Scale * vp.Width + _x.Offset);
                _screenY = (int)(vp.Y + _y.Scale * vp.Height + _y.Offset);
            }
        }
Beispiel #5
0
        public void KeepInsideViewport(Graphics.Viewport viewport)
        {
            if (_buttons.Count > 0)
            {
                int totalWidth = _buttons.Count * ButtonWidth;

                int overflowX = (_screenX + totalWidth) - viewport.Width;
                int overflowY = (_screenY + ButtonWidth) - viewport.Height;

                if (overflowX > 0)
                {
                    _screenX -= overflowX;
                }
                if (overflowY > 0)
                {
                    _screenY -= overflowY;
                }

                foreach (Button button in _buttons)
                {
                    button.CalculateScreenCoordinates();
                }
            }
        }