Пример #1
0
 public MyHudControlChat(
     MyHudChat chat,
     Vector2? position = null,
     Vector2? size = null,
     Vector4? backgroundColor = null,
     MyFontEnum font = MyFontEnum.White,
     float textScale = 0.7f,
     MyGuiDrawAlignEnum textAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     StringBuilder contents = null,
     bool drawScrollbar = false,
     MyGuiDrawAlignEnum textBoxAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM,
     bool selectable = false)
     : base (position, size, backgroundColor, font, textScale, textAlign, contents, drawScrollbar, textBoxAlign, selectable)
 {
     m_forceUpdate = true;
     m_chat = chat;
     OriginAlign = MyGuiDrawAlignEnum.HORISONTAL_LEFT_AND_VERTICAL_BOTTOM;
     base.VisibleChanged += MyHudControlChat_VisibleChanged;
 }
        public void UpdateChat(MyHudChat chat)
        {
            if (MyHud.Chat.Dirty)
            {
                m_chatMultilineControl.Clear();

                foreach (var message in MyHud.Chat.MessagesQueue)
                {
                    bool isMe = Sandbox.Engine.Networking.MySteam.UserName == message.Item1;

                    m_chatMultilineControl.AppendText(new StringBuilder(message.Item1), isMe ? MyFontEnum.Blue : MyFontEnum.White, m_chatMultilineControl.TextScale, Vector4.One);
                    m_chatMultilineControl.AppendText(new StringBuilder(": "));
                    m_chatMultilineControl.AppendText(new StringBuilder(message.Item2));
                    m_chatMultilineControl.AppendLine();
                }

                MyHud.Chat.Dirty = false;
            }
            //m_chatMultilineControl.BackgroundTexture
        }