Exemplo n.º 1
0
        public Label(string text, bool isunicode, ushort hue, int maxwidth = 0, byte font = 0xFF, FontStyle style = FontStyle.None, TEXT_ALIGN_TYPE align = TEXT_ALIGN_TYPE.TS_LEFT, bool ishtml = false)
        {
            _gText = RenderedText.Create(text, hue, font, isunicode, style, align, maxwidth, isHTML: ishtml);

            AcceptMouseInput = false;
            Width            = _gText.Width;
            Height           = _gText.Height;
        }
Exemplo n.º 2
0
        public Button
        (
            int buttonID,
            ushort normal,
            ushort pressed,
            ushort over      = 0,
            string caption   = "",
            byte font        = 0,
            bool isunicode   = true,
            ushort normalHue = ushort.MaxValue,
            ushort hoverHue  = ushort.MaxValue
        )
        {
            ButtonID = buttonID;
            _gumpGraphics[NORMAL]  = normal;
            _gumpGraphics[PRESSED] = pressed;
            _gumpGraphics[OVER]    = over;
            _textures[NORMAL]      = GumpsLoader.Instance.GetTexture(normal);
            _textures[PRESSED]     = GumpsLoader.Instance.GetTexture(pressed);

            if (over > 0)
            {
                _textures[OVER] = GumpsLoader.Instance.GetTexture(over);
            }

            UOTexture t = _textures[NORMAL];

            if (t == null)
            {
                Dispose();

                return;
            }

            Width    = t.Width;
            Height   = t.Height;
            FontHue  = normalHue == ushort.MaxValue ? (ushort)0 : normalHue;
            HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue;

            if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue)
            {
                _fontTexture = new RenderedText[2];

                _caption = caption;

                _fontTexture[0] = RenderedText.Create(caption, FontHue, font, isunicode);

                if (hoverHue != ushort.MaxValue)
                {
                    _fontTexture[1] = RenderedText.Create(caption, HueHover, font, isunicode);
                }
            }

            CanMove          = false;
            AcceptMouseInput = true;
            //CanCloseWithRightClick = false;
            CanCloseWithEsc = false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// 新しいインスタンスを生成します。
        /// </summary>
        /// <exception cref="InvalidOperationException">Graphics機能が初期化されていない。</exception>
        public TextNode()
        {
            if (!Engine.Config.EnabledCoreModules.HasFlag(CoreModules.Graphics))
            {
                throw new InvalidOperationException("Graphics機能が初期化されていません。");
            }

            _RenderedText = RenderedText.Create();
        }
Exemplo n.º 4
0
        public CroppedText(string text, ushort hue, int maxWidth = 0)
        {
            _gameText = RenderedText.Create
                        (
                text, hue, (byte)(Client.Version >= ClientVersion.CV_305D ? 1 : 0), true,
                maxWidth > 0 ? FontStyle.BlackBorder | FontStyle.Cropped : FontStyle.BlackBorder, maxWidth: maxWidth
                        );

            AcceptMouseInput = false;
        }
