diff options
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp | 107 |
1 files changed, 93 insertions, 14 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp index dd5a429f..51eab5aa 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugSetCamera.cpp @@ -17,7 +17,7 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void *initData, UILayer currentPosition->player = playerNo; Minecraft *pMinecraft = Minecraft::GetInstance(); - if (pMinecraft != NULL) + if (pMinecraft != nullptr) { Vec3 *vec = pMinecraft->localplayers[playerNo]->getPos(1.0); @@ -31,19 +31,19 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void *initData, UILayer WCHAR TempString[256]; - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camX); + swprintf( (WCHAR *)TempString, 256, L"%.2f", currentPosition->m_camX); m_textInputX.init(TempString, eControl_CamX); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camY); + swprintf( (WCHAR *)TempString, 256, L"%.2f", currentPosition->m_camY); m_textInputY.init(TempString, eControl_CamY); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_camZ); + swprintf( (WCHAR *)TempString, 256, L"%.2f", currentPosition->m_camZ); m_textInputZ.init(TempString, eControl_CamZ); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_yRot); + swprintf( (WCHAR *)TempString, 256, L"%.2f", currentPosition->m_yRot); m_textInputYRot.init(TempString, eControl_YRot); - swprintf( (WCHAR *)TempString, 256, L"%f", currentPosition->m_elev); + swprintf( (WCHAR *)TempString, 256, L"%.2f", currentPosition->m_elev); m_textInputElevation.init(TempString, eControl_Elevation); m_checkboxLockPlayer.init(L"Lock Player", eControl_LockPlayer, app.GetFreezePlayers()); @@ -55,6 +55,7 @@ UIScene_DebugSetCamera::UIScene_DebugSetCamera(int iPad, void *initData, UILayer m_labelCamY.init(L"CamY"); m_labelCamZ.init(L"CamZ"); m_labelYRotElev.init(L"Y-Rot & Elevation (Degs)"); + } wstring UIScene_DebugSetCamera::getMoviePath() @@ -62,8 +63,59 @@ wstring UIScene_DebugSetCamera::getMoviePath() return L"DebugSetCamera"; } +#ifdef _WINDOWS64 +UIControl_TextInput* UIScene_DebugSetCamera::getTextInputForControl(eControls ctrl) +{ + switch (ctrl) + { + case eControl_CamX: return &m_textInputX; + case eControl_CamY: return &m_textInputY; + case eControl_CamZ: return &m_textInputZ; + case eControl_YRot: return &m_textInputYRot; + case eControl_Elevation: return &m_textInputElevation; + default: return NULL; + } +} + +void UIScene_DebugSetCamera::getDirectEditInputs(vector<UIControl_TextInput*> &inputs) +{ + inputs.push_back(&m_textInputX); + inputs.push_back(&m_textInputY); + inputs.push_back(&m_textInputZ); + inputs.push_back(&m_textInputYRot); + inputs.push_back(&m_textInputElevation); +} + +void UIScene_DebugSetCamera::onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result) +{ + wstring value = input->getEditBuffer(); + double val = 0; + if (!value.empty()) val = _fromString<double>(value); + + if (input == &m_textInputX) currentPosition->m_camX = val; + else if (input == &m_textInputY) currentPosition->m_camY = val; + else if (input == &m_textInputZ) currentPosition->m_camZ = val; + else if (input == &m_textInputYRot) currentPosition->m_yRot = val; + else if (input == &m_textInputElevation) currentPosition->m_elev = val; +} + +bool UIScene_DebugSetCamera::handleMouseClick(F32 x, F32 y) +{ + UIScene::handleMouseClick(x, y); + return true; // always consume to prevent Iggy re-entry on empty space +} +#endif + +void UIScene_DebugSetCamera::tick() +{ + UIScene::tick(); +} + void UIScene_DebugSetCamera::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) { handled = true; return; } +#endif ui.AnimateKeyPress(iPad, key, repeat, pressed, released); switch(key) @@ -88,11 +140,14 @@ void UIScene_DebugSetCamera::handleInput(int iPad, int key, bool repeat, bool pr void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) { - switch((int)controlId) +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) return; +#endif + switch(static_cast<int>(controlId)) { case eControl_Teleport: app.SetXuiServerAction( ProfileManager.GetPrimaryPad(), - eXuiServerAction_SetCameraLocation, + eXuiServerAction_SetCameraLocation, (void *)currentPosition); break; case eControl_CamX: @@ -100,15 +155,34 @@ void UIScene_DebugSetCamera::handlePress(F64 controlId, F64 childId) case eControl_CamZ: case eControl_YRot: case eControl_Elevation: - m_keyboardCallbackControl = (eControls)((int)controlId); + m_keyboardCallbackControl = static_cast<eControls>(static_cast<int>(controlId)); +#ifdef _WINDOWS64 + if (g_KBMInput.IsKBMActive()) + { + UIControl_TextInput* input = getTextInputForControl(m_keyboardCallbackControl); + if (input) input->beginDirectEdit(25); + } + else + { + UIKeyboardInitData kbData; + kbData.title = L"Enter value"; + kbData.defaultText = L""; + kbData.maxChars = 25; + kbData.callback = &UIScene_DebugSetCamera::KeyboardCompleteCallback; + kbData.lpParam = this; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData, eUILayer_Fullscreen, eUIGroup_Fullscreen); + } +#else +>>>>>>> origin/main InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugSetCamera::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); +#endif break; }; } void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) { - switch((int)controlId) + switch(static_cast<int>(controlId)) { case eControl_LockPlayer: app.SetFreezePlayers(selected); @@ -118,14 +192,19 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId, bool selected) int UIScene_DebugSetCamera::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) { - UIScene_DebugSetCamera *pClass=(UIScene_DebugSetCamera *)lpParam; - uint16_t pchText[2048];//[128]; - ZeroMemory(pchText, 2048/*128*/ * sizeof(uint16_t) ); + UIScene_DebugSetCamera *pClass=static_cast<UIScene_DebugSetCamera *>(lpParam); + uint16_t pchText[2048]; + ZeroMemory(pchText, 2048 * sizeof(uint16_t)); +#ifdef _WINDOWS64 + Win64_GetKeyboardText(pchText, 2048); +#else +>>>>>>> origin/main InputManager.GetText(pchText); +#endif if(pchText[0]!=0) { - wstring value = (wchar_t *)pchText; + wstring value = reinterpret_cast<wchar_t*>(pchText); double val = 0; if(!value.empty()) val = _fromString<double>( value ); switch(pClass->m_keyboardCallbackControl) |
