public void DrawTextWithDefaultFont(
     string text,
     Vec2 textPositionMin,
     Vec2 textPositionMax,
     Vec2 size,
     uint color,
     TextFlags flags)
 {
     EngineApplicationInterface.IMetaMesh.DrawTextWithDefaultFont(this.Pointer, text, textPositionMin, textPositionMax, size, color, flags);
 }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle, String initialLayoutStyle)
 {
     this.font               = font;
     this.width              = width;
     this.height             = height;
     this.flags              = (flags == 0) ? TextFlags.Standard : flags;
     this.style              = fontStyle;
     this.options            = options;
     this.initialLayoutStyle = initialLayoutStyle;
 }
Esempio n. 3
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.TableViewListItemReferenceTextFlags = ((TextFlags)(binaryReader.ReadInt32()));
     this.CellWidth       = binaryReader.ReadInt16();
     this.fieldpad        = binaryReader.ReadBytes(2);
     this.BitmapTopleft   = binaryReader.ReadPoint();
     this.BitmapTag       = binaryReader.ReadTagReference();
     this.StringId        = binaryReader.ReadStringID();
     this.RenderDepthBias = binaryReader.ReadInt16();
     this.fieldpad0       = binaryReader.ReadBytes(2);
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.TextReferenceTextFlags          = ((TextFlags)(binaryReader.ReadInt32()));
     this.AnimationIndex                  = ((AnimationIndexEnum)(binaryReader.ReadInt16()));
     this.IntroAnimationDelayMilliseconds = binaryReader.ReadInt16();
     this.fieldpad        = binaryReader.ReadBytes(2);
     this.CustomFont      = ((CustomFontEnum)(binaryReader.ReadInt16()));
     this.TextColor       = binaryReader.ReadVector4();
     this.TextBounds      = binaryReader.ReadVector2();
     this.StringId        = binaryReader.ReadStringID();
     this.RenderDepthBias = binaryReader.ReadInt16();
     this.fieldpad0       = binaryReader.ReadBytes(2);
     return(pointerQueue);
 }
Esempio n. 5
0
        public static void DrawString(Vector2 pos, Color color, TextFlags flags, string text)
        {
            bool center = (flags & TextFlags.TEXT_FLAG_CENTERED) == TextFlags.TEXT_FLAG_CENTERED;

            if ((flags & TextFlags.TEXT_FLAG_OUTLINED) == TextFlags.TEXT_FLAG_OUTLINED)
            {
                DrawStringInternal(pos + new Vector2(1f, 0f), Color.black, text, center);
                DrawStringInternal(pos + new Vector2(0f, 1f), Color.black, text, center);
                DrawStringInternal(pos + new Vector2(0f, -1f), Color.black, text, center);
            }
            if ((flags & TextFlags.TEXT_FLAG_DROPSHADOW) == TextFlags.TEXT_FLAG_DROPSHADOW)
            {
                DrawStringInternal(pos + new Vector2(1f, 1f), Color.black, text, center);
            }
            DrawStringInternal(pos, color, text, center);
        }
