Example #1
0
        internal void ArrangeMessages()
        {
            m_VisibleMessages = 0;
            m_Height          = 0;
            m_Width           = 0;

            if (!Visible)
            {
                return;
            }

            switch (Mode)
            {
            case MessageModeType.Say:
            case MessageModeType.Whisper:
            case MessageModeType.Yell:
            case MessageModeType.Spell:
            case MessageModeType.NpcFrom:
            case MessageModeType.BarkLoud:
            case MessageModeType.BarkLow:
                int i = 0;
                while (m_VisibleMessages < m_Messages.Length)
                {
                    var onscreenMessage = m_Messages.GetItemAt(m_VisibleMessages);
                    var size            = m_TextMesh.GetPreferredValues(onscreenMessage.RichText);
                    if (m_Height + size.y <= Constants.OnscreenMessageHeight)
                    {
                        m_VisibleMessages++;
                        m_Width   = Mathf.Max(m_Width, size.x);
                        m_Height += size.y;
                        onscreenMessage.VisibleSince = Mathf.Min(OpenTibiaUnity.TicksMillis, onscreenMessage.VisibleSince);

                        m_TextMesh.text += (i++ == 0 ? "" : "\n") + onscreenMessage.RichText;
                        continue;
                    }
                    break;
                }

                break;

            default:
                if (m_Messages.Length > 0)
                {
                    var onscreenMessage = m_Messages.GetItemAt(0);
                    m_TextMesh.text = onscreenMessage.RichText;
                    var size = m_TextMesh.GetPreferredValues();
                    m_VisibleMessages            = 1;
                    m_Width                      = size.x;
                    m_Height                     = size.y;
                    onscreenMessage.VisibleSince = Mathf.Min(OpenTibiaUnity.TicksMillis, onscreenMessage.VisibleSince);
                }
                break;
            }

            m_TextMesh.ForceMeshUpdate();
        }
 internal TextualEffectInstance(int color, string text, TMPro.TextMeshProUGUI textMesh) : base(0, null)
 {
     m_LastPhaseChange = OpenTibiaUnity.TicksMillis;
     m_TextMesh        = textMesh;
     m_TextMesh.text   = text;
     m_TextMesh.color  = Colors.ColorFrom8Bit(color);
     m_Size            = m_TextMesh.GetPreferredValues();
     m_Dirty           = false;
 }
Example #3
0
 public TextualEffectInstance(int color, string text, TMPro.TextMeshProUGUI textMesh) : base(0, null)
 {
     _lastPhaseChange = OpenTibiaUnity.TicksMillis;
     _textMesh        = textMesh;
     _textMesh.text   = text;
     _textMesh.color  = Colors.ColorFrom8Bit(color);
     _size            = _textMesh.GetPreferredValues();
     _dirty           = false;
 }
        private void CheckDirty()
        {
            if (!m_Dirty)
            {
                return;
            }

            m_Size  = m_TextMesh.GetPreferredValues();
            m_Dirty = false;
        }
Example #5
0
        private void CheckDirty()
        {
            if (!_dirty)
            {
                return;
            }

            _size  = _textMesh.GetPreferredValues();
            _dirty = false;
        }
Example #6
0
        public void SetMessage(string message, int maxWidth = -1, int maxHeight = -1)
        {
            _messagesLabel.SetText(message);

            var preferedSize = _messagesLabel.GetPreferredValues();

            var layoutElement = _messagesLabel.GetComponent <LayoutElement>();

            layoutElement.preferredWidth  = Mathf.Min(maxWidth, preferedSize.x);
            layoutElement.preferredHeight = Mathf.Min(maxHeight, preferedSize.y);
        }