| 451 | } |
| 452 | |
| 453 | void CGameClient::OnUpdate() |
| 454 | { |
| 455 | HandleLanguageChanged(); |
| 456 | |
| 457 | CUIElementBase::Init(Ui()); // update static pointer because game and editor use separate UI |
| 458 | |
| 459 | // handle mouse movement |
| 460 | float x = 0.0f, y = 0.0f; |
| 461 | IInput::ECursorType CursorType = Input()->CursorRelative(&x, &y); |
| 462 | if(CursorType != IInput::CURSOR_NONE) |
| 463 | { |
| 464 | for(auto &pComponent : m_vpInput) |
| 465 | { |
| 466 | if(pComponent->OnCursorMove(x, y, CursorType)) |
| 467 | break; |
| 468 | } |
| 469 | } |
| 470 | |
| 471 | // handle touch events |
| 472 | const std::vector<IInput::CTouchFingerState> &vTouchFingerStates = Input()->TouchFingerStates(); |
| 473 | bool TouchHandled = false; |
| 474 | for(auto &pComponent : m_vpInput) |
| 475 | { |
| 476 | if(TouchHandled) |
| 477 | { |
| 478 | // Also update inactive components so they can handle touch fingers being released. |
| 479 | pComponent->OnTouchState({}); |
| 480 | } |
| 481 | else if(pComponent->OnTouchState(vTouchFingerStates)) |
| 482 | { |
| 483 | Input()->ClearTouchDeltas(); |
| 484 | TouchHandled = true; |
| 485 | } |
| 486 | } |
| 487 | |
| 488 | // handle key presses |
| 489 | Input()->ConsumeEvents([&](const IInput::CEvent &Event) { |
| 490 | for(auto &pComponent : m_vpInput) |
| 491 | { |
| 492 | // Events with flag `FLAG_RELEASE` must always be forwarded to all components so keys being |
| 493 | // released can be handled in all components also after some components have been disabled. |
| 494 | if(pComponent->OnInput(Event) && (Event.m_Flags & ~IInput::FLAG_RELEASE) != 0) |
| 495 | break; |
| 496 | } |
| 497 | }); |
| 498 | |
| 499 | if(g_Config.m_ClSubTickAiming && m_Binds.m_MouseOnAction) |
| 500 | { |
| 501 | m_Controls.m_aMousePosOnAction[g_Config.m_ClDummy] = m_Controls.m_aMousePos[g_Config.m_ClDummy]; |
| 502 | m_Binds.m_MouseOnAction = false; |
| 503 | } |
| 504 | |
| 505 | for(auto &pComponent : m_vpAll) |
| 506 | { |
| 507 | pComponent->OnUpdate(); |
| 508 | } |
| 509 | } |
| 510 |
nothing calls this directly
no test coverage detected