Exemple #1
0
 public RenderText(Rect virtualScreen, Dictionary <byte, Position> glyphTextureMapping,
                   IRenderLayer layer, IText text, TextColor textColor, bool shadow)
     : base(text.MaxLineSize * CharacterWidth, text.LineCount * CharacterHeight - (LineHeight - CharacterHeight), virtualScreen)
 {
     this.glyphTextureMapping = glyphTextureMapping;
     bounds    = virtualScreen;
     Layer     = layer;
     Text      = text;
     TextColor = textColor;
     Shadow    = shadow;
 }
Exemple #2
0
        public IRenderText AddText(Position position, string text, TextColor textColor, bool shadow = true,
                                   byte displayLayer = 1, char?fallbackChar = null)
        {
            var renderText = renderView.RenderTextFactory.Create(renderView.GetLayer(Layer.Text),
                                                                 renderView.TextProcessor.CreateText(text, fallbackChar), textColor, shadow);

            renderText.DisplayLayer = (byte)Util.Min(255, this.DisplayLayer + displayLayer);
            renderText.PaletteIndex = game.UIPaletteIndex;
            renderText.X            = position.X;
            renderText.Y            = position.Y;
            renderText.Visible      = true;
            texts.Add(new UIText(renderText));
            return(renderText);
        }
Exemple #3
0
        public UIText AddText(Rect bounds, IText text, TextColor textColor, TextAlign textAlign = TextAlign.Left,
                              bool shadow = true, byte displayLayer = 1, bool scrolling = false, Layout layout = null)
        {
            UIText uiText;

            displayLayer = (byte)Util.Min(255, DisplayLayer + displayLayer);

            if (scrolling && layout != null)
            {
                uiText = layout.CreateScrollableText(bounds, text, textColor, textAlign, displayLayer, shadow, game.TextPaletteIndex);
            }
            else
            {
                uiText = new UIText(renderView, game.TextPaletteIndex, text, bounds, displayLayer,
                                    textColor, shadow, textAlign, scrolling);
            }
            texts.Add(uiText);
            if (scrolling)
            {
                bool closeAfterScroll = CloseOnClick;
                CloseOnClick = false;
                if (closeAfterScroll)
                {
                    if (layout != null)
                    {
                        uiText.FreeScrollingEnded += () =>
                        {
                            if (closeAfterScroll)
                            {
                                game.ClosePopup();
                            }
                        };
                    }
                    else
                    {
                        uiText.Scrolled += scrolledToEnd =>
                        {
                            if (closeAfterScroll && scrolledToEnd)
                            {
                                game.ClosePopup();
                            }
                        };
                    }
                }
            }
            return(uiText);
        }
Exemple #4
0
 public RenderText(Rect virtualScreen, Dictionary <byte, Position> glyphTextureMapping,
                   IRenderLayer layer, IText text, TextColor textColor, bool shadow, Rect bounds, TextAlign textAlign,
                   int characterWidth = CharacterWidth, int characterHeight = CharacterHeight)
     : base(text.MaxLineSize * characterWidth, text.LineCount * characterHeight - (LineHeight - characterHeight), virtualScreen)
 {
     this.glyphTextureMapping = glyphTextureMapping;
     this.bounds    = bounds;
     this.textAlign = textAlign;
     Layer          = layer;
     Text           = text;
     TextColor      = textColor;
     Shadow         = shadow;
     X = bounds.Left;
     Y = bounds.Top;
     this.characterWidth  = characterWidth;
     this.characterHeight = characterHeight;
 }
Exemple #5
0
 public UIText AddText(Rect bounds, string text, TextColor textColor, TextAlign textAlign = TextAlign.Left,
                       bool shadow = true, byte displayLayer = 1, bool scrolling = false, Layout layout = null)
 {
     return(AddText(bounds, renderView.TextProcessor.CreateText(text), textColor, textAlign,
                    shadow, (byte)Util.Min(255, displayLayer), scrolling, layout));
 }