| 302 | } |
| 303 | |
| 304 | void AboutSection::OnTouchEvent(const nCine::TouchEvent& event, Vector2i viewSize) |
| 305 | { |
| 306 | switch (event.type) { |
| 307 | case TouchEventType::Down: { |
| 308 | std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); |
| 309 | if (pointerIndex != -1) { |
| 310 | float y = event.pointers[pointerIndex].y * (float)viewSize.Y; |
| 311 | if (y < 80.0f) { |
| 312 | _root->PlaySfx("MenuSelect"_s, 0.5f); |
| 313 | _root->LeaveSection(); |
| 314 | return; |
| 315 | } |
| 316 | |
| 317 | _touchStart = Vector2f(event.pointers[pointerIndex].x * viewSize.X, y); |
| 318 | _touchLast = _touchStart; |
| 319 | _touchTime = 0.0f; |
| 320 | _autoScroll = false; |
| 321 | } |
| 322 | break; |
| 323 | } |
| 324 | case TouchEventType::Move: { |
| 325 | if (_touchStart != Vector2f::Zero) { |
| 326 | std::int32_t pointerIndex = event.findPointerIndex(event.actionIndex); |
| 327 | if (pointerIndex != -1) { |
| 328 | Vector2f touchMove = Vector2f(event.pointers[pointerIndex].x * viewSize.X, event.pointers[pointerIndex].y * viewSize.Y); |
| 329 | float delta = _touchLast.Y - touchMove.Y; |
| 330 | if (delta != 0.0f) { |
| 331 | _scrollOffset += delta; |
| 332 | if (delta < -0.1f && _touchDirection >= 0) { |
| 333 | _touchDirection = -1; |
| 334 | _touchSpeed = 0.0f; |
| 335 | } else if (delta > 0.1f && _touchDirection <= 0) { |
| 336 | _touchDirection = 1; |
| 337 | _touchSpeed = 0.0f; |
| 338 | } |
| 339 | _touchSpeed = (0.8f * _touchSpeed) + (0.2f * std::abs(delta) / TouchKineticDivider); |
| 340 | } |
| 341 | _touchLast = touchMove; |
| 342 | } |
| 343 | } |
| 344 | break; |
| 345 | } |
| 346 | case TouchEventType::Up: { |
| 347 | bool alreadyMoved = (_touchStart == Vector2f::Zero || (_touchStart - _touchLast).SqrLength() > 100 || _touchTime > FrameTimer::FramesPerSecond); |
| 348 | _touchStart = Vector2f::Zero; |
| 349 | if (alreadyMoved) { |
| 350 | return; |
| 351 | } |
| 352 | |
| 353 | if (_touchLast.Y > 120.0f) { |
| 354 | // Approximation of scroll offsets, needs to be changed when header is changed |
| 355 | if (_scrollOffset > 40.0f && _scrollOffset < 400.0f) { |
| 356 | if (theApplication().OpenUrl("https://deat.tk/jazz2/"_s)) { |
| 357 | _root->PlaySfx("MenuSelect"_s, 0.5f); |
| 358 | } |
| 359 | } |
| 360 | } |
| 361 | break; |
nothing calls this directly
no test coverage detected