MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / OnTouchEvent

Method OnTouchEvent

Sources/Jazz2/UI/Menu/ServerSelectSection.cpp:518–628  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

516 }
517
518 void ServerSelectSection::OnTouchEvent(const TouchEvent& event, Vector2i viewSize)
519 {
520 if (_shouldStart) {
521 return;
522 }
523
524 switch (event.type) {
525 case TouchEventType::Down: {
526 std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex);
527 if (pointerIndex != -1) {
528 float y = event.pointers[pointerIndex].y * (float)viewSize.Y;
529 if (y < 80.0f) {
530 _root->PlaySfx("MenuSelect"_s, 0.5f);
531 if (_waitForIpInput) {
532 if (_keyboardVisible) {
533 theApplication().HideScreenKeyboard();
534 _keyboardVisible = false;
535 RecalcLayoutForScreenKeyboard();
536 } else {
537 _waitForIpInput = false;
538 _ipInput.Deactivate();
539 }
540 } else {
541 _root->LeaveSection();
542 }
543 return;
544 }
545
546 _touchStart = Vector2f(event.pointers[pointerIndex].x * viewSize.X, y);
547 _touchLast = _touchStart;
548 _touchTime = 0.0f;
549 }
550 break;
551 }
552 case TouchEventType::Move: {
553 if (_touchStart != Vector2f::Zero) {
554 std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex);
555 if (pointerIndex != -1) {
556 Vector2f touchMove = Vector2f(event.pointers[pointerIndex].x * viewSize.X, event.pointers[pointerIndex].y * viewSize.Y);
557 if (!_waitForIpInput && _availableHeight < _height) {
558 float delta = touchMove.Y - _touchLast.Y;
559 if (delta != 0.0f) {
560 _y += delta;
561 if (delta < -0.1f && _touchDirection >= 0) {
562 _touchDirection = -1;
563 _touchSpeed = 0.0f;
564 } else if (delta > 0.1f && _touchDirection <= 0) {
565 _touchDirection = 1;
566 _touchSpeed = 0.0f;
567 }
568 _touchSpeed = (0.8f * _touchSpeed) + (0.2f * std::abs(delta) / TouchKineticDivider);
569 }
570 }
571 _touchLast = touchMove;
572 }
573 }
574 break;
575 }

Callers

nothing calls this directly

Calls 11

findPointerIndexMethod · 0.80
PlaySfxMethod · 0.45
HideScreenKeyboardMethod · 0.45
DeactivateMethod · 0.45
LeaveSectionMethod · 0.45
LengthMethod · 0.45
GetContentBoundsMethod · 0.45
CanShowScreenKeyboardMethod · 0.45
ShowScreenKeyboardMethod · 0.45
ActivateMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected