MCPcopy Create free account
hub / github.com/OpenLoco/OpenLoco / edgeScroll

Function edgeScroll

src/OpenLoco/src/Input/Keyboard.cpp:410–487  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

408 }
409
410 static void edgeScroll()
411 {
412 if (!Ui::hasInputFocus())
413 {
414 return;
415 }
416
417 if (Tutorial::state() != Tutorial::State::none)
418 {
419 return;
420 }
421
422 if (!Config::get().edgeScrolling)
423 {
424 return;
425 }
426
427 if (Input::state() != State::normal && Input::state() != State::dropdownActive)
428 {
429 return;
430 }
431
432 if (hasKeyModifier(KeyModifier::shift) || hasKeyModifier(KeyModifier::control))
433 {
434 return;
435 }
436
437 Ui::Point delta = { 0, 0 };
438 auto cursor = getCursorPosScaled();
439
440 if (cursor.x == 0)
441 {
442 delta.x -= Config::get().edgeScrollingSpeed;
443 }
444
445 if (cursor.x >= Ui::width() - 1)
446 {
447 delta.x += Config::get().edgeScrollingSpeed;
448 }
449
450 if (cursor.y == 0)
451 {
452 delta.y -= Config::get().edgeScrollingSpeed;
453 }
454
455 if (cursor.y >= Ui::height() - 1)
456 {
457 delta.y += Config::get().edgeScrollingSpeed;
458 }
459
460 if (delta.x == 0 && delta.y == 0)
461 {
462 return;
463 }
464
465 auto main = WindowManager::getMainWindow();
466 if (main->hasFlags(WindowFlags::viewportNoScrolling))
467 {

Callers 1

handleKeyboardFunction · 0.85

Calls 11

hasInputFocusFunction · 0.85
hasKeyModifierFunction · 0.85
getCursorPosScaledFunction · 0.85
widthFunction · 0.85
heightFunction · 0.85
getMainWindowFunction · 0.85
isTitleModeFunction · 0.85
stateFunction · 0.50
getFunction · 0.50
setFlagFunction · 0.50
hasFlagsMethod · 0.45

Tested by

no test coverage detected