Esempio n. 1
0
        protected void OnMessageOut(ChatMessageEventArgs e)
        {
            var handler = MessageOut;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Esempio n. 2
0
        public override void FTSUpdate(GameTime timeSpend)
        {
            if (_imanager.ActionsManager.isTriggered(UtopiaActions.ToggleInterface))
            {
                IsHided = !IsHided;
            }

            if (Stopwatch.GetTimestamp() > _lastUpdateTime + _hideChatInTick)
            {
                SetFontAlphaColor(0);
            }
            else
            {
                SetFontAlphaColor(200);
            }


            if (Activated && _imanager.ActionsManager.isTriggered(UtopiaActions.ExitChat, CatchExclusiveActions))
            {
                Activated = false;
                _textInput.Clear();
                _lastUpdateTime = Stopwatch.GetTimestamp();
                _refreshDisplay = true;
            }

            if (_imanager.ActionsManager.isTriggered(UtopiaActions.ToggleChat, CatchExclusiveActions))
            {
                if (Activated == false)
                {
                    CatchExclusiveActions = true;
                    _lastUpdateTime       = Stopwatch.GetTimestamp();

                    Activated       = true;
                    _refreshDisplay = true;
                    _textInput.Clear();
                    _textInput.isListening = true;
                }
                else
                {
                    //Send message to server !
                    Activated             = false;
                    CatchExclusiveActions = false;
                    var input = _textInput.GetText();
                    if (!string.IsNullOrWhiteSpace(input))
                    {
                        var ea = new ChatMessageEventArgs {
                            Message = input
                        };

                        OnMessageOut(ea);

                        if (!ea.DoNotSend)
                        {
                            var msg = new ChatMessage {
                                DisplayName = _server.DisplayName, Message = input
                            };
                            if (input.StartsWith("/me ", StringComparison.CurrentCultureIgnoreCase))
                            {
                                msg.Action  = true;
                                msg.Message = input.Remove(0, 4);
                            }

                            if (input.StartsWith("/"))
                            {
                                _server.ServerConnection.Send(new EntityUseMessage()
                                {
                                    DynamicEntityId = _server.Player.DynamicId,
                                    UseType         = UseType.Command,
                                    State           = _server.Player.EntityState
                                });
                            }

                            _server.ServerConnection.Send(msg);
                        }
                    }
                    _textInput.isListening = false;
                    _textInput.Clear();
                    _refreshDisplay = true;
                }
            }

            _textInput.Refresh();
        }