Esempio n. 6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
        /// </summary>
        /// <param name="font">The default font.</param>
        /// <param name="width">The width of the layout area.</param>
        /// <param name="height">The height of the layout area.</param>
        /// <param name="flags">A set of flags that specify how to render and align the text.</param>
        /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
        /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
        /// <param name="script">A value specifying which script is used to draw the text.</param>
        /// <param name="fontStyle">The initial font style.</param>
        /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
        /// <param name="language">The ISO 639 name of the text language.</param>
        public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script, UltravioletFontStyle fontStyle, String initialLayoutStyle, String language = "en")
        {
            if (direction == TextDirection.TopToBottom || direction == TextDirection.BottomToTop)
            {
                throw new NotSupportedException(UltravioletStrings.UnsupportedTextDirection);
            }

            this.Font               = font;
            this.Width              = width;
            this.Height             = height;
            this.Flags              = (flags == 0) ? TextFlags.Standard : flags;
            this.Style              = fontStyle;
            this.Direction          = direction;
            this.Script             = script;
            this.Options            = options;
            this.InitialLayoutStyle = initialLayoutStyle;
            this.Language           = language;
        }
        /// <summary>
        /// Adds a cell to the collection.
        /// </summary>
        /// <param name="format">The cell's format string.</param>
        /// <param name="text">The cell's text.</param>
        /// <param name="textFlags">The cell's text flags.</param>
        /// <param name="width">The cell's width in pixels, or <see langword="null"/> to automatically size the cell.</param>
        /// <param name="height">The cell's height in pixels, or <see langword="null"/> to automatically size the cell.</param>
        /// <returns>The cell that was added to the collection.</returns>
        public TextTableCell <ViewModelType> Add(String format, String text, TextFlags textFlags, Int32?width, Int32?height)
        {
            var cell = new TextTableCell <ViewModelType>(row)
            {
                Format    = format,
                RawText   = text,
                TextFlags = textFlags,
                Width     = width,
                Height    = height,
            };

            cell.Refresh();

            AddInternal(cell);
            row.Table.MarkDirty();

            return(cell);
        }
 /// <summary>
 /// Draws a text layout
 /// </summary>
 /// <param name="deviceContext">Device context</param>
 /// <param name="textLayout">Text layout to draw</param>
 /// <param name="origin">Draw origin</param>
 /// <param name="color">Text color</param>
 /// <param name="flags">Draw flags</param>
 /// <param name="transform">Transfomration matrix</param>
 public void DrawTextLayout(DeviceContext deviceContext, SharpDX.DirectWrite.TextLayout textLayout, Vector2 origin, Matrix transform, Color4 color, TextFlags flags)
 {
     this.DrawTextLayout(deviceContext, textLayout, origin.X, origin.Y, color.ToRgba(), IntPtr.Zero, new IntPtr(&transform), flags);
 }
        /// <summary>
        /// Draws a string using a transformation matrix
        /// </summary>
        /// <param name="deviceContext">A valid dirct3d11 device context</param>
        /// <param name="s">String to draw</param>
        /// <param name="fontSize">Font size</param>
        /// <param name="color">Color</param>
        /// <param name="flags">Draw flags</param>
        /// <param name="fontFamily">Font family</param>
        /// <param name="transform">A 3d transformation</param>
        /// <param name="clipRectangle">Optional clip rectangle</param>
        public void DrawString(DeviceContext deviceContext, string s, string fontFamily, float fontSize, Matrix transform, RectangleF?clipRectangle, Color4 color, TextFlags flags)
        {
            IntPtr     clipRectanglePtr = IntPtr.Zero;
            RectangleF clipRectRef;

            if (clipRectangle.HasValue)
            {
                clipRectRef      = clipRectangle.Value;
                clipRectanglePtr = new IntPtr(&clipRectRef);
            }
            this.DrawString(deviceContext, s, fontFamily, fontSize, SharpDX.RectangleF.Empty, color.ToRgba(), clipRectanglePtr, new IntPtr(&transform), flags);
        }
 /// <summary>
 /// Draws a text layout
 /// </summary>
 /// <param name="deviceContext">Device context</param>
 /// <param name="textLayout">Text layout to draw</param>
 /// <param name="origin">Draw origin</param>
 /// <param name="color">Text color</param>
 /// <param name="flags">Draw flags</param>
 public void DrawTextLayout(DeviceContext deviceContext, SharpDX.DirectWrite.TextLayout textLayout, Vector2 origin, Color4 color, TextFlags flags)
 {
     this.DrawTextLayout(deviceContext, textLayout, origin.X, origin.Y, color.ToRgba(), flags);
 }
 /// <summary>
 /// Adds a cell to the collection.
 /// </summary>
 /// <param name="format">The cell's format string.</param>
 /// <param name="text">The cell's text.</param>
 /// <param name="textFlags">The cell's text flags.</param>
 /// <returns>The cell that was added to the collection.</returns>
 public TextTableCell <ViewModelType> Add(String format, String text, TextFlags textFlags)
 {
     return(Add(format, text, textFlags, null, null));
 }
Esempio n. 12
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle)
     : this(font, width, height, flags, options, TextDirection.LeftToRight, TextScript.Unknown, fontStyle, null)
 {
 }
Esempio n. 13
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, UltravioletFontStyle fontStyle, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, fontStyle, initialLayoutStyle)
 {
 }
Esempio n. 14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, String initialLayoutStyle)
     : this(font, width, height, flags, options, UltravioletFontStyle.Regular, initialLayoutStyle)
 {
 }
Esempio n. 15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(SpriteFont font, Int32?width, Int32?height, TextFlags flags, SpriteFontStyle fontStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, fontStyle, null)
 {
 }
Esempio n. 16
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
 /// <param name="script">A value specifying which script is used to draw the text.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 /// <param name="language">The ISO 639 name of the text language.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script, String initialLayoutStyle, String language = "en")
     : this(font, width, height, flags, options, direction, script, UltravioletFontStyle.Regular, initialLayoutStyle, language)
 {
 }
Esempio n. 17
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(SpriteFont font, Int32? width, Int32? height, TextFlags flags, SpriteFontStyle fontStyle, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, fontStyle, initialLayoutStyle)
 {
 }
