Replace call to Cry renderer to get viewport height (#939)

This commit is contained in:
michabr
2021-05-25 18:51:37 -07:00
committed by GitHub
parent 03ec6465b5
commit 29163fba1a
@@ -1450,13 +1450,17 @@ void UiTextInputComponent::CheckStartTextInput()
EBUS_EVENT_ID_RESULT(textString, m_textEntity, UiTextBus, GetText);
options.m_initialText = Utf8SubString(textString, m_textCursorPos, m_textSelectionStartPos);
AZ::EntityId canvasEntityId;
EBUS_EVENT_ID_RESULT(canvasEntityId, GetEntityId(), UiElementBus, GetCanvasEntityId);
// Calculate height available for virtual keyboard. In game mode, canvas size is the same as viewport size
AZ::Vector2 canvasSize;
EBUS_EVENT_ID_RESULT(canvasSize, canvasEntityId, UiCanvasBus, GetCanvasSize);
UiTransformInterface::RectPoints rectPoints;
EBUS_EVENT_ID(GetEntityId(), UiTransformBus, GetViewportSpacePoints, rectPoints);
const AZ::Vector2 bottomRight = rectPoints.GetAxisAlignedBottomRight();
options.m_normalizedMinY = bottomRight.GetY() / static_cast<float>(gEnv->pRenderer->GetHeight());
options.m_normalizedMinY = (canvasSize.GetY() > 0.0f) ? bottomRight.GetY() / canvasSize.GetY() : 0.0f;
AZ::EntityId canvasEntityId;
EBUS_EVENT_ID_RESULT(canvasEntityId, GetEntityId(), UiElementBus, GetCanvasEntityId);
EBUS_EVENT_ID_RESULT(options.m_localUserId, canvasEntityId, UiCanvasBus, GetLocalUserIdInputFilter);
AzFramework::InputTextEntryRequestBus::Broadcast(&AzFramework::InputTextEntryRequests::TextEntryStart, options);