mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2024-12-15 04:30:29 +00:00
Queue key presses for a short period after pressing a computer shortcut
Fixes #1326
This commit is contained in:
parent
7e54a40fa9
commit
62e3c5f9aa
@ -30,6 +30,7 @@ public class TerminalWidget extends AbstractWidget {
|
|||||||
private static final Component DESCRIPTION = Component.translatable("gui.computercraft.terminal");
|
private static final Component DESCRIPTION = Component.translatable("gui.computercraft.terminal");
|
||||||
|
|
||||||
private static final float TERMINATE_TIME = 0.5f;
|
private static final float TERMINATE_TIME = 0.5f;
|
||||||
|
private static final float KEY_SUPPRESS_DELAY = 0.2f;
|
||||||
|
|
||||||
private final Terminal terminal;
|
private final Terminal terminal;
|
||||||
private final InputHandler computer;
|
private final InputHandler computer;
|
||||||
@ -79,15 +80,12 @@ public class TerminalWidget extends AbstractWidget {
|
|||||||
switch (key) {
|
switch (key) {
|
||||||
case GLFW.GLFW_KEY_T -> {
|
case GLFW.GLFW_KEY_T -> {
|
||||||
if (terminateTimer < 0) terminateTimer = 0;
|
if (terminateTimer < 0) terminateTimer = 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case GLFW.GLFW_KEY_S -> {
|
case GLFW.GLFW_KEY_S -> {
|
||||||
if (shutdownTimer < 0) shutdownTimer = 0;
|
if (shutdownTimer < 0) shutdownTimer = 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case GLFW.GLFW_KEY_R -> {
|
case GLFW.GLFW_KEY_R -> {
|
||||||
if (rebootTimer < 0) rebootTimer = 0;
|
if (rebootTimer < 0) rebootTimer = 0;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
case GLFW.GLFW_KEY_V -> {
|
case GLFW.GLFW_KEY_V -> {
|
||||||
// Ctrl+V for paste
|
// Ctrl+V for paste
|
||||||
@ -118,7 +116,7 @@ public class TerminalWidget extends AbstractWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key >= 0 && terminateTimer < 0 && rebootTimer < 0 && shutdownTimer < 0) {
|
if (key >= 0 && terminateTimer < KEY_SUPPRESS_DELAY && rebootTimer < KEY_SUPPRESS_DELAY && shutdownTimer < KEY_SUPPRESS_DELAY) {
|
||||||
// Queue the "key" event and add to the down set
|
// Queue the "key" event and add to the down set
|
||||||
var repeat = keysDown.get(key);
|
var repeat = keysDown.get(key);
|
||||||
keysDown.set(key);
|
keysDown.set(key);
|
||||||
|
Loading…
Reference in New Issue
Block a user