Esempio n. 18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(SpriteFont font, Int32? width, Int32? height, TextFlags flags, TextLayoutOptions options, SpriteFontStyle fontStyle)
     : this(font, width, height, flags, options, fontStyle, null)
 {
 }
Esempio n. 19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 public TextLayoutSettings(SpriteFont font, Int32? width, Int32? height, TextFlags flags)
     : this(font, width, height, flags, TextLayoutOptions.None, SpriteFontStyle.Regular)
 {
 }
Esempio n. 20
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(SpriteFont font, Int32? width, Int32? height, TextFlags flags, TextLayoutOptions options, SpriteFontStyle fontStyle, String initialLayoutStyle)
 {
     this.font = font;
     this.width = width;
     this.height = height;
     this.flags = (flags == 0) ? TextFlags.Standard : flags;
     this.style = fontStyle;
     this.options = options;
     this.initialLayoutStyle = initialLayoutStyle;
 }
Esempio n. 21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(SpriteFont font, Int32? width, Int32? height, TextFlags flags, TextLayoutOptions options, String initialLayoutStyle)
     : this(font, width, height, flags, options, SpriteFontStyle.Regular, initialLayoutStyle)
 {
 }
Esempio n. 22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="fontStyle">The initial font style.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, UltravioletFontStyle fontStyle, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, TextDirection.LeftToRight, TextScript.Unknown, fontStyle, initialLayoutStyle)
 {
 }
Esempio n. 23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 public TextLayoutSettings(SpriteFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options)
     : this(font, width, height, flags, options, SpriteFontStyle.Regular)
 {
 }
Esempio n. 24
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags)
     : this(font, width, height, flags, TextLayoutOptions.None, UltravioletFontStyle.Regular)
 {
 }
Esempio n. 25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="direction">A value indicating the direction in which the text should be laid out.</param>
 /// <param name="script">A value specifying which script is used to draw the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, TextDirection direction, TextScript script)
     : this(font, width, height, flags, options, direction, script, UltravioletFontStyle.Regular, null)
 {
 }
Esempio n. 26
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="options">A set of options which can be used to modify the behavior of the layout engine.</param>
 /// <param name="fontStyle">The initial font style.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags, TextLayoutOptions options, UltravioletFontStyle fontStyle)
     : this(font, width, height, flags, options, fontStyle, null)
 {
 }
 /// <summary>
 /// Draws a string
 /// </summary>
 /// <param name="deviceContext">A valid dirct3d11 device context</param>
 /// <param name="s">String to draw</param>
 /// <param name="fontSize">Font size</param>
 /// <param name="origin">Origin (top left)</param>
 /// <param name="color">Color</param>
 /// <param name="flags">Draw flags</param>
 public void DrawString(DeviceContext deviceContext, string s, float fontSize, Vector2 origin, Color4 color, TextFlags flags)
 {
     this.DrawString(deviceContext, s, fontSize, origin.X, origin.Y, color.ToRgba(), flags);
 }
Esempio n. 28
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 public TextLayoutSettings(UltravioletFont font, Int32?width, Int32?height, TextFlags flags)
     : this(font, width, height, flags, TextLayoutOptions.None, TextDirection.LeftToRight, TextScript.Unknown, UltravioletFontStyle.Regular, null)
 {
 }
        /// <summary>
        /// Draws a string using a transformation matrix
        /// </summary>
        /// <param name="deviceContext">A valid dirct3d11 device context</param>
        /// <param name="s">String to draw</param>
        /// <param name="fontSize">Font size</param>
        /// <param name="color">Color</param>
        /// <param name="flags">Draw flags</param>
        /// <param name="fontFamily">Font family</param>
        /// <param name="transform">A 3d transformation</param>
        public void DrawString(DeviceContext deviceContext, string s, string fontFamily, float fontSize, Matrix transform, Color4 color, TextFlags flags)
        {
            IntPtr clipRectanglePtr = IntPtr.Zero;

            SharpDX.Mathematics.Interop.RawRectangleF emptyRect = new SharpDX.Mathematics.Interop.RawRectangleF(0.0f, 0.0f, 0.0f, 0.0f);
            this.DrawString(deviceContext, s, fontFamily, fontSize, emptyRect, color.ToRgba(), IntPtr.Zero, new IntPtr(&transform), flags);
        }
Esempio n. 30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="TextLayoutSettings"/> structure.
 /// </summary>
 /// <param name="font">The default font.</param>
 /// <param name="width">The width of the layout area.</param>
 /// <param name="height">The height of the layout area.</param>
 /// <param name="flags">A set of flags that specify how to render and align the text.</param>
 /// <param name="initialLayoutStyle">The name of the initial layout style, or <see langword="null"/> to use no initial layout style.</param>
 public TextLayoutSettings(SpriteFont font, Int32?width, Int32?height, TextFlags flags, String initialLayoutStyle)
     : this(font, width, height, flags, TextLayoutOptions.None, SpriteFontStyle.Regular, initialLayoutStyle)
 {
 }
