public void RunTick() { // Mouse Handling this.MouseOver = this.GetMouseOverState(); if (this.MouseOver == UIMouseOverState.On) { UIComponent.ComponentWithFocus = this; // Mouse Clicked if (Cursor.LeftMouseState == Cursor.MouseDownState.Clicked) { UIComponent.ComponentSelected = this; } } // If the Mouse just exited this component: //else if(this.MouseOver == UIMouseOverState.Exited) {} // Key Handling if (UIComponent.ComponentSelected == this) { InputClient input = Systems.input; // Get Characters Pressed (doesn't assist with order) string charsPressed = input.GetCharactersPressed(); UICreoInput comp = (UICreoInput)UIComponent.ComponentSelected; if (charsPressed.Length > 0) { comp.SetInputText(comp.text + charsPressed); } // Backspace (+Shift, +Control) if (input.LocalKeyDown(Keys.Back) && this.lastBack < Systems.timer.UniFrame) { if (input.LocalKeyPressed(Keys.Back)) { this.lastBack = Systems.timer.UniFrame + 10; } else { this.lastBack = Systems.timer.UniFrame + 4; } if (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift) || input.LocalKeyDown(Keys.LeftControl) || input.LocalKeyDown(Keys.RightControl)) { comp.SetInputText(""); } else if (comp.text.Length > 0) { comp.SetInputText(comp.text.Substring(0, comp.text.Length - 1)); } } } }
public void RunTick() { InputClient input = Systems.input; // Get Characters Pressed (doesn't assist with order) string charsPressed = input.GetCharactersPressed(); if (charsPressed.Length > 0) { ConsoleTrack.instructionText += charsPressed; } // Backspace else if (input.LocalKeyDown(Keys.Back) && ConsoleTrack.instructionText.Length > 0) { // After a hard delete (just pressed), wait 10 frames rather than 3. if (input.LocalKeyPressed(Keys.Back)) { ConsoleTrack.instructionText = ConsoleTrack.instructionText.Substring(0, ConsoleTrack.instructionText.Length - 1); this.backspaceFrame = Systems.timer.UniFrame + 10; // If held shift or control, remove the full line. if (input.LocalKeyDown(Keys.LeftShift) || input.LocalKeyDown(Keys.RightShift) || input.LocalKeyDown(Keys.LeftControl) || input.LocalKeyDown(Keys.RightControl)) { ConsoleTrack.instructionText = ""; } } else if (this.backspaceFrame < Systems.timer.UniFrame) { ConsoleTrack.instructionText = ConsoleTrack.instructionText.Substring(0, ConsoleTrack.instructionText.Length - 1); // Delete a character every 3 frames. this.backspaceFrame = Systems.timer.UniFrame + 3; } } // Up + Down - Scroll through Console Text else if (input.LocalKeyPressed(Keys.Up)) { this.ScrollConsoleText(-1); } else if (input.LocalKeyPressed(Keys.Down)) { this.ScrollConsoleText(1); } // Tab - Appends the tab lookup to the current instruction text. else if (input.LocalKeyDown(Keys.Tab)) { ConsoleTrack.instructionText += ConsoleTrack.tabLookup; } // Enter - Process the instruction. else if (input.LocalKeyPressed(Keys.Enter)) { ConsoleTrack.activate = true; // The instruction is meant to run (rather than just reveal new text hints). } // Close Console (Tilde, Escape) else if (input.LocalKeyPressed(Keys.OemTilde) || input.LocalKeyPressed(Keys.Escape)) { UIHandler.SetMenu(null, false); } // If there was no input provided, end here. else { return; } // Process the Instruction this.SendCommand(ConsoleTrack.instructionText, false); }