Beyond_Beyaan.BBTextBox.Initialize C# (CSharp) Метод

Initialize() публичный Метод

public Initialize ( int xPos, int yPos, int width, int height, bool wrapText, bool allowScrollbar, string name, Random r, string &reason ) : bool
xPos int
yPos int
width int
height int
wrapText bool
allowScrollbar bool
name string
r System.Random
reason string
Результат bool
        public bool Initialize(int xPos, int yPos, int width, int height, bool wrapText, bool allowScrollbar, string name, Random r, out string reason)
        {
            //If using scrollbar, then shrink the actual width by 16 to allow for scrollbar, even if it's not visible
            _x = xPos;
            _y = yPos;
            _maxWidth = width;
            Width = width;
            Height = height == 0 ? 1 : height;
            _wrapText = wrapText;
            _scrollbarVisible = false;
            _textScrollBar = new BBScrollBarNoArrows();
            _allowScrollbar = allowScrollbar;
            if (_allowScrollbar)
            {
                if (_wrapText)
                {
                    if (!_textScrollBar.Initialize(xPos + _maxWidth - 5, yPos, Height, Height, 1, false, false, r, out reason))
                    {
                        return false;
                    }
                    _wrapView = new Viewport(0, 0, _maxWidth - 5, Height);

                    _target = new RenderImage(name + "render", _maxWidth - 5, Height, ImageBufferFormats.BufferRGB888A8);
                }
                else
                {
                    if (!_textScrollBar.Initialize(xPos, yPos + Height - 5, _maxWidth, _maxWidth, 1, true, false, r, out reason))
                    {
                        return false;
                    }
                    _wrapView = new Viewport(0, 0, _maxWidth, Height - 5);

                    _target = new RenderImage(name + "render", _maxWidth, Height - 5, ImageBufferFormats.BufferRGB888A8);
                }
            }
            else
            {
                _wrapView = new Viewport(0, 0, _maxWidth, Height);

                _target = new RenderImage(name + "render", _maxWidth, Height, ImageBufferFormats.BufferRGB888A8);
            }
            _textSprite = new TextSprite(name, string.Empty, FontManager.GetDefaultFont());
            _textSprite.WordWrap = _wrapText;
            if (_allowScrollbar || _wrapText)
            {
                _textSprite.Bounds = _wrapView;
            }
            _target.BlendingMode = BlendingModes.Modulated;
            reason = null;
            return true;
        }

Usage Example

Пример #1
0
        public bool Initialize(string name, string text, int screenWidth, int screenHeight, Random r, out string reason)
        {
            _text = new BBTextBox();
            if (!_text.Initialize(0, 0, WIDTH - 30, 0, true, false, name, r, out reason))
            {
                return false;
            }
            _text.SetText(text);
            if (_text.Width < WIDTH - 30)
            {
                _actualWidth = _text.Width + 30;
            }
            else
            {
                _actualWidth = WIDTH;
            }

            _totalHeight = _text.Height + 15;

            _background = new BBStretchableImage();
            if (!_background.Initialize(0, 0, _actualWidth, _totalHeight, StretchableImageType.ThinBorderBG, r, out reason))
            {
                return false;
            }

            _showing = false;
            _delayBeforeShowing = 0; //1 second will turn on showing

            _screenWidth = screenWidth;
            _screenHeight = screenHeight;

            reason = null;
            return true;
        }