public override void Startup() { IoCManager.InjectDependencies(this); inputManager.KeyBindStateChanged += OnKeyBindStateChanged; escapeMenu = new EscapeMenu { Visible = false }; escapeMenu.AddToScreen(); var escapeMenuCommand = InputCmdHandler.FromDelegate(session => { if (escapeMenu.Visible) { if (escapeMenu.IsAtFront()) { escapeMenu.Visible = false; } else { escapeMenu.MoveToFront(); } } else { escapeMenu.OpenCentered(); } }); inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand); }
public override void KeyDown(KeyEventArgs e) { if (e.Key == Keyboard.Key.Escape) { if (escapeMenu.Visible) { if (escapeMenu.IsAtFront()) { escapeMenu.Visible = false; } else { escapeMenu.MoveToFront(); } } else { escapeMenu.OpenCentered(); } e.Handle(); return; } if (e.Key == Keyboard.Key.T && !_gameChat.Input.HasFocus() && !(userInterfaceManager.Focused is LineEdit)) { _gameChat.Input.GrabFocus(); } inputManager.KeyDown(e); }
public override void Startup() { IoCManager.InjectDependencies(this); mapManager.Startup(); inputManager.KeyBindStateChanged += OnKeyBindStateChanged; escapeMenu = new EscapeMenu { Visible = false }; escapeMenu.AddToScreen(); var escapeMenuCommand = InputCmdHandler.FromDelegate(session => { if (escapeMenu.Visible) { if (escapeMenu.IsAtFront()) { escapeMenu.Visible = false; } else { escapeMenu.MoveToFront(); } } else { escapeMenu.OpenCentered(); } }); inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand); inputManager.SetInputCommand(EngineKeyFunctions.FocusChat, InputCmdHandler.FromDelegate(session => { _gameChat.Input.GrabFocus(); })); _gameChat = new Chatbox(); userInterfaceManager.StateRoot.AddChild(_gameChat); _gameChat.TextSubmitted += console.ParseChatMessage; console.AddString += _gameChat.AddLine; _gameChat.DefaultChatFormat = "say \"{0}\""; }
private void Enabled() { if (_escapeMenu.IsOpen) { if (_escapeMenu.IsAtFront()) { _setOpenValue(false); } else { _escapeMenu.MoveToFront(); } } else { _setOpenValue(true); } }
private void StateManagerOnOnStateChanged(StateChangedEventArgs obj) { if (obj.NewState is GameScreen) { // Switched TO GameScreen. _escapeMenu = new EscapeMenu(_clientConsole, _tileDefinitionManager, _placementManager, _prototypeManager, _resourceCache, _configurationManager) { Visible = false }; _escapeMenu.AddToScreen(); var escapeMenuCommand = InputCmdHandler.FromDelegate(session => { if (_escapeMenu.Visible) { if (_escapeMenu.IsAtFront()) { _escapeMenu.Visible = false; } else { _escapeMenu.MoveToFront(); } } else { _escapeMenu.OpenCentered(); } }); _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, escapeMenuCommand); } else if (obj.OldState is GameScreen) { // Switched FROM GameScreen. _escapeMenu.Dispose(); _escapeMenu = null; _inputManager.SetInputCommand(EngineKeyFunctions.EscapeMenu, null); } }