MenuFont() public static méthode

public static MenuFont ( IScreen screen ) : SpriteFont
screen IScreen
Résultat Microsoft.Xna.Framework.Graphics.SpriteFont
Exemple #1
0
        public override void Draw(GameTime time)
        {
            base.Draw(time);

            if (IsVisible)
            {
                spriteBatch.Begin();

                // zeichne den Hintergrund
                spriteBatch.DrawColoredRectangle(BackgroundColor, Bounds);

                if (BackgroundTexture != null)
                {
                    spriteBatch.Draw(BackgroundTexture, Bounds, Color.White);
                }

                // lade die Schrift
                SpriteFont font = Design.MenuFont(Screen);

                // zeichne die Schrift
                Color foreground = ForegroundColor * (IsEnabled ? 1f : 0.5f);
                if (IsLocalized)
                {
                    spriteBatch.DrawStringInRectangle(font, name.Localize(), foreground, Bounds, AlignX, AlignY);
                }
                else
                {
                    spriteBatch.DrawStringInRectangle(font, name, foreground, Bounds, AlignX, AlignY);
                }

                spriteBatch.End();
            }
        }
Exemple #2
0
        public override void Draw(GameTime time)
        {
            base.Draw(time);

            if (IsVisible)
            {
                spriteBatch.Begin();

                // zeichne den Hintergrund
                spriteBatch.DrawColoredRectangle(BackgroundColor, Bounds);

                // lade die Schrift
                SpriteFont font = Design.MenuFont(Screen);

                // zeichne die Schrift
                Color   foreground = ForegroundColor * (IsEnabled ? 1f : 0.5f);
                Vector2 scale      = new Vector2(0.15f, 0.15f)            // Standard-Skalierung ist 10%
                                     / new Vector2(800, 600)              // bei 800x600
                                     * Screen.Bounds.Size.AbsoluteVector; // Auf aktuelle Auflösung hochrechnen
                string wrappedText = parseText(Text, scale);
                spriteBatch.DrawScaledString(font, wrappedText, foreground, Bounds.Position, scale);

                spriteBatch.End();
            }
        }
Exemple #3
0
        private String parseText(String text, Vector2 scale)
        {
            // lade die Schrift
            SpriteFont font = Design.MenuFont(Screen);
            // berechne die Skalierung der schrift
            //spriteBatch.DrawStringInRectangle (font, parseText (Text), foreground, Bounds, AlignX, AlignY);

            String line         = String.Empty;
            String returnString = String.Empty;

            String[] wordArray = Regex.Split(text, @"(?<=[.,; !])");

            foreach (String word in wordArray)
            {
                if ((font.MeasureString(line + word) * scale).X > Bounds.Rectangle.Width)
                {
                    returnString = returnString + line + '\n';
                    line         = String.Empty;
                }

                line = line + word;
            }

            return(returnString + line);
        }
Exemple #4
0
        public override void Draw(GameTime time)
        {
            base.Draw(time);

            if (IsVisible)
            {
                spriteBatch.Begin();

                // berechne die Ausmaße des Eingabefelds
                Bounds bounds = ValueBounds;

                // zeichne den Hintergrund des Eingabefelds
                spriteBatch.DrawColoredRectangle(ForegroundColor, bounds);
                Color backgroundColor = IsInputEnabled ? Design.WidgetBackground.Mix(Design.WidgetForeground, 0.25f) : Design.WidgetBackground;
                spriteBatch.DrawColoredRectangle(backgroundColor, bounds.Shrink(xy: 2));

                // lade die Schrift
                SpriteFont font = Design.MenuFont(Screen);

                // zeichne die Schrift
                spriteBatch.DrawStringInRectangle(
                    font: font,
                    text: InputText,
                    color: ForegroundColor,
                    bounds: bounds.Shrink(x: 4, y: 2),
                    alignX: HorizontalAlignment.Left,
                    alignY: AlignY
                    );

                spriteBatch.End();
            }
        }
Exemple #5
0
        public override void Draw(GameTime time)
        {
            base.Draw(time);

            spriteBatch.Begin();

            // zeichne den Hintergrund
            spriteBatch.DrawColoredRectangle(BackgroundColor, Bounds);

            // lade die Schrift
            SpriteFont font = Design.MenuFont(Screen);

            // zeichne den Titel des Dialogs
            spriteBatch.DrawColoredRectangle(TitleBackgroundColor(), TitleBounds);
            spriteBatch.DrawStringInRectangle(font, Title.Localize(), TitleForegroundColor(), TitleBounds, AlignX, AlignY);

            spriteBatch.End();
        }