Beispiel #1
0
            public TextRenderer(LWF lwf, TextContext context) : base(lwf)
            {
                m_context      = context;
                m_matrix       = new Matrix4x4();
                m_renderMatrix = new Matrix4x4();
                m_colorMult    = new UnityEngine.Color();
#if LWF_USE_ADDITIONALCOLOR
                m_colorAdd = new UnityEngine.Color();
#endif
                if (m_context.systemFontRenderer != null)
                {
                    ISystemFontRenderer.Parameter p =
                        context.systemFontRendererParameter;
                    float scale = lwf.scaleByStage;
                    m_context.systemFontRenderer.Init(
                        p.mSize * scale,
                        p.mWidth * scale,
                        p.mHeight * scale,
                        p.mStyle,
                        p.mAlign,
                        p.mVerticalAlign,
                        p.mLineSpacing * scale,
                        p.mLetterSpacing * scale,
                        p.mLeftMargin * scale,
                        p.mRightMargin * scale);
                }
            }
Beispiel #2
0
            public TextRenderer(LWF lwf, TextContext context) : base(lwf)
            {
                m_context      = context;
                m_matrix       = new Matrix4x4();
                m_renderMatrix = new Matrix4x4();
                m_colorMult    = new UnityEngine.Color();
#if LWF_USE_ADDITIONALCOLOR
                m_colorAdd = new UnityEngine.Color();
#endif
                if (m_context != null && m_context.systemFontRenderer != null)
                {
                    ISystemFontRenderer.Parameter p =
                        context.systemFontRendererParameter;
                    float scale = lwf.scaleByStage;
                    m_context.systemFontRenderer.Init(
                        p.mSize * scale,
                        p.mWidth * scale,
                        p.mHeight * scale,
                        p.mStyle,
                        p.mAlign,
                        p.mVerticalAlign,
                        p.mLineSpacing * scale,
                        p.mLetterSpacing * scale,
                        p.mLeftMargin * scale,
                        p.mRightMargin * scale);
                }

                CombinedMeshRenderer.Factory factory =
                    lwf.rendererFactory as CombinedMeshRenderer.Factory;
                if (factory != null)
                {
                    m_shouldBeOnTop = true;
                    m_zOffset       = Mathf.Abs(factory.zRate);
                }
            }
Beispiel #3
0
            public UnityTextRenderer(LWF lwf, int objectId) : base(lwf)
            {
                Factory factory = lwf.rendererFactory as Factory;

                m_context = new TextContext(
                    factory, factory.gameObject, lwf.data, objectId);
                m_matrix       = new Matrix4x4();
                m_renderMatrix = new Matrix4x4();
                m_colorMult    = new UnityEngine.Color();
                m_colorAdd     = new UnityEngine.Color();
                if (m_context != null && m_context.systemFontRenderer != null)
                {
                    ISystemFontRenderer.Parameter p =
                        m_context.systemFontRendererParameter;
                    float scale = lwf.scaleByStage;
                    m_context.systemFontRenderer.Init(
                        p.mSize * scale,
                        p.mWidth * scale,
                        p.mHeight * scale,
                        p.mStyle,
                        p.mAlign,
                        p.mVerticalAlign,
                        p.mLineSpacing * scale,
                        p.mLetterSpacing * scale,
                        p.mLeftMargin * scale,
                        p.mRightMargin * scale);
                }

                CombinedMeshRenderer.Factory c =
                    lwf.rendererFactory as CombinedMeshRenderer.Factory;
                if (c != null)
                {
                    m_shouldBeOnTop = true;
                    m_zOffset       = Mathf.Abs(c.zRate);
                }
            }
