diff options
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp')
| -rw-r--r-- | Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp | 97 |
1 files changed, 95 insertions, 2 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp index 2a8ac9f8..d3da0870 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp @@ -41,8 +41,72 @@ wstring UIScene_DebugCreateSchematic::getMoviePath() return L"DebugCreateSchematic"; } +UIControl_TextInput* UIScene_DebugCreateSchematic::getTextInputForControl(eControls ctrl) +{ + switch (ctrl) + { + case eControl_Name: return &m_textInputName; + case eControl_StartX: return &m_textInputStartX; + case eControl_StartY: return &m_textInputStartY; + case eControl_StartZ: return &m_textInputStartZ; + case eControl_EndX: return &m_textInputEndX; + case eControl_EndY: return &m_textInputEndY; + case eControl_EndZ: return &m_textInputEndZ; + default: return NULL; + } +} + +#ifdef _WINDOWS64 +void UIScene_DebugCreateSchematic::getDirectEditInputs(vector<UIControl_TextInput*> &inputs) +{ + inputs.push_back(&m_textInputName); + inputs.push_back(&m_textInputStartX); + inputs.push_back(&m_textInputStartY); + inputs.push_back(&m_textInputStartZ); + inputs.push_back(&m_textInputEndX); + inputs.push_back(&m_textInputEndY); + inputs.push_back(&m_textInputEndZ); +} + +void UIScene_DebugCreateSchematic::onDirectEditFinished(UIControl_TextInput *input, UIControl_TextInput::EDirectEditResult result) +{ + wstring value = input->getEditBuffer(); + int iVal = 0; + if (!value.empty()) + iVal = _fromString<int>(value); + + if (input == &m_textInputName) + { + if (!value.empty()) + swprintf(m_data->name, 64, L"%ls", value.c_str()); + else + swprintf(m_data->name, 64, L"schematic"); + } + else if (input == &m_textInputStartX) m_data->startX = iVal; + else if (input == &m_textInputStartY) m_data->startY = iVal; + else if (input == &m_textInputStartZ) m_data->startZ = iVal; + else if (input == &m_textInputEndX) m_data->endX = iVal; + else if (input == &m_textInputEndY) m_data->endY = iVal; + else if (input == &m_textInputEndZ) m_data->endZ = iVal; +} + +bool UIScene_DebugCreateSchematic::handleMouseClick(F32 x, F32 y) +{ + UIScene::handleMouseClick(x, y); + return true; // always consume to prevent Iggy re-entry on empty space +} +#endif + +void UIScene_DebugCreateSchematic::tick() +{ + UIScene::tick(); +} + void UIScene_DebugCreateSchematic::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled) { +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) return; +#endif ui.AnimateKeyPress(iPad, key, repeat, pressed, released); switch(key) @@ -67,6 +131,9 @@ void UIScene_DebugCreateSchematic::handleInput(int iPad, int key, bool repeat, b void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) { +#ifdef _WINDOWS64 + if (isDirectEditBlocking()) return; +#endif switch((int)controlId) { case eControl_Create: @@ -112,8 +179,28 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) case eControl_EndX: case eControl_EndY: case eControl_EndZ: - m_keyboardCallbackControl = (eControls)((int)controlId); - InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); + { + m_keyboardCallbackControl = (eControls)((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 something"; + kbData.defaultText = L""; + kbData.maxChars = 25; + kbData.callback = &UIScene_DebugCreateSchematic::KeyboardCompleteCallback; + kbData.lpParam = this; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData, eUILayer_Fullscreen, eUIGroup_Fullscreen); + } +#else + InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); +#endif + } break; }; } @@ -138,9 +225,15 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool b { UIScene_DebugCreateSchematic *pClass=(UIScene_DebugCreateSchematic *)lpParam; +#ifdef _WINDOWS64 + uint16_t pchText[128]; + ZeroMemory(pchText, 128 * sizeof(uint16_t)); + Win64_GetKeyboardText(pchText, 128); +#else uint16_t pchText[128]; ZeroMemory(pchText, 128 * sizeof(uint16_t) ); InputManager.GetText(pchText); +#endif if(pchText[0]!=0) { |
