示例#1
0
        public override void LoadContent()
        {
            base.LoadContent();

            Viewport   viewport = ScreenManager.GraphicsDevice.Viewport;
            SpriteFont font     = ScreenManager.Fonts.MenuSpriteFont;

            _texScrollButton = ScreenManager.Content.Load <Texture2D>("Common/arrow");
            _texSlider       = ScreenManager.Content.Load <Texture2D>("Common/slider");

            float scrollBarPos = viewport.Width / 2f;

            for (int i = 0; i < _menuEntries.Count; ++i)
            {
                _menuEntries[i].Initialize();
                scrollBarPos = Math.Min(scrollBarPos,
                                        (viewport.Width - _menuEntries[i].GetWidth()) / 2f);
            }
            scrollBarPos -= _texScrollButton.Width + 2f;

            _titleOrigin   = font.MeasureString(_menuTitle) / 2f;
            _titlePosition = new Vector2(viewport.Width / 2f, font.MeasureString("M").Y / 2f + 10f);

            _menuBorderMargin = font.MeasureString("M").Y * 0.8f;
            _menuBorderTop    = (viewport.Height - _menuBorderMargin * (NumEntries - 1)) / 2f;
            _menuBorderBottom = (viewport.Height + _menuBorderMargin * (NumEntries - 1)) / 2f;

            _menuOffset = 0f;
            _maxOffset  = Math.Max(0f, (_menuEntries.Count - NumEntries) * _menuBorderMargin);

            _scrollUp = new MenuButton(_texScrollButton, false,
                                       new Vector2(scrollBarPos, _menuBorderTop - _texScrollButton.Height), this);
            _scrollDown = new MenuButton(_texScrollButton, true,
                                         new Vector2(scrollBarPos, _menuBorderBottom + _texScrollButton.Height), this);
            _scrollSlider = new MenuButton(_texSlider, false, new Vector2(scrollBarPos, _menuBorderTop), this);

            _scrollLock = false;
        }
示例#2
0
        public override void LoadContent()
        {
            base.LoadContent();

            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            SpriteFont font = ScreenManager.Fonts.MenuSpriteFont;

            _texScrollButton = ScreenManager.Content.Load<Texture2D>("Common/arrow");
            _texSlider = ScreenManager.Content.Load<Texture2D>("Common/slider");

            float scrollBarPos = viewport.Width / 2f;
            for (int i = 0; i < _menuEntries.Count; ++i)
            {
                _menuEntries[i].Initialize();
                scrollBarPos = Math.Min(scrollBarPos,
                                         (viewport.Width - _menuEntries[i].GetWidth()) / 2f);
            }
            scrollBarPos -= _texScrollButton.Width + 2f;

            _titleOrigin = font.MeasureString(_menuTitle) / 2f;
            _titlePosition = new Vector2(viewport.Width / 2f, font.MeasureString("M").Y / 2f + 10f);

            _menuBorderMargin = font.MeasureString("M").Y * 0.8f;
            _menuBorderTop = (viewport.Height - _menuBorderMargin * (NumEntries - 1)) / 2f;
            _menuBorderBottom = (viewport.Height + _menuBorderMargin * (NumEntries - 1)) / 2f;

            _menuOffset = 0f;
            _maxOffset = Math.Max(0f, (_menuEntries.Count - NumEntries) * _menuBorderMargin);

            _scrollUp = new MenuButton(_texScrollButton, false,
                                       new Vector2(scrollBarPos, _menuBorderTop - _texScrollButton.Height), this);
            _scrollDown = new MenuButton(_texScrollButton, true,
                                         new Vector2(scrollBarPos, _menuBorderBottom + _texScrollButton.Height), this);
            _scrollSlider = new MenuButton(_texSlider, false, new Vector2(scrollBarPos, _menuBorderTop), this);

            _scrollLock = false;
        }
示例#3
0
        public override void LoadContent()
        {
            base.LoadContent();

            Viewport viewport = ScreenManager.GraphicsDevice.Viewport;
            SpriteFont font = ScreenManager.Fonts.MenuSpriteFont;

            _menuItemMarginTop = font.MeasureString("M").Y;
            _bgColor = Color.White;

            DestinationRectangle = new Rectangle(0, 0, viewport.Width, viewport.Height);

            _texScrollButton = ScreenManager.Content.Load<Texture2D>("Common/arrow");
            _texSlider = ScreenManager.Content.Load<Texture2D>("Common/scroller");
            _background = ScreenManager.Content.Load<Texture2D>("Backgrounds/MenuBG");

            _rectBG = new Rectangle(0, 0, _background.Width, _background.Height);

            //////////////////////////////////////
            //Loas these only if we have a score
            //section
            //////////////////////////////////////
            if (_scoreSection != null)
            {
                _scoreSection.Load();
            }

            float scrollBarPos = viewport.Width / 2f;
            for (int i = 0; i < _menuEntries.Count; ++i)
            {
                _menuEntries[i].Initialize();
                scrollBarPos = Math.Min(scrollBarPos,
                                         (viewport.Width - _menuEntries[i].GetWidth())/3);
            }
            scrollBarPos -= _texScrollButton.Width;

            _titleOrigin = font.MeasureString(_menuTitle) / 2f;
            TitleWidth = font.MeasureString("M").Y / 2f + 20f;
            UpdateTitlePosition(viewport);

            _menuBorderMargin = font.MeasureString("M").Y +_menuItemMarginTop + 100;
            _menuBorderTop = (_menuBorderMargin);
            _scrollSliderPosition = new Vector2(scrollBarPos, _menuBorderTop + 20);
            _menuBorderBottom = (viewport.Height - _menuBorderMargin);

            _menuOffset = 0f;
            _maxOffset = Math.Max(0f, ((_menuEntries.Count - 4) * _menuBorderMargin));

            _scrollUp = new MenuButton(_texScrollButton, false,
                                       new Vector2(scrollBarPos, _menuBorderTop - _texScrollButton.Height), this);
            _scrollDown = new MenuButton(_texScrollButton, true,
                                         new Vector2(scrollBarPos, _menuBorderBottom + _texScrollButton.Height), this);
            _scrollSlider = new MenuButton(_texSlider, false, _scrollSliderPosition, this);

            _scrollLock = false;
        }