Beispiel #4
0
            public TextContext(Factory f, GameObject p, Data data, Format.Text text)
            {
                factory = f;
                parent = p;

                Format.TextProperty textProperty =
                data.textProperties[text.textPropertyId];
                Format.Font fontProperty = data.fonts[textProperty.fontId];
                color = factory.ConvertColor(data.colors[text.colorId]);

                string str = data.strings[text.stringId];
                string fontName = data.strings[fontProperty.stringId];
                string fontPath = factory.fontPrefix + fontName;
                float fontHeight = (float)textProperty.fontHeight;
                float width = (float)text.width;
                float height = (float)text.height;
                float lineSpacing = 1.0f + (float)textProperty.leading / fontHeight;
                float letterSpacing = (float)fontProperty.letterspacing / fontHeight;
                float tabSpacing = 4.0f;
                float leftMargin = textProperty.leftMargin / fontHeight;
                float rightMargin = textProperty.rightMargin / fontHeight;

                if (fontName.StartsWith("_")) {

                ISystemFontRenderer.Style style = ISystemFontRenderer.Style.NORMAL;

                ISystemFontRenderer.Align align;
                int a = textProperty.align & (int)Align.ALIGN_MASK;
                switch (a) {
                default:
                case (int)Align.LEFT:
                align = ISystemFontRenderer.Align.LEFT;   break;
                case (int)Align.RIGHT:
                align = ISystemFontRenderer.Align.RIGHT;  break;
                case (int)Align.CENTER:
                align = ISystemFontRenderer.Align.CENTER; break;
                }

                ISystemFontRenderer.VerticalAlign valign;
                int va = textProperty.align & (int)Align.VERTICAL_MASK;
                switch (va) {
                default:
                valign = ISystemFontRenderer.VerticalAlign.TOP;
                break;
                case (int)Align.VERTICAL_BOTTOM:
                valign = ISystemFontRenderer.VerticalAlign.BOTTOM;
                break;
                case (int)Align.VERTICAL_MIDDLE:
                valign = ISystemFontRenderer.VerticalAlign.MIDDLE;
                break;
                }

                systemFontRendererParameter = new ISystemFontRenderer.Parameter(
                fontHeight, width, height, style, align, valign, lineSpacing,
                letterSpacing, leftMargin, rightMargin);
                systemFontRenderer = ISystemFontRenderer.Construct();
                systemFontRenderer.SetText(str, color);

                } else {

                BitmapFont.Renderer.Align align;
                int a = textProperty.align & (int)Align.ALIGN_MASK;
                switch (a) {
                default:
                case (int)Align.LEFT:
                align = BitmapFont.Renderer.Align.LEFT;   break;
                case (int)Align.RIGHT:
                align = BitmapFont.Renderer.Align.RIGHT;  break;
                case (int)Align.CENTER:
                align = BitmapFont.Renderer.Align.CENTER; break;
                }

                BitmapFont.Renderer.VerticalAlign valign;
                int va = textProperty.align & (int)Align.VERTICAL_MASK;
                switch (va) {
                default:
                valign = BitmapFont.Renderer.VerticalAlign.TOP;
                break;
                case (int)Align.VERTICAL_BOTTOM:
                valign = BitmapFont.Renderer.VerticalAlign.BOTTOM;
                break;
                case (int)Align.VERTICAL_MIDDLE:
                valign = BitmapFont.Renderer.VerticalAlign.MIDDLE;
                break;
                }

                bitmapFontRenderer = new BitmapFont.Renderer(fontPath,
                fontHeight,
                width,
                height,
                align,
                valign,
                0.25f,
                lineSpacing,
                letterSpacing,
                tabSpacing,
                leftMargin,
                rightMargin);
                bitmapFontRenderer.SetText(str, color);

                }
            }