Exemplo n.º 5
0
        public TextEntry(byte font, int maxcharlength = -1, int maxWidth = 0, int width = 0, bool unicode = true, FontStyle style = FontStyle.None, ushort hue = 0xFFFF) : base(maxcharlength, width, maxWidth)
        {
            RenderText = RenderedText.Create(String.Empty, hue, font, unicode, style, maxWidth: width);

            if (maxWidth > 0)
            {
                RenderText.FontStyle |= FontStyle.Cropped;
            }

            RenderCaret = RenderedText.Create("_", hue, font, unicode, (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None);
        }
Exemplo n.º 6
0
            public BuffControlEntry(BuffIcon icon) : base(0, 0, icon.Graphic, 0)
            {
                Icon           = icon;
                Width          = Texture.Width;
                Height         = Texture.Height;
                _alpha         = 0xFF;
                _decreaseAlpha = true;
                _timer         = (uint)(icon.Timer <= 0 ? 0xFFFF_FFFF : Time.Ticks + icon.Timer * 1000);
                _gText         = RenderedText.Create("", 0xFFFF, 2, true, FontStyle.Fixed | FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER, Texture.Width);

                SetTooltip(icon.Text);
            }
Exemplo n.º 7
0
        public static TextObject CreateMessage
        (
            string msg,
            ushort hue,
            byte font,
            bool isunicode,
            MessageType type,
            TextType textType
        )
        {
            if (ProfileManager.CurrentProfile != null && ProfileManager.CurrentProfile.OverrideAllFonts)
            {
                font      = ProfileManager.CurrentProfile.ChatFont;
                isunicode = ProfileManager.CurrentProfile.OverrideAllFontsIsUnicode;
            }

            int width = isunicode
                ? FontsLoader.Instance.GetWidthUnicode(font, msg)
                : FontsLoader.Instance.GetWidthASCII(font, msg);

            if (width > 200)
            {
                width = isunicode
                    ? FontsLoader.Instance.GetWidthExUnicode(font, msg, 200, TEXT_ALIGN_TYPE.TS_LEFT, (ushort)FontStyle.BlackBorder)
                    : FontsLoader.Instance.GetWidthExASCII(font, msg, 200, TEXT_ALIGN_TYPE.TS_LEFT, (ushort)FontStyle.BlackBorder);
            }
            else
            {
                width = 0;
            }

            TextObject textObject = TextObject.Create();

            textObject.Alpha = 0xFF;
            textObject.Type  = type;
            textObject.Hue   = hue;

            if (!isunicode && textType == TextType.OBJECT)
            {
                hue = 0;
            }

            textObject.RenderedText = RenderedText.Create
                                      (
                msg, hue, font, isunicode, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_LEFT, width, 30, false, false,
                textType == TextType.OBJECT
                                      );

            textObject.Time             = CalculateTimeToLive(textObject.RenderedText);
            textObject.RenderedText.Hue = textObject.Hue;

            return(textObject);
        }
Exemplo n.º 8
0
        public HSliderBar(int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false)
        {
            X = x;
            Y = y;

            if (hasText)
            {
                _text   = RenderedText.Create(string.Empty, color, font, unicode);
                _drawUp = drawUp;
            }

            MinValue         = min;
            MaxValue         = max;
            BarWidth         = w;
            _style           = style;
            AcceptMouseInput = true;


            if (_gumpWidget == null)
            {
                switch (_style)
                {
                case HSliderBarStyle.MetalWidgetRecessedBar:

                    _gumpSpliderBackground = new UOTexture32[3]
                    {
                        GumpsLoader.Instance.GetTexture(213), GumpsLoader.Instance.GetTexture(214), GumpsLoader.Instance.GetTexture(215)
                    };

                    _gumpWidget = GumpsLoader.Instance.GetTexture(216);

                    break;

                case HSliderBarStyle.BlueWidgetNoBar:
                    _gumpWidget = GumpsLoader.Instance.GetTexture(0x845);

                    break;
                }

                Width = BarWidth;

                if (_gumpWidget != null)
                {
                    Height = _gumpWidget.Height;
                }

                //RecalculateSliderX();
                CalculateOffset();
            }

            Value = value;
        }
Exemplo n.º 9
0
        public void Add(int damage)
        {
            TextObject text_obj = TextObject.Create();

            text_obj.RenderedText = RenderedText.Create(damage.ToString(), (ushort)(Parent == World.Player ? 0x0034 : 0x0021), 3, false);
            text_obj.Time         = Time.Ticks + 1500;

            _messages.AddToFront(text_obj);

            if (_messages.Count > 10)
            {
                _messages.RemoveFromBack()?.RenderedText?.Destroy();
            }
        }
Exemplo n.º 10
0
        public void Add(int damage)
        {
            _messages.AddToFront(new TextOverhead
            {
                RenderedText = RenderedText.Create(damage.ToString(), (ushort)(Parent == World.Player ? 0x0034 : 0x0021), 3, false),
                Time         = Time.Ticks + 1500
            });


            if (_messages.Count > 10)
            {
                _messages.RemoveFromBack()?.RenderedText?.Destroy();
            }
        }
Exemplo n.º 11
0
        public Button
        (
            int buttonID,
            ushort normal,
            ushort pressed,
            ushort over      = 0,
            string caption   = "",
            byte font        = 0,
            bool isunicode   = true,
            ushort normalHue = ushort.MaxValue,
            ushort hoverHue  = ushort.MaxValue
        )
        {
            ButtonID = buttonID;
            _normal  = normal;
            _pressed = pressed;
            _over    = over;

            if (GumpsLoader.Instance.GetGumpTexture(normal, out var bounds) == null)
            {
                Dispose();

                return;
            }

            Width    = bounds.Width;
            Height   = bounds.Height;
            FontHue  = normalHue == ushort.MaxValue ? (ushort)0 : normalHue;
            HueHover = hoverHue == ushort.MaxValue ? normalHue : hoverHue;

            if (!string.IsNullOrEmpty(caption) && normalHue != ushort.MaxValue)
            {
                _fontTexture = new RenderedText[2];

                _caption = caption;

                _fontTexture[0] = RenderedText.Create(caption, FontHue, font, isunicode);

                if (hoverHue != ushort.MaxValue)
                {
                    _fontTexture[1] = RenderedText.Create(caption, HueHover, font, isunicode);
                }
            }

            CanMove          = false;
            AcceptMouseInput = true;
            //CanCloseWithRightClick = false;
            CanCloseWithEsc = false;
        }
Exemplo n.º 12
0
        public StbTextBox
        (
            byte font,
            int max_char_count    = -1,
            int maxWidth          = 0,
            bool isunicode        = true,
            FontStyle style       = FontStyle.None,
            ushort hue            = 0,
            TEXT_ALIGN_TYPE align = 0
        )
        {
            AcceptKeyboardInput = true;
            AcceptMouseInput    = true;
            CanMove             = false;
            IsEditable          = true;

            _maxCharCount = max_char_count;

            Stb            = new TextEdit(this);
            Stb.SingleLine = true;

            if (maxWidth > 0)
            {
                style |= FontStyle.CropTexture;
            }

            _fontStyle = style;

            if ((style & (FontStyle.Fixed | FontStyle.Cropped)) != 0 && maxWidth <= 0)
            {
                Debug.Assert((style & (FontStyle.Fixed | FontStyle.Cropped)) != 0 && maxWidth <= 0);
            }

            // stb_textedit will handle part of these tag
            style &= ~(/*FontStyle.Fixed | */ FontStyle.Cropped | FontStyle.CropTexture);

            _rendererText = RenderedText.Create(string.Empty, hue, font, isunicode, style, align, maxWidth);

            _rendererCaret = RenderedText.Create
                             (
                "_", hue, font, isunicode,
                (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None, align
                             );

            Height = _rendererCaret.Height;
        }
Exemplo n.º 13
0
        public NameOverheadGump(Entity entity) : base(entity.Serial, 0)
        {
            CanMove                = false;
            AcceptMouseInput       = true;
            CanCloseWithRightClick = true;
            Entity = entity;

            Hue hue = entity is Mobile m?Notoriety.GetHue(m.NotorietyFlag) : (Hue)0x0481;

            _renderedText = RenderedText.Create(String.Empty, hue, 0xFF, true, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER, 100, 30, true);

            Add(_background = new AlphaBlendControl(.3f)
            {
                WantUpdateSize = false,
                Hue            = hue
            });
        }
Exemplo n.º 14
0
        public HSliderBar(int x, int y, int w, int min, int max, int value, HSliderBarStyle style, bool hasText = false, byte font = 0, ushort color = 0, bool unicode = true, bool drawUp = false)
        {
            X = x;
            Y = y;

            if (hasText)
            {
                _text   = RenderedText.Create(string.Empty, color, font, unicode);
                _drawUp = drawUp;
            }

            MinValue         = min;
            MaxValue         = max;
            BarWidth         = w;
            Value            = value;
            _style           = style;
            AcceptMouseInput = true;
        }
Exemplo n.º 15
0
        public HSliderBar
        (
            int x,
            int y,
            int w,
            int min,
            int max,
            int value,
            HSliderBarStyle style,
            bool hasText = false,
            byte font    = 0,
            ushort color = 0,
            bool unicode = true,
            bool drawUp  = false
        )
        {
            X = x;
            Y = y;

            if (hasText)
            {
                _text   = RenderedText.Create(string.Empty, color, font, unicode);
                _drawUp = drawUp;
            }

            MinValue         = min;
            MaxValue         = max;
            BarWidth         = w;
            _style           = style;
            AcceptMouseInput = true;

            var texture = GumpsLoader.Instance.GetGumpTexture((uint)(_style == HSliderBarStyle.MetalWidgetRecessedBar ? 216 : 0x845), out var bounds);

            Width = BarWidth;

            if (texture != null)
            {
                Height = bounds.Height;
            }

            CalculateOffset();

            Value = value;
        }
Exemplo n.º 16
0
            public void AddEntry(string text, int font, Hue hue, bool isUnicode, DateTime time)
            {
                bool maxScroll = _scrollBar.Value == _scrollBar.MaxValue;

                while (_entries.Count > 199)
                {
                    _entries.RemoveFromFront().Destroy();
                    _hours.RemoveFromFront().Destroy();
                }

                RenderedText h = RenderedText.Create($"{time:t} ", 1150, 1, true, FontStyle.BlackBorder);

                _hours.AddToBack(h);

                _entries.AddToBack(RenderedText.Create(text, hue, (byte)font, isUnicode, FontStyle.Indention | FontStyle.BlackBorder, maxWidth: Width - (18 + h.Width)));

                _scrollBar.MaxValue += _entries[_entries.Count - 1].Height;
                if (maxScroll) _scrollBar.Value = _scrollBar.MaxValue;
            }
Exemplo n.º 17
0
            public PasswordStbTextBox
            (
                byte font,
                int max_char_count    = -1,
                int maxWidth          = 0,
                bool isunicode        = true,
                FontStyle style       = FontStyle.None,
                ushort hue            = 0,
                TEXT_ALIGN_TYPE align = TEXT_ALIGN_TYPE.TS_LEFT
            ) : base
                (
                    font,
                    max_char_count,
                    maxWidth,
                    isunicode,
                    style,
                    hue,
                    align
                )
            {
                _rendererText = RenderedText.Create
                                (
                    string.Empty,
                    hue,
                    font,
                    isunicode,
                    style,
                    align,
                    maxWidth
                                );

                _rendererCaret = RenderedText.Create
                                 (
                    "_",
                    hue,
                    font,
                    isunicode,
                    (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None,
                    align
                                 );

                NoSelection = true;
            }
Exemplo n.º 18
0
            public BuffControlEntry(BuffIcon icon) : base(0, 0, icon.Graphic, 0)
            {
                if (IsDisposed)
                {
                    return;
                }

                Icon           = icon;
                _alpha         = 0xFF;
                _decreaseAlpha = true;
                _timer         = (uint)(icon.Timer <= 0 ? 0xFFFF_FFFF : Time.Ticks + icon.Timer * 1000);
                _gText         = RenderedText.Create("", 0xFFFF, 2, true, FontStyle.Fixed | FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER, Width);


                AcceptMouseInput = true;
                WantUpdateSize   = false;
                CanMove          = true;

                SetTooltip(icon.Text);
            }
Exemplo n.º 19
0
        public NameOverheadGump(uint serial) : base(serial, 0)
        {
            CanMove                = false;
            AcceptMouseInput       = true;
            CanCloseWithRightClick = true;

            Entity entity = World.Get(serial);

            if (entity == null)
            {
                Dispose();
                return;
            }

            _renderedText = RenderedText.Create(String.Empty, entity is Mobile m ? Notoriety.GetHue(m.NotorietyFlag) : (ushort)0x0481, 0xFF, true, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_CENTER, 100, 30, true);

            SetTooltip(entity);

            BuildGump();
        }
Exemplo n.º 20
0
            public PinControl(int x, int y)
            {
                X = x;
                Y = y;


                _text = RenderedText.Create(string.Empty, font: 0, isunicode: false);

                _pic = new GumpPic(0, 0, 0x139B, 0);
                Add(_pic);

                WantUpdateSize = false;
                Width          = _pic.Width;
                Height         = _pic.Height;

                AcceptMouseInput = true;
                CanMove          = false;

                _pic.AcceptMouseInput = true;
            }
Exemplo n.º 21
0
        public Checkbox
        (
            ushort inactive,
            ushort active,
            string text    = "",
            byte font      = 0,
            ushort color   = 0,
            bool isunicode = true,
            int maxWidth   = 0
        )
        {
            _inactive = inactive;
            _active   = active;

            var textureInactive = GumpsLoader.Instance.GetGumpTexture(inactive, out var boundsInactive);
            var textureActive   = GumpsLoader.Instance.GetGumpTexture(active, out var boundsActive);

            if (textureInactive == null || textureActive == null)
            {
                Dispose();

                return;
            }

            Width = boundsInactive.Width;

            _text = RenderedText.Create
                    (
                text,
                color,
                font,
                isunicode,
                maxWidth: maxWidth
                    );

            Width += _text.Width;

            Height           = Math.Max(boundsInactive.Width, _text.Height);
            CanMove          = false;
            AcceptMouseInput = true;
        }
Exemplo n.º 22
0
        public Checkbox
        (
            ushort inactive,
            ushort active,
            string text    = "",
            byte font      = 0,
            ushort color   = 0,
            bool isunicode = true,
            int maxWidth   = 0
        )
        {
            _textures[INACTIVE] = GumpsLoader.Instance.GetTexture(inactive);
            _textures[ACTIVE]   = GumpsLoader.Instance.GetTexture(active);

            if (_textures[0] == null || _textures[1] == null)
            {
                Dispose();

                return;
            }

            UOTexture t = _textures[INACTIVE];

            Width = t.Width;

            _text = RenderedText.Create
                    (
                text,
                color,
                font,
                isunicode,
                maxWidth: maxWidth
                    );

            Width += _text.Width;

            Height           = Math.Max(t.Width, _text.Height);
            CanMove          = false;
            AcceptMouseInput = true;
        }
Exemplo n.º 23
0
        public HtmlControl()
        {
            _gameText = RenderedText.Create(string.Empty, isunicode: true, font: 1);

            CanMove = true;
        }
Exemplo n.º 24
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(_serial) && World.OPL.TryGetRevision(_serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(_serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FontsLoader.Instance.SetUseHTML(true);
                    FontsLoader.Instance.RecalculateWidthByInfo = true;

                    int width = FontsLoader.Instance.GetWidthUnicode(1, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;

                    FontsLoader.Instance.RecalculateWidthByInfo = false;
                    FontsLoader.Instance.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8))
            {
                x = Client.Game.Window.ClientBounds.Width - (_renderedText.Width + 8);
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8))
            {
                y = Client.Game.Window.ClientBounds.Height - (_renderedText.Height + 8);
            }

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Texture2DCache.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);
            batcher.DrawRectangle(Texture2DCache.GetTexture(Color.Gray), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x + 3, y));
        }
Exemplo n.º 25
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (SerialHelper.IsValid(Serial) && World.OPL.TryGetRevision(Serial, out uint revision) && _hash != revision)
            {
                _hash = revision;
                Text  = ReadProperties(Serial, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Time.Ticks)
            {
                return(false);
            }


            byte   font  = 1;
            float  alpha = 0.3f;
            ushort hue   = 0xFFFF;
            float  zoom  = 1;

            if (ProfileManager.CurrentProfile != null)
            {
                font  = ProfileManager.CurrentProfile.TooltipFont;
                alpha = 1f - ProfileManager.CurrentProfile.TooltipBackgroundOpacity / 100f;

                if (float.IsNaN(alpha))
                {
                    alpha = 1f;
                }

                hue  = ProfileManager.CurrentProfile.TooltipTextHue;
                zoom = ProfileManager.CurrentProfile.TooltipDisplayZoom / 100f;
            }

            FontsLoader.Instance.SetUseHTML(true);
            FontsLoader.Instance.RecalculateWidthByInfo = true;

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create
                                (
                    null,
                    font: font,
                    isunicode: true,
                    style: FontStyle.BlackBorder,
                    cell: 5,
                    isHTML: true,
                    align: TEXT_ALIGN_TYPE.TS_CENTER,
                    recalculateWidthByInfo: true,
                    hue: hue
                                );
            }

            if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    int width = FontsLoader.Instance.GetWidthUnicode(font, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FontsLoader.Instance.GetWidthExUnicode
                            (
                        font,
                        Text,
                        width,
                        TEXT_ALIGN_TYPE.TS_CENTER,
                        (ushort)FontStyle.BlackBorder
                            );

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Font = font;
                _renderedText.Hue  = hue;
                _renderedText.Text = _textHTML;
            }

            FontsLoader.Instance.RecalculateWidthByInfo = false;
            FontsLoader.Instance.SetUseHTML(false);

            if (_renderedText.Texture == null)
            {
                return(false);
            }

            int z_width  = _renderedText.Width + 8;
            int z_height = _renderedText.Height + 8;

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Client.Game.Window.ClientBounds.Width - z_width)
            {
                x = Client.Game.Window.ClientBounds.Width - z_width;
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Client.Game.Window.ClientBounds.Height - z_height)
            {
                y = Client.Game.Window.ClientBounds.Height - z_height;
            }


            Vector3 hue_vec = Vector3.Zero;

            ShaderHueTranslator.GetHueVector(ref hue_vec, 0, false, alpha);

            batcher.Draw2D
            (
                SolidColorTextureCache.GetTexture(Color.Black),
                x - 4,
                y - 2,
                z_width * zoom,
                z_height * zoom,
                ref hue_vec
            );

            batcher.DrawRectangle
            (
                SolidColorTextureCache.GetTexture(Color.Gray),
                x - 4,
                y - 2,
                (int)(z_width * zoom),
                (int)(z_height * zoom),
                ref hue_vec
            );

            hue_vec.X = 0;
            hue_vec.Y = 0;
            hue_vec.Z = 0;

            return(batcher.Draw2D
                   (
                       _renderedText.Texture,
                       x + 3,
                       y + 3,
                       z_width * zoom,
                       z_height * zoom,
                       0,
                       0,
                       z_width,
                       z_height,
                       ref hue_vec
                   ));
        }
