mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-24 05:03:34 -04:00
Allow using up/down in main gui window input box for quickly repeating commands.
This commit is contained in:
parent
5877dc63d6
commit
f42ea4e6ee
@ -407,17 +407,42 @@ namespace MCGalaxy.Gui {
|
||||
void demoteToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
PlayerCmd("rank", "-down ", "");
|
||||
}
|
||||
PlayerProperties playerProps;
|
||||
|
||||
#region Main tab
|
||||
List<string> inputLog = new List<string>(21);
|
||||
int inputIndex = -1;
|
||||
|
||||
void txtInput_KeyDown(object sender, KeyEventArgs e) {
|
||||
if (e.KeyCode != Keys.Enter) return;
|
||||
if (e.KeyCode == Keys.Up) {
|
||||
inputIndex = Math.Min(inputIndex + 1, inputLog.Count - 1);
|
||||
if (inputIndex > -1) SetInputText();
|
||||
} else if (e.KeyCode == Keys.Down) {
|
||||
inputIndex = Math.Max(inputIndex - 1, -1);
|
||||
if (inputIndex > -1) SetInputText();
|
||||
} else if (e.KeyCode == Keys.Enter) {
|
||||
InputText();
|
||||
} else {
|
||||
inputIndex = -1; return;
|
||||
}
|
||||
e.Handled = true;
|
||||
e.SuppressKeyPress = true;
|
||||
}
|
||||
|
||||
void SetInputText() {
|
||||
if (inputIndex == -1) return;
|
||||
main_txtInput.Text = inputLog[inputIndex];
|
||||
main_txtInput.SelectionLength = 0;
|
||||
main_txtInput.SelectionStart = main_txtInput.Text.Length;
|
||||
}
|
||||
|
||||
void InputText() {
|
||||
string text = main_txtInput.Text;
|
||||
if (text.Length == 0) return;
|
||||
|
||||
inputLog.Insert(0, text);
|
||||
if (inputLog.Count > 20)
|
||||
inputLog.RemoveAt(20);
|
||||
|
||||
if (text[0] == '/' && text.Length > 1 && text[1] == '/') {
|
||||
Handlers.HandleChat(text.Substring(1), WriteLine);
|
||||
} else if (text[0] == '/') {
|
||||
@ -622,6 +647,7 @@ namespace MCGalaxy.Gui {
|
||||
|
||||
|
||||
#region Players tab
|
||||
PlayerProperties playerProps;
|
||||
|
||||
public void UpdatePlyersListBox() {
|
||||
RunOnUiThread(
|
||||
|
Loading…
x
Reference in New Issue
Block a user