Beispiel #5
0
            public TextContext(Factory f, GameObject p, Data data, int objectId)
            {
                factory = f;
                parent  = p;

                Format.Text         text         = data.texts[objectId];
                Format.TextProperty textProperty =
                    data.textProperties[text.textPropertyId];
                Format.Font fontProperty = data.fonts[textProperty.fontId];
                color = factory.ConvertColor(data.colors[text.colorId]);

                string fontName      = data.strings[fontProperty.stringId];
                string fontPath      = factory.fontPrefix + fontName;
                float  fontHeight    = (float)textProperty.fontHeight;
                float  width         = (float)text.width;
                float  height        = (float)text.height;
                float  lineSpacing   = 1.0f + (float)textProperty.leading / fontHeight;
                float  letterSpacing = fontProperty.letterspacing;
                float  tabSpacing    = 4.0f;
                float  leftMargin    = textProperty.leftMargin / fontHeight;
                float  rightMargin   = textProperty.rightMargin / fontHeight;

                if (fontName.StartsWith("_"))
                {
                    ISystemFontRenderer.Style style;
                    if (fontName == "_bold")
                    {
                        style = ISystemFontRenderer.Style.BOLD;
                    }
                    else if (fontName == "_italic")
                    {
                        style = ISystemFontRenderer.Style.ITALIC;
                    }
                    else if (fontName == "_bold_italic")
                    {
                        style = ISystemFontRenderer.Style.BOLD_ITALIC;
                    }
                    else
                    {
                        style = ISystemFontRenderer.Style.NORMAL;
                    }

                    ISystemFontRenderer.Align align;
                    int a = textProperty.align & (int)Align.ALIGN_MASK;
                    switch (a)
                    {
                    default:
                    case (int)Align.LEFT:
                        align = ISystemFontRenderer.Align.LEFT;   break;

                    case (int)Align.RIGHT:
                        align = ISystemFontRenderer.Align.RIGHT;  break;

                    case (int)Align.CENTER:
                        align = ISystemFontRenderer.Align.CENTER; break;
                    }

                    ISystemFontRenderer.VerticalAlign valign;
                    int va = textProperty.align & (int)Align.VERTICAL_MASK;
                    switch (va)
                    {
                    default:
                        valign = ISystemFontRenderer.VerticalAlign.TOP;
                        break;

                    case (int)Align.VERTICAL_BOTTOM:
                        valign = ISystemFontRenderer.VerticalAlign.BOTTOM;
                        break;

                    case (int)Align.VERTICAL_MIDDLE:
                        valign = ISystemFontRenderer.VerticalAlign.MIDDLE;
                        break;
                    }

                    systemFontRendererParameter = new ISystemFontRenderer.Parameter(
                        fontHeight, width, height, style, align, valign, lineSpacing,
                        letterSpacing, leftMargin, rightMargin);
                    systemFontRenderer = ISystemFontRenderer.Construct();
                }
                else
                {
                    BitmapFont.Renderer.Align align;
                    int a = textProperty.align & (int)Align.ALIGN_MASK;
                    switch (a)
                    {
                    default:
                    case (int)Align.LEFT:
                        align = BitmapFont.Renderer.Align.LEFT;   break;

                    case (int)Align.RIGHT:
                        align = BitmapFont.Renderer.Align.RIGHT;  break;

                    case (int)Align.CENTER:
                        align = BitmapFont.Renderer.Align.CENTER; break;
                    }

                    BitmapFont.Renderer.VerticalAlign valign;
                    int va = textProperty.align & (int)Align.VERTICAL_MASK;
                    switch (va)
                    {
                    default:
                        valign = BitmapFont.Renderer.VerticalAlign.TOP;
                        break;

                    case (int)Align.VERTICAL_BOTTOM:
                        valign = BitmapFont.Renderer.VerticalAlign.BOTTOM;
                        break;

                    case (int)Align.VERTICAL_MIDDLE:
                        valign = BitmapFont.Renderer.VerticalAlign.MIDDLE;
                        break;
                    }

                    bitmapFontRenderer = new BitmapFont.Renderer(fontPath,
                                                                 fontHeight,
                                                                 width,
                                                                 height,
                                                                 align,
                                                                 valign,
                                                                 0.25f,
                                                                 lineSpacing,
                                                                 letterSpacing,
                                                                 tabSpacing,
                                                                 leftMargin,
                                                                 rightMargin);
                }
            }