Quote from: Khris on Wed 23/10/2024 10:46:45It's this one: https://drive.google.com/file/d/19uyh4VBjeMkhg-oNX2RC-STsw7IGG9Bl/view?usp=drive_link
This is likely a culprit:
void noloopcheck dialog_options_mouse_click(DialogOptionsRenderingInfo *info, MouseButton button) {
if (button == eMouseLeft) {
if (_mouseOverUpArrow && _showUpArrow) {
while (mouse.IsButtonDown(eMouseLeft)) {} // <--------------------------------------
_scrolledDown--;
}
if (_mouseOverDownArrow && _showDownArrow) {
while (mouse.IsButtonDown(eMouseLeft)) {} // <--------------------------------------
_scrolledDown++;
}
}
<...>
}
void noloopcheck dialog_options_key_press(DialogOptionsRenderingInfo *info, eKeyCode keycode, int mod) {
if (_keyboardScrolling && keycode == eKeyUpArrow && _showUpArrow) {
while (IsKeyPressed(eKeyUpArrow)) {} // <--------------------------------------
_scrolledDown--;
return;
}
if (_keyboardScrolling && keycode == eKeyDownArrow && _showDownArrow) {
while (IsKeyPressed(eKeyDownArrow)) {} // <--------------------------------------
_scrolledDown++;
return;
}
<...>
}
The problem is that engine does not guarantee updates of mouse or key states unless control is passed back to it. So empty loops like that are not reliable.
I would even say that this should not work.
Frankly, I'm not sure how it works on desktop systems, maybe by accident... Like, maybe the buttons are no longer pressed anymore when the script enters these lines. Probably it works bit differently on Web version.
EDIT:
roflmao... just like I knew it, this is a comment from the engine code inside IsKeyPressed:
// old input handling: update key state in realtime
// left only in case if necessary for some ancient game, but
// this really may only be required if there's a key waiting loop in
// script without Wait(1) to let engine poll events in a natural way.
if (game.options[OPT_KEYHANDLEAPI] == 0)
SDL_PumpEvents();
Mouse.IsButtonDown does not have this.