Ejemplo n.º 1
0
 internal void AppendMessage(OnscreenMessage message)
 {
     if (m_Messages.Length >= m_Messages.Size)
     {
         m_Messages.RemoveItemAt(GetFirstNonHeaderIndex());
     }
     m_Messages.AddItem(message);
 }
Ejemplo n.º 2
0
 public void AppendMessage(OnscreenMessage message)
 {
     if (_messages.Length >= _messages.Size)
     {
         _messages.RemoveItemAt(GetFirstNonHeaderIndex());
     }
     _messages.AddItem(message);
 }
Ejemplo n.º 3
0
        public OnscreenMessageBox AddOnscreenMessage(UnityEngine.Vector3Int?absolutePosition, int statementId, string speaker, int speakerLevel, MessageModeType mode, Utils.UnionStrInt text, int color)
        {
            var messageFilterSet = OpenTibiaUnity.OptionStorage.GetMessageFilterSet(Chat.MessageFilterSet.DefaultSet);
            var messageMode      = messageFilterSet.GetMessageMode(mode);

            if (messageMode == null || !messageMode.ShowOnScreen || messageMode.ScreenTarget == MessageScreenTargets.None)
            {
                return(null);
            }

            var nameFilterSet = OpenTibiaUnity.OptionStorage.GetNameFilterSet(Chat.NameFilterSet.DefaultSet);

            if (!messageMode.IgnoreNameFilter && (nameFilterSet == null || !nameFilterSet.AcceptMessage(mode, speaker, text)))
            {
                return(null);
            }

            var screenTarget = messageMode.ScreenTarget;

            if (screenTarget == MessageScreenTargets.EffectCoordinate)
            {
                if (!absolutePosition.HasValue)
                {
                    throw new System.Exception("WorldMapStorage.AddOnscreenMessage: Missing co-ordinate.");
                }

                if (text.IsInt)
                {
                    AddTextualEffect(absolutePosition.Value, color, ((int)text).ToString());
                }
                return(null);
            }

            OnscreenMessageBox messageBox = null;
            OnscreenMessage    message    = null;

            if (screenTarget == MessageScreenTargets.BoxCoordinate)
            {
                if (!absolutePosition.HasValue)
                {
                    throw new System.Exception("WorldMapStorage.AddOnscreenMessage: Missing co-ordinate.");
                }

                bool visible = true;

                for (int i = (int)screenTarget; i < MessageBoxes.Count; i++)
                {
                    var tmpMessageBox = MessageBoxes[i];
                    if (tmpMessageBox.Position == null || tmpMessageBox.Position == absolutePosition.Value)
                    {
                        if (tmpMessageBox.Speaker == speaker && tmpMessageBox.Mode == mode)
                        {
                            messageBox = tmpMessageBox;
                            break;
                        }

                        visible = false;
                    }
                }

                if (messageBox == null)
                {
                    messageBox = new OnscreenMessageBox(absolutePosition, speaker, speakerLevel, mode, Constants.NumOnscreenMessages)
                    {
                        Visible = visible
                    };

                    var tmpMessage = messageMode.GetOnscreenMessageHeader(speaker, speakerLevel);
                    if (tmpMessage != null)
                    {
                        message = new OnscreenMessage(-1, speaker, speakerLevel, mode, tmpMessage);
                        message.FormatMessage(null, messageMode.TextARGB, messageMode.HighlightARGB);
                        message.TTL = int.MaxValue;
                        messageBox.AppendMessage(message);
                    }

                    MessageBoxes.Add(messageBox);
                }
            }
            else
            {
                messageBox = MessageBoxes[(int)screenTarget];
            }

            message = new OnscreenMessage(statementId, speaker, speakerLevel, mode, text);
            message.FormatMessage(messageMode.GetOnscreenMessagePrefix(speaker, speakerLevel), messageMode.TextARGB, messageMode.HighlightARGB);
            messageBox.AppendMessage(message);
            messageBox.Visible = true;
            InvalidateOnscreenMessages();
            return(messageBox);
        }
Ejemplo n.º 4
0
        public OnscreenMessageBox AddOnscreenMessage(UnityEngine.Vector3Int?position, int statementID, string speaker, int speakerLevel, MessageModes mode, Utility.UnionStrInt text, uint color)
        {
            Chat.MessageFilterSet messageFilterSet = Chat.MessageFilterSet.DefaultFilterSet;

            Chat.MessageMode messageMode = messageFilterSet.GetMessageMode(mode);
            if (messageMode == null || !messageMode.ShowOnScreen || messageMode.ScreenTarget == MessageScreenTargets.None)
            {
                return(null);
            }

            // TODO: name filter (speaker)

            var screenTarget = messageMode.ScreenTarget;

            if (screenTarget == MessageScreenTargets.EffectCoordinate)
            {
                // color effect on a position
                // Tip: Here you can modify this "is int" and "as int" to add colored text and so on.

                if (!position.HasValue)
                {
                    throw new System.Exception("WorldMapStorage.AddOnscreenMessage: Missing co-ordinate.");
                }

                if (text.IsInt)
                {
                    //uint value = (uint)((int)text);
                    //var textualEffect = OpenTibiaUnity.AppearanceStorage.CreateTextualEffect(-1, color, value);
                    //AppendEffect(position.Value, textualEffect);
                }

                return(null);
            }

            OnscreenMessageBox messageBox = null;
            OnscreenMessage    message    = null;

            if (screenTarget == MessageScreenTargets.BoxCoordinate)
            {
                if (!position.HasValue)
                {
                    throw new System.Exception("WorldMapStorage.AddOnscreenMessage: Missing co-ordinate.");
                }

                bool visible = true;

                for (int i = (int)screenTarget; i < MessageBoxes.Count; i++)
                {
                    var tmpMessageBox = MessageBoxes[i];
                    if (tmpMessageBox.Position == null || tmpMessageBox.Position == position.Value)
                    {
                        if (tmpMessageBox.Speaker == speaker && tmpMessageBox.Mode == mode)
                        {
                            messageBox = tmpMessageBox;
                            break;
                        }

                        visible = false;
                    }
                }

                if (messageBox == null)
                {
                    var textBox = UnityEngine.Object.Instantiate(m_TextBoxPrefab, OpenTibiaUnity.GameManager.OnscreenMessagesContainer);
                    messageBox         = new OnscreenMessageBox(position, speaker, speakerLevel, mode, Constants.NumOnscreenMessages, textBox);
                    messageBox.Visible = visible;

                    var tmpMessage = messageMode.GetOnscreenMessageHeader(speaker, speakerLevel);
                    if (tmpMessage != null)
                    {
                        message = new OnscreenMessage(-1, speaker, speakerLevel, mode, tmpMessage);
                        message.FormatMessage(null, messageMode.TextARGB, messageMode.HighlightARGB);
                        message.TTL = int.MaxValue;
                        messageBox.AppendMessage(message);
                    }

                    MessageBoxes.Add(messageBox);
                }
            }
            else
            {
                messageBox = MessageBoxes[(int)screenTarget];
            }

            message = new OnscreenMessage(statementID, speaker, speakerLevel, mode, text);
            message.FormatMessage(messageMode.GetOnscreenMessagePrefix(speaker, speakerLevel), messageMode.TextARGB, messageMode.HighlightARGB);
            messageBox.AppendMessage(message);
            messageBox.Visible = true;
            InvalidateOnscreenMessages();
            return(messageBox);
        }