Exemplo n.º 26
0
 public MultiLineEntry(byte font, int maxcharlength = -1, int maxWidth = 0, int width = 0, bool unicode = true, FontStyle style = FontStyle.None, ushort hue = 0xFFFF) : base(maxcharlength, width, maxWidth)
 {
     RenderText  = RenderedText.Create(string.Empty, hue, font, unicode, style, maxWidth: width);
     RenderCaret = RenderedText.Create("_", hue, font, unicode, (style & FontStyle.BlackBorder) != 0 ? FontStyle.BlackBorder : FontStyle.None, maxWidth: width);
     MaxLines    = 0;
 }
Exemplo n.º 27
0
        public void DrawText()
        {
            Assert.True(Engine.Initialize("Altseed2 C# Engine", 800, 600, new Configuration()));

            var font  = Font.LoadDynamicFont("../../Core/TestData/Font/mplus-1m-regular.ttf", 100);
            var font2 = Font.LoadDynamicFont("../../Core/TestData/Font/GenYoMinJP-Bold.ttf", 100);

            Assert.NotNull(font);
            Assert.NotNull(font2);
            var imageFont = Font.CreateImageFont(font);

            imageFont.AddImageGlyph('〇', Texture2D.Load(@"../../Core/TestData/IO/AltseedPink.png"));

            List <RenderedText> texts = new List <RenderedText>();

            {
                var t = RenderedText.Create();
                t.Font      = font;
                t.Text      = "Hello, world! こんにちは";
                t.Transform = MathHelper.CalcTransform(new Vector2F(), new Vector2F(), 0, new Vector2F(1, 1));
                texts.Add(t);
            }

            {
                var t = RenderedText.Create();
                t.Font      = font;
                t.Text      = "色を指定する。";
                t.Color     = new Color(0, 0, 255, 255);
                t.Transform = MathHelper.CalcTransform(new Vector2F(0, 100), new Vector2F(), 0, new Vector2F(1, 1));
                texts.Add(t);
            }

            {
                var t = RenderedText.Create();
                t.Font      = font2;
                t.Text      = "𠀋 𡈽 𡌛 𡑮 𡢽 𠮟 𡚴 𡸴 𣇄 𣗄 𣜿 𣝣 𣳾 𤟱 𥒎 𥔎 𥝱 𥧄 𥶡 𦫿 𦹀 𧃴 𧚄 𨉷";
                t.Transform = MathHelper.CalcTransform(new Vector2F(0, 200), new Vector2F(), 0, new Vector2F(1, 1));
                texts.Add(t);
            }

            var rotatedText = RenderedText.Create();
            {
                rotatedText.Font = font;
                rotatedText.Text = "くるくるまわる";
                texts.Add(rotatedText);
            }

            {
                var imageFontText = RenderedText.Create();
                imageFontText.Font      = imageFont;
                imageFontText.Text      = "Altseed〇Altseed";
                imageFontText.Transform = MathHelper.CalcTransform(new Vector2F(0, 300), new Vector2F(), 0, new Vector2F(1, 1));
                texts.Add(imageFontText);
            }

            int count = 0;

            while (Engine.DoEvents() && count++ < 300)
            {
                Assert.True(Engine.Graphics.BeginFrame(new RenderPassParameter(Engine.ClearColor, true, true)));
                rotatedText.Transform = MathHelper.CalcTransform(new Vector2F(0, 300), new Vector2F(), count, new Vector2F(1, 1));

                foreach (var item in texts)
                {
                    Engine.Renderer.DrawText(item);
                }

                Engine.Renderer.Render();
                Assert.True(Engine.Graphics.EndFrame());
            }

            Engine.Terminate();
        }