Esempio n. 31
0
        private void Render(DX11RenderContext context, DX11RenderSettings settings)
        {
            if (this.spreadMax == 0)
            {
                return;
            }

            if (this.FInEnabled[0])
            {
                float w = (float)settings.RenderWidth;
                float h = (float)settings.RenderHeight;

                if (shaprdxContext == null)
                {
                    shaprdxContext = new SharpDX.Direct3D11.DeviceContext(context.CurrentDeviceContext.ComPointer);
                }

                FontWrapper fw = this.FTextRenderer.IsConnected ? this.FTextRenderer[0][context].FontWrapper : FontWrapperFactory.GetWrapper(context, this.dwFactory);

                var renderStates = fw.RenderStates;

                float *rawMatPtr;
                int    transformCount;
                this.transformIn.GetMatrixPointer(out transformCount, out rawMatPtr);

                SharpDX.Matrix *matrixPointer = (SharpDX.Matrix *)rawMatPtr;

                bool applyState = this.FStateIn.IsConnected;

                var sView = settings.View;
                var sProj = settings.Projection;

                SharpDX.Matrix view       = *(SharpDX.Matrix *) & sView;
                SharpDX.Matrix projection = *(SharpDX.Matrix *) & sProj;

                var objectsettings = this.objectSettings[context];
                objectsettings.IterationCount = 1;
                objectsettings.Geometry       = null;

                for (int i = 0; i < this.spreadMax; i++)
                {
                    SharpDX.Matrix preScale = SharpDX.Matrix.Scaling(1.0f, -1.0f, 1.0f);

                    switch (this.FNormalizeInput[i].Index)
                    {
                    case 1: preScale = SharpDX.Matrix.Scaling(1.0f / w, -1.0f / w, 1.0f); break;

                    case 2: preScale = SharpDX.Matrix.Scaling(1.0f / h, -1.0f / h, 1.0f); break;

                    case 3: preScale = SharpDX.Matrix.Scaling(1.0f / w, -1.0f / h, 1.0f); break;
                    }
                    SharpDX.Matrix sm = matrixPointer[i % transformCount];

                    SharpDX.Matrix mat = SharpDX.Matrix.Multiply(preScale, sm);
                    mat = SharpDX.Matrix.Multiply(mat, view);
                    mat = SharpDX.Matrix.Multiply(mat, projection);

                    objectsettings.DrawCallIndex  = i;
                    objectsettings.WorldTransform = *(SlimDX.Matrix *) & mat;


                    if (settings.ValidateObject(objectsettings))
                    {
                        SlimDX.Color4 color = this.FInColor[i];
                        color.Alpha *= SharpDX.MathUtil.Clamp(settings.LayerOpacity, 0.0f, 1.0f);
                        SharpDX.Color4 sdxColor = *(SharpDX.Color4 *) & color;

                        TextFlags flag = TextFlags.NoWordWrapping;

                        if (this.FHorizontalAlignInput[i].Index == 0)
                        {
                            flag |= TextFlags.Left;
                        }
                        else if (this.FHorizontalAlignInput[i].Index == 1)
                        {
                            flag |= TextFlags.Center;
                        }
                        else if (this.FHorizontalAlignInput[i].Index == 2)
                        {
                            flag |= TextFlags.Right;
                        }

                        if (this.FVerticalAlignInput[i].Index == 0)
                        {
                            flag |= TextFlags.Top;
                        }
                        else if (this.FVerticalAlignInput[i].Index == 1)
                        {
                            flag |= TextFlags.VerticalCenter;
                        }
                        else if (this.FVerticalAlignInput[i].Index == 2)
                        {
                            flag |= TextFlags.Bottom;
                        }

                        string font = this.FFontInput[i].Name;

                        if (applyState)
                        {
                            renderStates.SetStates(shaprdxContext, 0);

                            context.RenderStateStack.Push(this.FStateIn[i]);

                            fw.DrawString(shaprdxContext, this.FInString[i], font, this.FInSize[i],
                                          mat, sdxColor, flag | TextFlags.StatePrepared);

                            context.RenderStateStack.Pop();
                        }
                        else
                        {
                            fw.DrawString(shaprdxContext, this.FInString[i], font, this.FInSize[i],
                                          mat, sdxColor, flag);
                        }
                    }
                }

                //Apply old states back
                context.RenderStateStack.Apply();
                context.CleanShaderStages();
            }
        }