private void UpdateFont()
    {
        FontPackage p = fontPackages[selectedFont];

        textMaterial.mainTexture = useDistanceMap ? p.distanceMap : p.atlas;
        text.Font = p.font;
    }
Esempio n. 2
0
        private void DeleteFont_Click(object sender, MouseEventArgs e)
        {
            FontPackage fontp = (FontPackage)((StackPanel)((Control)sender).Tag).Tag;

            data.FontManager.Remove(fontp);

            AddFonts();
            FontWorker.LoadFonts(data);
        }
        public override void LoadContent()
        {
            base.LoadContent();
            _spriteBatch = new SpriteBatch(GraphicsDevice);
            _background  = Content.Load <Texture2D>("Images/MenuBackground");

            //Load font range for scaling.
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-20"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-22"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-24"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-26"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-28"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-30"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-32"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-34"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-36"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-38"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-40"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-42"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-44"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-46"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-48"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-50"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-52"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-54"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-56"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-58"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-60"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-62"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-64"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-66"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-68"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-70"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-72"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-74"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-76"));
            _fontList.Add(Content.Load <BitmapFont>("Fonts/arial-78"));

            fontPackage = FontHelper.GetFont(_fontList, proposedTextHeight, GraphicsDevice.Viewport.Bounds);

            newGame = FontHelper.SetTextBoxPosition(newGame, fontPackage, GraphicsDevice.Viewport.Bounds, VerticalPosition.Centered, 0f, HorizontalPosition.Centered, 0f);

            RectangleF newGameRectangle     = fontPackage.Font.GetStringRectangle(newGame.Value);
            float      centerPointNewGame   = GraphicsDevice.Viewport.Bounds.Width / 2f - (newGameRectangle.Width / 2f);
            float      verticalPointNewGame = GraphicsDevice.Viewport.Bounds.Height * 0.25f;

            newGame.Location          = new Vector2(centerPointNewGame, verticalPointNewGame);
            newGameRectangle.Position = new Point2(newGame.Location.X, newGame.Location.Y);
            newGame.BoundingBox       = newGameRectangle;

            RectangleF loadGameRectangle     = fontPackage.Font.GetStringRectangle(loadGame.Value);
            float      centerPointLoadGame   = GraphicsDevice.Viewport.Bounds.Width / 2f - (loadGameRectangle.Width / 2f);
            float      verticalPointLoadGame = verticalPointNewGame + (newGame.BoundingBox.Height * 1.5f);

            loadGame.Location = new Vector2(centerPointLoadGame, verticalPointLoadGame);

            RectangleF optionsRectangle     = fontPackage.Font.GetStringRectangle(options.Value);
            float      centerPointOptions   = GraphicsDevice.Viewport.Bounds.Width / 2f - (optionsRectangle.Width / 2f);
            float      verticalPointOptions = verticalPointLoadGame + (newGame.BoundingBox.Height * 1.5f);

            options.Location = new Vector2(centerPointOptions, verticalPointOptions);

            RectangleF exitRectangle     = fontPackage.Font.GetStringRectangle(exit.Value);
            float      centerPointExit   = GraphicsDevice.Viewport.Bounds.Width / 2f - (exitRectangle.Width / 2f);
            float      verticalPointExit = verticalPointOptions + (newGame.BoundingBox.Height * 1.5f);

            exit.Location          = new Vector2(centerPointExit, verticalPointExit);
            exitRectangle.Position = new Point2(exit.Location.X, exit.Location.Y);
            exit.BoundingBox       = exitRectangle;
        }