Exemplo n.º 28
0
        public bool Draw(UltimaBatcher2D batcher, int x, int y)
        {
            if (_gameObject != null && _hash != _gameObject.PropertiesHash)
            {
                _hash = _gameObject.PropertiesHash;
                Text  = ReadProperties(_gameObject, out _textHTML);
            }

            if (string.IsNullOrEmpty(Text))
            {
                return(false);
            }

            if (_lastHoverTime > Engine.Ticks)
            {
                return(false);
            }

            if (_renderedText == null)
            {
                _renderedText = RenderedText.Create(string.Empty, font: 1, isunicode: true, style: FontStyle.BlackBorder, cell: 5, isHTML: true, align: TEXT_ALIGN_TYPE.TS_CENTER, recalculateWidthByInfo: true);
            }
            else if (_renderedText.Text != Text)
            {
                if (_maxWidth == 0)
                {
                    FileManager.Fonts.SetUseHTML(true);
                    FileManager.Fonts.RecalculateWidthByInfo = true;

                    int width = FileManager.Fonts.GetWidthUnicode(1, Text);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    width = FileManager.Fonts.GetWidthExUnicode(1, Text, width, TEXT_ALIGN_TYPE.TS_CENTER, (ushort)FontStyle.BlackBorder);

                    if (width > 600)
                    {
                        width = 600;
                    }

                    _renderedText.MaxWidth = width;

                    FileManager.Fonts.RecalculateWidthByInfo = false;
                    FileManager.Fonts.SetUseHTML(false);
                }
                else
                {
                    _renderedText.MaxWidth = _maxWidth;
                }

                _renderedText.Text = _textHTML;
            }

            if (x < 0)
            {
                x = 0;
            }
            else if (x > Engine.WindowWidth - (_renderedText.Width + 8))
            {
                x = Engine.WindowWidth - (_renderedText.Width + 8);
            }

            if (y < 0)
            {
                y = 0;
            }
            else if (y > Engine.WindowHeight - (_renderedText.Height + 8))
            {
                y = Engine.WindowHeight - (_renderedText.Height + 8);
            }

            Vector3 hue = Vector3.Zero;

            ShaderHuesTraslator.GetHueVector(ref hue, 0, false, 0.3f, true);

            batcher.Draw2D(Textures.GetTexture(Color.Black), x - 4, y - 2, _renderedText.Width + 8, _renderedText.Height + 4, ref hue);

            return(_renderedText.Draw(batcher, x, y));
        }