Reorganize control flow in gdCustomSelect

Fixes #198
This commit is contained in:
Alexander Batalov 2022-11-03 18:08:49 +03:00
parent b689b3a757
commit a38151bf2c
1 changed files with 63 additions and 71 deletions

View File

@ -4104,10 +4104,7 @@ int _gdCustomSelect(int a1)
sharedFpsLimiter.mark(); sharedFpsLimiter.mark();
int keyCode = inputGetInput(); int keyCode = inputGetInput();
if (keyCode == -1) { if (keyCode != -1) {
continue;
}
if (keyCode == KEY_CTRL_Q || keyCode == KEY_CTRL_X || keyCode == KEY_F10) { if (keyCode == KEY_CTRL_Q || keyCode == KEY_CTRL_X || keyCode == KEY_F10) {
showQuitConfirmationDialog(); showQuitConfirmationDialog();
} }
@ -4124,26 +4121,17 @@ int _gdCustomSelect(int a1)
} else if (keyCode == KEY_ESCAPE) { } else if (keyCode == KEY_ESCAPE) {
done = true; done = true;
} else if (keyCode == -2) { } else if (keyCode == -2) {
if ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) == 0) { if ((mouseGetEvent() & MOUSE_EVENT_LEFT_BUTTON_UP) != 0) {
continue;
}
// No need to use mouseHitTestInWindow as these values are already // No need to use mouseHitTestInWindow as these values are already
// in screen coordinates. // in screen coordinates.
if (!_mouse_click_in(minX, minY, maxX, maxY)) { if (_mouse_click_in(minX, minY, maxX, maxY)) {
continue;
}
int mouseX; int mouseX;
int mouseY; int mouseY;
mouseGetPosition(&mouseX, &mouseY); mouseGetPosition(&mouseX, &mouseY);
int lineHeight = fontGetLineHeight(); int lineHeight = fontGetLineHeight();
int newValue = (mouseY - minY) / lineHeight; int newValue = (mouseY - minY) / lineHeight;
if (newValue >= 6) { if (newValue < 6) {
continue;
}
unsigned int timestamp = getTicks(); unsigned int timestamp = getTicks();
if (newValue == value) { if (newValue == value) {
if (getTicksBetween(timestamp, v53) < 250) { if (getTicksBetween(timestamp, v53) < 250) {
@ -4185,6 +4173,10 @@ int _gdCustomSelect(int a1)
} }
v53 = timestamp; v53 = timestamp;
} }
}
}
}
}
renderPresent(); renderPresent();
sharedFpsLimiter.throttle(); sharedFpsLimiter.throttle();