Ejemplo n.º 1
0
        public static TextObject CreateMessage(string msg, ushort hue, byte font, bool isunicode, MessageType type)
        {
            if (ProfileManager.Current != null && ProfileManager.Current.OverrideAllFonts)
            {
                font      = ProfileManager.Current.ChatFont;
                isunicode = ProfileManager.Current.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;
            }

            RenderedText rtext = RenderedText.Create(msg, hue, font, isunicode, FontStyle.BlackBorder, TEXT_ALIGN_TYPE.TS_LEFT, width, 30, false, false, true);

            TextObject text_obj = TextObject.Create();

            text_obj.RenderedText = rtext;
            text_obj.Alpha        = 0xFF;
            text_obj.Time         = CalculateTimeToLive(rtext);
            text_obj.Type         = type;
            text_obj.Hue          = hue;

            return(text_obj);
        }
Ejemplo n.º 2
0
        public void FromFullKey()
        {
            var syntax = CallSyntax.Parse("text(Hello World,font:10px Helvetica,color:red)");

            var draw = TextObject.Create(syntax);

            Assert.Equal("Hello World", draw.Content);
            Assert.Equal("red", draw.Color);

            Assert.Equal("text(Hello World,color:red,font:Helvetica)", draw.ToString());
        }
Ejemplo n.º 3
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;
            }


            ushort fixedColor = (ushort)(hue & 0x3FFF);

            if (fixedColor != 0)
            {
                if (fixedColor >= 0x0BB8)
                {
                    fixedColor = 1;
                }

                fixedColor |= (ushort)(hue & 0xC000);
            }
            else
            {
                fixedColor = (ushort)(hue & 0x8000);
            }


            TextObject textObject = TextObject.Create();

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

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

            textObject.RenderedText = RenderedText.Create
                                      (
                msg,
                fixedColor,
                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);
        }