public override void LoadContent() { base.LoadContent(); LoadOptions(); Viewport viewport = Framework.GraphicsDevice.Viewport; _font = ContentWrapper.GetFont("MenuFont"); _checkmark = ContentWrapper.GetTexture("Checkmark"); _optionStart = (viewport.Height - (_optionEntries.Count - 1) * (_optionEntrySize.Y + EntrySpacer)) / 2f; _optionSpacing = _optionEntrySize.Y + EntrySpacer; for (int i = 0; i < _optionEntries.Count; i++) { _optionEntries[i].InitializePosition(new Vector2(viewport.Width / 2f, _optionStart + _optionSpacing * i)); } // The background includes a border somewhat larger than the text itself. _topLeft.X = viewport.Width / 2f - _optionEntrySize.X / 2f - HorizontalPadding; _topLeft.Y = _optionStart - _optionEntrySize.Y / 2f - VerticalPadding; _bottomRight.X = viewport.Width / 2f + _optionEntrySize.X / 2f + HorizontalPadding; _bottomRight.Y = _optionStart + (_optionEntries.Count - 1) * _optionSpacing + _optionEntrySize.Y / 2f + VerticalPadding; }
/// <summary> /// Constructs a new option entry with the specified text. /// </summary> public OptionEntry(string text, bool isChecked) { Text = text; IsChecked = isChecked; _hoverFade = 0.0; _checkedFade = 0.0; SpriteFont font = ContentWrapper.GetFont("MenuFont"); Size = font.MeasureString(text); }
/// <summary> /// Constructs a new menu entry with the specified text. /// </summary> public MenuEntry(string text, PhysicsDemoScreen screen, Texture2D preview) { Text = text; _screen = screen; Preview = preview; _hoverFade = 0.0; _selectionFade = 0.0; SpriteFont font = ContentWrapper.GetFont("MenuFont"); Size = font.MeasureString(text); }
/// <summary> /// Loads graphics content for this screen. This uses the shared ContentManager /// provided by the Game class, so the content will remain loaded forever. /// Whenever a subsequent MessageBoxScreen tries to load this same content, /// it will just get back another reference to the already loaded data. /// </summary> public override void LoadContent() { _font = ContentWrapper.GetFont("DetailsFont"); // Center the message text in the viewport. Viewport viewport = Framework.GraphicsDevice.Viewport; Vector2 viewportSize = new Vector2(viewport.Width, viewport.Height); Vector2 textSize = _font.MeasureString(_message); _textPosition = (viewportSize - textSize) / 2; // The background includes a border somewhat larger than the text itself. _topLeft.X = _textPosition.X - HorizontalPadding; _topLeft.Y = _textPosition.Y - VerticalPadding; _bottomRight.X = _textPosition.X + textSize.X + HorizontalPadding; _bottomRight.Y = _textPosition.Y + textSize.Y + VerticalPadding; base.LoadContent(); }
public override void LoadContent() { base.LoadContent(); Viewport viewport = Framework.GraphicsDevice.Viewport; _font = ContentWrapper.GetFont("MenuFont"); _samplesLogo = ContentWrapper.GetTexture("SamplesLogo"); _titleOrigin = new Vector2(_samplesLogo.Width, _samplesLogo.Height) / 2f; _titlePosition = new Vector2(viewport.Width / 2f, TitleBarHeight / 2f); float horizontalSpacing = (viewport.Width / 2f - _menuEntrySize.X - EntrySpacer - _menuEntrySize.Y) / 3f; float verticalSpacing = (viewport.Height - TitleBarHeight - NumEntries * (_menuEntrySize.Y + EntrySpacer) + EntrySpacer) / 2f; _previewOrigin = new Vector2(viewport.Width / 4f, viewport.Height / 4f); PreviewPosition = new Vector2(viewport.Width - _previewOrigin.X - horizontalSpacing, (viewport.Height - TitleBarHeight) / 2f + TitleBarHeight); _menuStart = _menuEntrySize.Y / 2f + verticalSpacing + TitleBarHeight; _menuSpacing = _menuEntrySize.Y + EntrySpacer; _menuEntries.Sort(); MenuEntry.InitializeEntries(-_menuEntrySize.X / 2f, _menuEntrySize.X / 2f + horizontalSpacing); for (int i = 0; i < _menuEntries.Count; i++) { _menuEntries[i].InitializePosition(_menuStart + _menuSpacing * i, i < NumEntries); } _menuSlider = new MenuSlider(new Vector2(_menuEntrySize.X + horizontalSpacing + EntrySpacer + _menuEntrySize.Y / 2f, _menuStart)); if (_menuEntries.Count > NumEntries) { _scrollSpacing = _menuSpacing * (NumEntries - 1) / (_menuEntries.Count - NumEntries); } else { _scrollSpacing = 0f; } _scrollHover = false; _scrollLock = false; }
public void LoadContent() { _font = ContentWrapper.GetFont("DetailsFont"); }