コード例 #1
0
        public int AddTextWordWrapWithShadow(Component_Font font, double fontSize, string text, Rectangle rectangle, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
        {
            var renderer = ViewportControl.Viewport.CanvasRenderer;

            if (font == null || font.Disposed)
            {
                font = renderer.DefaultFont;
            }
            if (font == null || font.Disposed)
            {
                return(0);
            }
            //if( font == null )
            //	font = EditorFont;
            if (fontSize < 0)
            {
                fontSize = renderer.DefaultFontSize;
            }

            var items = font.GetWordWrapLines(fontSize, renderer, text, rectangle.Size.X);

            string[] lines = new string[items.Length];
            for (int n = 0; n < lines.Length; n++)
            {
                lines[n] = items[n].Text;
            }

            AddTextLinesWithShadow(font, fontSize, lines, rectangle, horizontalAlign, verticalAlign, color);

            return(lines.Length);
        }
コード例 #2
0
        //

        public static void AddTextWithShadow(Viewport viewport, Component_Font font, double fontSize, string text, Vector2 position, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
        {
            var renderer = viewport.CanvasRenderer;

            if (font == null || font.Disposed)
            {
                font = renderer.DefaultFont;
            }
            if (font == null || font.Disposed)
            {
                return;
            }
            if (fontSize < 0)
            {
                fontSize = renderer.DefaultFontSize;
            }

            Vector2 shadowOffset = shadowDistanceInPixels / viewport.SizeInPixels.ToVector2();

            renderer.AddText(font, fontSize, text, position + shadowOffset, horizontalAlign, verticalAlign, new ColorValue(0, 0, 0, color.Alpha / 2));
            renderer.AddText(font, fontSize, text, position, horizontalAlign, verticalAlign, color);
        }
コード例 #3
0
 public int AddTextWordWrapWithShadow(Component_Font font, double fontSize, string text, Rectangle rectangle, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
 {
     return(owner.AddTextWordWrapWithShadow(font, fontSize, text, rectangle, horizontalAlign, verticalAlign, color));
 }
コード例 #4
0
 public void AddTextLinesWithShadow(Component_Font font, double fontSize, IList <string> lines, Rectangle rectangle, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
 {
     owner.AddTextLinesWithShadow(font, fontSize, lines, rectangle, horizontalAlign, verticalAlign, color);
 }
コード例 #5
0
        ////public float FontSizeInPixels
        ////{
        ////	get { return fontSizeInPixels; }
        ////	set { fontSizeInPixels = value; }
        ////}

        ////public EngineFont EditorFont
        ////{
        ////	get { return editorFont; }
        ////}

        public void AddTextWithShadow(Component_Font font, double fontSize, string text, Vector2 position, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
        {
            owner.AddTextWithShadow(font, fontSize, text, position, horizontalAlign, verticalAlign, color);
        }
コード例 #6
0
        public void AddTextLinesWithShadow(Component_Font font, double fontSize, IList <string> lines, Rectangle rectangle, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color)
        {
            if (lines.Count == 0)
            {
                return;
            }

            var renderer = ViewportControl.Viewport.CanvasRenderer;

            if (font == null || font.Disposed)
            {
                font = renderer.DefaultFont;
            }
            if (font == null || font.Disposed)
            {
                return;
            }
            //if( font == null )
            //	font = EditorFont;
            if (fontSize < 0)
            {
                fontSize = renderer.DefaultFontSize;
            }

            Vector2 shadowOffset = shadowDistanceInPixels / ViewportControl.Viewport.SizeInPixels.ToVector2();
            float   linesHeight  = (float)lines.Count * (float)fontSize;

            double posY = 0;

            switch (verticalAlign)
            {
            case EVerticalAlignment.Top:
                posY = rectangle.Top;
                break;

            case EVerticalAlignment.Center:
                posY = rectangle.Top + (rectangle.Size.Y - linesHeight) / 2;
                break;

            case EVerticalAlignment.Bottom:
                posY = rectangle.Bottom - linesHeight;
                break;
            }

            for (int n = 0; n < lines.Count; n++)
            {
                string line = lines[n];

                double posX = 0;
                switch (horizontalAlign)
                {
                case EHorizontalAlignment.Left:
                    posX = rectangle.Left;
                    break;

                case EHorizontalAlignment.Center:
                    posX = rectangle.Left + (rectangle.Size.X - font.GetTextLength(fontSize, renderer, line)) / 2;
                    break;

                case EHorizontalAlignment.Right:
                    posX = rectangle.Right - font.GetTextLength(fontSize, renderer, line);
                    break;
                }

                Vector2 position = new Vector2(posX, posY);

                renderer.AddText(font, fontSize, line, position + shadowOffset, EHorizontalAlignment.Left, EVerticalAlignment.Top, new ColorValue(0, 0, 0, color.Alpha / 2));
                renderer.AddText(font, fontSize, line, position, EHorizontalAlignment.Left, EVerticalAlignment.Top, color);
                posY += fontSize;
            }
        }
コード例 #7
0
        public static void PerformRenderUI()
        {
            CanvasRenderer renderer = MainViewport.CanvasRenderer;

            if (transparency == 0.0f)
            {
                return;
            }

            //load backgrouund texture and font
            if (texture != null && texture.Disposed)
            {
                needLoadTextureAndFont = true;
            }
            if (needLoadTextureAndFont)
            {
                texture = ResourceManager.LoadResource <Component_Image>("Base\\UI\\Images\\Console.png");
                //texture = ResourceManager.LoadResource<Component_Image>( "Base\\UI\\Images\\Console.jpg" );

                font = renderer.DefaultFont;
                //font = EngineFontManager.Instance.LoadFont( "Default", .025f );
                needLoadTextureAndFont = false;
            }

            if (font == null)
            {
                return;
            }

            Vector2F viewportSize = renderer.ViewportForScreenCanvasRenderer.SizeInPixels.ToVector2F();
            Vector2F shadowOffset = new Vector2F(1, 1) / viewportSize;

            //draw background
            var textureRect = new Rectangle(0, 0, 10 * renderer.AspectRatio, 10 / 2);

            textureRect -= textureOffset;
            renderer.AddQuad(new Rectangle(0, 0, 1, .5f), textureRect, texture, new ColorValue(1, 1, 1, transparency), false);

            //var textureRect = new Rectangle( 0, 1.0 - renderer.AspectRatioInv, 1, 1 );
            //renderer.AddQuad( new Rectangle( 0, 0, 1, .5f ), textureRect, texture, new ColorValue( 0.7, 0.7, 0.7, transparency ), false );

            //draw border line
            renderer.AddQuad(new Rectangle(0, .5f, 1, .508f), new ColorValue(0.29f, 0.6f, 0.86f, 0.9f * transparency));

            //draw background info
            string staticText = "Press \"~\" or \"F12\" to hide console\r\nPress \"Ctrl + ~\" to hide and disable auto opening";

            renderer.AddTextWordWrap(staticText, new RectangleF(0, 0, .995f, .495f), EHorizontalAlignment.Right, false, EVerticalAlignment.Bottom, 0,
                                     new ColorValue(0.8, 0.8, 0.8, transparency));

            float fontheight = (float)fontSize;            // font.Height;

            float x = .01f;

            float y = .5f - fontheight;

            string str;

            if (stringDownPosition != strings.Count - 1)
            {
                str = "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -" +
                      " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -";
            }
            else
            {
                str = currentString + "_";
            }

            renderer.PushClipRectangle(new RectangleF(0, 0, .975f, 1));
            renderer.AddText(font, fontSize, str, new Vector2F(x, y) + shadowOffset, EHorizontalAlignment.Left,
                             EVerticalAlignment.Center, new ColorValue(0, 0, 0, transparency / 2));
            renderer.AddText(font, fontSize, str, new Vector2F(x, y), EHorizontalAlignment.Left,
                             EVerticalAlignment.Center, new ColorValue(1, 1, 1, transparency));
            renderer.PopClipRectangle();

            y -= fontheight + fontheight * .5f;

            int startpos = stringDownPosition;

            if (startpos > strings.Count - 1)
            {
                startpos = strings.Count - 1;
            }
            for (int n = startpos; n >= 0 && y - fontheight > 0; n--)
            {
                var text      = strings[n].text;
                int lineCount = text.Count(f => f == '\n') + 1;

                float y2 = y - fontheight * (lineCount - 1) / 2;

                renderer.AddText(font, fontSize, text, new Vector2F(x, y2) + shadowOffset, EHorizontalAlignment.Left,
                                 EVerticalAlignment.Center, strings[n].color * new ColorValue(0, 0, 0, transparency / 2));
                renderer.AddText(font, fontSize, text, new Vector2F(x, y2), EHorizontalAlignment.Left,
                                 EVerticalAlignment.Center, strings[n].color * new ColorValue(1, 1, 1, transparency));
                y -= fontheight * lineCount;
            }
        }
コード例 #8
0
 public int AddTextWordWrap(Component_Font font, double fontSize, string text, Rectangle rect, EHorizontalAlignment horizontalAlign,
                            bool alignByWidth, EVerticalAlignment verticalAlign, double textVerticalIndention, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign)
 {
     return(AddTextWordWrap(font, DefaultFontSize, text, rect.ToRectangleF(), horizontalAlign, alignByWidth, verticalAlign, (float)textVerticalIndention, color, options));
 }
コード例 #9
0
        /////////////////////////////////////////

        public abstract int AddTextWordWrap(Component_Font font, double fontSize, string text, RectangleF rect, EHorizontalAlignment horizontalAlign,
                                            bool alignByWidth, EVerticalAlignment verticalAlign, float textVerticalIndention, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign);
コード例 #10
0
 /// <summary>
 /// Adds text lines to rendering queue.
 /// </summary>
 /// <param name="font">The font.</param>
 /// <param name="lines">The text lines.</param>
 /// <param name="pos">The text position.</param>
 /// <param name="horizontalAlign">The text horizontal align.</param>
 /// <param name="verticalAlign">The text vertical align.</param>
 /// <param name="textVerticalIndention">The vertical intention between lines.</param>
 /// <param name="color">The text color.</param>
 public void AddTextLines(Component_Font font, double fontSize, IList <string> lines, Vector2 pos, EHorizontalAlignment horizontalAlign,
                          EVerticalAlignment verticalAlign, double textVerticalIndention, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign)
 {
     AddTextLines(font, fontSize, lines, pos.ToVector2F(), horizontalAlign, verticalAlign, (float)textVerticalIndention, color, options);
 }
コード例 #11
0
        /////////////////////////////////////////

        /// <summary>
        /// Adds text lines to rendering queue.
        /// </summary>
        /// <param name="font">The font.</param>
        /// <param name="lines">The text lines.</param>
        /// <param name="pos">The text position.</param>
        /// <param name="horizontalAlign">The text horizontal align.</param>
        /// <param name="verticalAlign">The text vertical align.</param>
        /// <param name="textVerticalIndention">The vertical intention between lines.</param>
        /// <param name="color">The text color.</param>
        public abstract void AddTextLines(Component_Font font, double fontSize, IList <string> lines, Vector2F pos, EHorizontalAlignment horizontalAlign,
                                          EVerticalAlignment verticalAlign, float textVerticalIndention, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign);
コード例 #12
0
 /// <summary>
 /// Adds text to rendering queue.
 /// </summary>
 /// <param name="font">The text font.</param>
 /// <param name="text">The text.</param>
 /// <param name="position">The text position.</param>
 /// <param name="horizontalAlign">The text horizontal align.</param>
 /// <param name="verticalAlign">The text vertical align.</param>
 /// <param name="color">The text color.</param>
 public void AddText(Component_Font font, double fontSize, string text, Vector2 position, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign)
 {
     AddText(font, fontSize, text, position.ToVector2F(), horizontalAlign, verticalAlign, color, options);
 }
コード例 #13
0
 /// <summary>
 /// Adds text to rendering queue.
 /// </summary>
 /// <param name="font">The text font.</param>
 /// <param name="text">The text.</param>
 /// <param name="position">The text position.</param>
 /// <param name="horizontalAlign">The text horizontal align.</param>
 /// <param name="verticalAlign">The text vertical align.</param>
 /// <param name="color">The text color.</param>
 public abstract void AddText(Component_Font font, double fontSize, string text, Vector2F position, EHorizontalAlignment horizontalAlign, EVerticalAlignment verticalAlign, ColorValue color, AddTextOptions options = AddTextOptions.PixelAlign);