Beispiel #1
0
        public void Chat(string text)
        {
            if (ChatLabel != null && !ChatLabel.IsDisposed)
            {
                ChatLabel.Dispose();
                ChatLabel = null;
            }

            const int     chatWidth = 200;
            List <string> chat      = new List <string>();

            string[] output = text.Split('(', ')');
            foreach (var o in output)
            {
                if (!uint.TryParse(o, out uint id))
                {
                    continue;
                }
                var item = GameScene.ItemInfoList.FirstOrDefault(x => x.Index == id);
                if (item != null)
                {
                    text = Functions.ReplaceFirst(text, "(" + o + ")", " " + item.FriendlyName + " ");
                }
            }

            int index = 0;

            for (int i = 1; i < text.Length; i++)
            {
                if (TextRenderer.MeasureText(CMain.Graphics, text.Substring(index, i - index), ChatFont).Width > chatWidth)
                {
                    chat.Add(text.Substring(index, i - index - 1));
                    index = i - 1;
                }
            }
            chat.Add(text.Substring(index, text.Length - index));

            text = chat[0];
            for (int i = 1; i < chat.Count; i++)
            {
                text += string.Format("\n{0}", chat[i]);
            }

            ChatLabel = new MirLabel
            {
                AutoSize      = true,
                BackColour    = Color.Transparent,
                ForeColour    = Color.White,
                OutLine       = true,
                OutLineColour = Color.Black,
                DrawFormat    = TextFormatFlags.HorizontalCenter,
                Text          = text,
            };
            ChatTime = CMain.Time + 5000;
        }
Beispiel #2
0
        public virtual void DrawChat()
        {
            if (ChatLabel == null || ChatLabel.IsDisposed)
            {
                return;
            }

            if (CMain.Time > ChatTime)
            {
                ChatLabel.Dispose();
                ChatLabel = null;
                return;
            }

            ChatLabel.ForeColour = Dead ? Color.Gray : Color.White;
            ChatLabel.Location   = new Point(DisplayRectangle.X + (48 - ChatLabel.Size.Width) / 2, DisplayRectangle.Y - (60 + ChatLabel.Size.Height) - (Dead ? 35 : 0));
            ChatLabel.Draw();
        }
Beispiel #3
0
        public void Chat(string text)
        {
            if (ChatLabel != null && !ChatLabel.IsDisposed)
            {
                ChatLabel.Dispose();
                ChatLabel = null;
            }

            const int     chatWidth = 200;
            List <string> chat      = new List <string>();

            int index = 0;

            for (int i = 1; i < text.Length; i++)
            {
                if (TextRenderer.MeasureText(CMain.Graphics, text.Substring(index, i - index), ChatFont).Width > chatWidth)
                {
                    chat.Add(text.Substring(index, i - index - 1));
                    index = i - 1;
                }
            }
            chat.Add(text.Substring(index, text.Length - index));

            text = chat[0];
            for (int i = 1; i < chat.Count; i++)
            {
                text += string.Format("\n{0}", chat[i]);
            }

            ChatLabel = new MirLabel
            {
                AutoSize      = true,
                BackColour    = Color.Transparent,
                ForeColour    = Color.White,
                OutLine       = true,
                OutLineColour = Color.Black,
                DrawFormat    = TextFormatFlags.HorizontalCenter,
                Text          = text,
            };
            ChatTime = CMain.Time + 5000;
        }