Exemplo n.º 1
0
        public static void SetupChatInputHandlers(IInputManager inputManager, ChatBox chatBox)
        {
            inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChat(chatBox)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusLocalChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Local)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusWhisperChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Whisper)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.OOC)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusAdminChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Admin)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusRadio,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Radio)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusDeadChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Dead)));

            inputManager.SetInputCommand(ContentKeyFunctions.FocusConsoleChat,
                                         InputCmdHandler.FromDelegate(_ => GameScreen.FocusChannel(chatBox, ChatSelectChannel.Console)));

            inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelForward,
                                         InputCmdHandler.FromDelegate(_ => chatBox.CycleChatChannel(true)));

            inputManager.SetInputCommand(ContentKeyFunctions.CycleChatChannelBackward,
                                         InputCmdHandler.FromDelegate(_ => chatBox.CycleChatChannel(false)));
        }
Exemplo n.º 2
0
        private void _onChatBoxTextSubmitted(ChatBox chatBox, string text)
        {
            DebugTools.Assert(chatBox == _currentChatBox);

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            switch (text[0])
            {
            case ConCmdSlash:
            {
                // run locally
                var conInput = text.Substring(1);
                _console.ProcessCommand(conInput);
                break;
            }

            case OOCAlias:
            {
                var conInput = text.Substring(1);
                _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
                break;
            }

            case AdminChatAlias:
            {
                var conInput = text.Substring(1);
                if (_groupController.CanCommand("asay"))
                {
                    _console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\"");
                }
                else
                {
                    _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
                }
                break;
            }

            case MeAlias:
            {
                var conInput = text.Substring(1);
                _console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\"");
                break;
            }

            default:
            {
                var conInput = _currentChatBox.DefaultChatFormat != null
                        ? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text))
                        : text;

                _console.ProcessCommand(conInput);
                break;
            }
            }
        }
Exemplo n.º 3
0
        private void _onFilterButtonToggled(ChatBox chatBox, BaseButton.ButtonToggledEventArgs e)
        {
            switch (e.Button.Name)
            {
            case "Local":
                _localState = !_localState;
                if (_localState)
                {
                    _filteredChannels |= ChatChannel.Local;
                    break;
                }
                else
                {
                    _filteredChannels &= ~ChatChannel.Local;
                    break;
                }

            case "OOC":
                _oocState = !_oocState;
                if (_oocState)
                {
                    _filteredChannels |= ChatChannel.OOC;
                    break;
                }
                else
                {
                    _filteredChannels &= ~ChatChannel.OOC;
                    break;
                }

            case "Admin":
                _adminState = !_adminState;
                if (_adminState)
                {
                    _filteredChannels |= ChatChannel.AdminChat;
                    break;
                }
                else
                {
                    _filteredChannels &= ~ChatChannel.AdminChat;
                    break;
                }

            case "ALL":
                chatBox.LocalButton.Pressed ^= true;
                chatBox.OOCButton.Pressed   ^= true;
                if (chatBox.AdminButton != null)
                {
                    chatBox.AdminButton.Pressed ^= true;
                }
                _allState = !_allState;
                break;
            }

            RepopulateChat(filteredHistory);
        }
Exemplo n.º 4
0
        public void SetChatBox(ChatBox chatBox)
        {
            if (_currentChatBox != null)
            {
                _currentChatBox.TextSubmitted -= _onChatBoxTextSubmitted;
            }

            _currentChatBox = chatBox;
            if (_currentChatBox != null)
            {
                _currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
            }
        }
Exemplo n.º 5
0
        private void _onChatBoxTextSubmitted(ChatBox chatBox, string text)
        {
            DebugTools.Assert(chatBox == _currentChatBox);

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            switch (text[0])
            {
            case ConCmdSlash:
            {
                // run locally
                var conInput = text.Substring(1);
                _console.ProcessCommand(conInput);
                break;
            }

            case OOCAlias:
            {
                var conInput = text.Substring(1);
                _console.ProcessCommand($"ooc \"{conInput}\"");
                break;
            }

            case MeAlias:
            {
                var conInput = text.Substring(1);
                _console.ProcessCommand($"me \"{conInput}\"");
                break;
            }

            default:
            {
                var conInput = _currentChatBox.DefaultChatFormat != null
                        ? string.Format(_currentChatBox.DefaultChatFormat, text)
                        : text;

                _console.ProcessCommand(conInput);
                break;
            }
            }
        }
Exemplo n.º 6
0
        public void SetChatBox(ChatBox chatBox)
        {
            if (_currentChatBox != null)
            {
                _currentChatBox.TextSubmitted -= _onChatBoxTextSubmitted;
                _currentChatBox.FilterToggled -= _onFilterButtonToggled;
            }

            _currentChatBox = chatBox;
            if (_currentChatBox != null)
            {
                _currentChatBox.TextSubmitted += _onChatBoxTextSubmitted;
                _currentChatBox.FilterToggled += _onFilterButtonToggled;
            }

            RepopulateChat(filteredHistory);
            _currentChatBox.AllButton.Pressed   = !_allState;
            _currentChatBox.LocalButton.Pressed = !_localState;
            _currentChatBox.OOCButton.Pressed   = !_oocState;
        }
Exemplo n.º 7
0
        private void _onChatBoxTextSubmitted(ChatBox chatBox, string text)
        {
            DebugTools.Assert(chatBox == _currentChatBox);

            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            // Check if message is longer than the character limit
            if (text.Length > _maxMessageLength)
            {
                string locWarning = Loc.GetString("Your message exceeds {0} character limit", _maxMessageLength);
                _currentChatBox?.AddLine(locWarning, ChatChannel.Server, Color.Orange);
                _currentChatBox.ClearOnEnter = false;   // The text shouldn't be cleared if it hasn't been sent
                return;
            }

            switch (text[0])
            {
            case ConCmdSlash:
            {
                // run locally
                var conInput = text.Substring(1);
                _console.ProcessCommand(conInput);
                break;
            }

            case OOCAlias:
            {
                var conInput = text.Substring(1);
                if (string.IsNullOrWhiteSpace(conInput))
                {
                    return;
                }
                _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
                break;
            }

            case AdminChatAlias:
            {
                var conInput = text.Substring(1);
                if (string.IsNullOrWhiteSpace(conInput))
                {
                    return;
                }
                if (_groupController.CanCommand("asay"))
                {
                    _console.ProcessCommand($"asay \"{CommandParsing.Escape(conInput)}\"");
                }
                else
                {
                    _console.ProcessCommand($"ooc \"{CommandParsing.Escape(conInput)}\"");
                }
                break;
            }

            case MeAlias:
            {
                var conInput = text.Substring(1);
                if (string.IsNullOrWhiteSpace(conInput))
                {
                    return;
                }
                _console.ProcessCommand($"me \"{CommandParsing.Escape(conInput)}\"");
                break;
            }

            default:
            {
                var conInput = _currentChatBox.DefaultChatFormat != null
                        ? string.Format(_currentChatBox.DefaultChatFormat, CommandParsing.Escape(text))
                        : text;

                _console.ProcessCommand(conInput);
                break;
            }
            }
        }