From f189d1e3bd2fb11dccf761452bb4b8ed822418c0 Mon Sep 17 00:00:00 2001 From: Devlrxxh Date: Thu, 5 Mar 2026 16:59:00 +0100 Subject: [PATCH] Finished implementing keyboard --- .../Common/UI/UIScene_AnvilMenu.cpp | 29 ++++++++- .../Common/UI/UIScene_AnvilMenu.h | 6 +- .../Common/UI/UIScene_CreateWorldMenu.cpp | 39 ++++++++++-- .../Common/UI/UIScene_CreateWorldMenu.h | 53 ++++++++-------- .../UI/UIScene_DebugCreateSchematic.cpp | 63 ++++++++++++++++++- .../Common/UI/UIScene_DebugCreateSchematic.h | 5 +- .../Common/UI/UIScene_Keyboard.cpp | 58 +++++++++++++++-- Minecraft.Client/Common/UI/UIScene_Keyboard.h | 28 +++++---- .../UI/UIScene_LaunchMoreOptionsMenu.cpp | 23 ++++++- .../Common/UI/UIScene_LaunchMoreOptionsMenu.h | 4 ++ .../Common/UI/UIScene_SignEntryMenu.cpp | 23 ++++++- .../Common/UI/UIScene_SignEntryMenu.h | 4 ++ Minecraft.Client/Common/UI/UIStructs.h | 21 +++++++ .../Windows64/KeyboardMouseInput.cpp | 10 +-- .../Windows64/Windows64_Minecraft.cpp | 22 +++++-- 15 files changed, 327 insertions(+), 61 deletions(-) diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp index c810ad455..0be1694b7 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.cpp @@ -327,7 +327,15 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(LPVOID lpParam,bool bRes) void UIScene_AnvilMenu::handleEditNamePressed() { setIgnoreInput(true); -#if defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ +#ifdef _WINDOWS64 + KeyboardInitData kbData; + kbData.title = app.GetString(IDS_TITLE_RENAME); + kbData.initialText = m_textInputAnvil.getLabel(); + kbData.charLimit = 30; + kbData.lpParam = this; + kbData.Func = &UIScene_AnvilMenu::KeyboardCompleteCallbackNew; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +#elif defined(__PS3__) || defined(__ORBIS__) || defined __PSVITA__ int language = XGetLanguage(); switch(language) { @@ -346,6 +354,21 @@ void UIScene_AnvilMenu::handleEditNamePressed() #endif } +#ifdef _WINDOWS64 +int UIScene_AnvilMenu::KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted) +{ + UIScene_AnvilMenu *pClass = (UIScene_AnvilMenu *)lpParam; + pClass->setIgnoreInput(false); + if(bAccepted) + { + pClass->setEditNameValue(text); + pClass->m_itemName = text; + pClass->updateItemName(); + } + return 0; +} +#endif + void UIScene_AnvilMenu::setEditNameValue(const wstring &name) { m_textInputAnvil.setLabel(name); @@ -357,6 +380,8 @@ void UIScene_AnvilMenu::setEditNameEditable(bool enabled) void UIScene_AnvilMenu::setCostLabel(const wstring &label, bool canAfford) { + if(!getMovie()) return; + IggyDataValue result; IggyDataValue value[2]; @@ -373,6 +398,8 @@ void UIScene_AnvilMenu::setCostLabel(const wstring &label, bool canAfford) void UIScene_AnvilMenu::showCross(bool show) { + if(!getMovie()) return; + if(m_showingCross != show) { IggyDataValue result; diff --git a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.h b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.h index 3afc63338..3c68934d6 100644 --- a/Minecraft.Client/Common/UI/UIScene_AnvilMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_AnvilMenu.h @@ -2,6 +2,7 @@ #include "UIScene_AbstractContainerMenu.h" #include "IUIScene_AnvilMenu.h" +#include "UIStructs.h" #include "..\Minecraft.World\MerchantMenu.h" class InventoryMenu; @@ -55,7 +56,10 @@ protected: virtual UIControl *getSection(ESceneSection eSection); - static int KeyboardCompleteCallback(LPVOID lpParam,bool bRes); + static int KeyboardCompleteCallback(LPVOID lpParam, const bool bRes); +#ifdef _WINDOWS64 + static int KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif virtual void handleEditNamePressed(); virtual void setEditNameValue(const wstring &name); virtual void setEditNameEditable(bool enabled); diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp index f7cca84bf..df394f3ea 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp @@ -417,7 +417,17 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId) case eControl_EditWorldName: { m_bIgnoreInput=true; +#ifdef _WINDOWS64 + KeyboardInitData kbData; + kbData.title = app.GetString(IDS_CREATE_NEW_WORLD); + kbData.initialText = m_worldName; + kbData.charLimit = 25; + kbData.lpParam = this; + kbData.Func = &UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallbackNew; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +#else InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),(DWORD)0,25,&UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default); +#endif } break; case eControl_GameModeToggle: @@ -488,7 +498,7 @@ void UIScene_CreateWorldMenu::StartSharedLaunchFlow() if(pTexturePack==NULL) { -#if TO_BE_IMPLEMENTED +#if TO_BE IMPLEMENTED // They've selected a texture pack they don't have yet // upsell CXuiCtrl4JList::LIST_ITEM_INFO ListItem; @@ -712,11 +722,15 @@ void UIScene_CreateWorldMenu::handleTimerComplete(int id) }; } +extern char chGlobalText[256]; + void UIScene_CreateWorldMenu::handleGainFocus(bool navBack) { if(navBack) { m_checkboxOnline.setChecked(m_MoreOptionsParams.bOnlineGame); + + m_bIgnoreInput = false; } } @@ -742,6 +756,23 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bo return 0; } +#ifdef _WINDOWS64 +int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted) +{ + UIScene_CreateWorldMenu *pClass = (UIScene_CreateWorldMenu *)lpParam; + pClass->m_bIgnoreInput = false; + + if(bAccepted && !text.empty()) + { + pClass->m_editWorldName.setLabel(text.c_str()); + pClass->m_worldName = text; + } + + pClass->m_buttonCreateWorld.setEnable(!pClass->m_worldName.empty()); + return 0; +} +#endif + void UIScene_CreateWorldMenu::checkStateAndStartGame() { int primaryPad = ProfileManager.GetPrimaryPad(); @@ -778,7 +809,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // 4J Stu - This is a bit messy and is due to the library incorrectly returning false for IsSignedInLive if the npAvailability isn't SCE_OK UINT uiIDA[1]; uiIDA[0]=IDS_OK; - ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); + ui.RequestAlertMessage(IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, uiIDA, 1, iPadNotSignedInLive); } else { @@ -962,7 +993,7 @@ void UIScene_CreateWorldMenu::checkStateAndStartGame() // On Windows64, Xbox Live is unavailable. Skip QuadrantSignin and start directly. CreateGame(this, 0); #else - //ProfileManager.RequestSignInUI(false, false, false, true, false,&CScene_MultiGameCreate::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad()); + //ProfileManager.RequestSignInUI(false, false, false, true, false,&UIScene_CreateWorldMenu::StartGame_SignInReturned, this,ProfileManager.GetPrimaryPad()); SignInInfo info; info.Func = &UIScene_CreateWorldMenu::StartGame_SignInReturned; info.lpParam = this; @@ -1077,7 +1108,7 @@ void UIScene_CreateWorldMenu::CreateGame(UIScene_CreateWorldMenu* pClass, DWORD else { // random - wSeed=L""; + wSeed=L""; } // start the game diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.h b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.h index d6ae1c040..84c9e320e 100644 --- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.h @@ -67,39 +67,42 @@ public: virtual void handleTouchBoxRebuild(); -protected: - // TODO: This should be pure virtual in this class - virtual wstring getMoviePath(); - - virtual void handleTimerComplete(int id); - virtual void handleGainFocus(bool navBack); + protected: + // TODO: This should be pure virtual in this class + virtual wstring getMoviePath(); + + virtual void handleTimerComplete(int id); + virtual void handleGainFocus(bool navBack); -public: - // INPUT - virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); + public: + // INPUT + virtual void handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled); -private: - void StartSharedLaunchFlow(); - bool IsLocalMultiplayerAvailable(); + private: + void StartSharedLaunchFlow(); + bool IsLocalMultiplayerAvailable(); #ifdef _DURANGO - static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); + static void checkPrivilegeCallback(LPVOID lpParam, bool hasPrivilege, int iPad); #endif -protected: - static int KeyboardCompleteWorldNameCallback(LPVOID lpParam,const bool bRes); - void handlePress(F64 controlId, F64 childId); - void handleSliderMove(F64 sliderId, F64 currentValue); - - static void CreateGame(UIScene_CreateWorldMenu* pClass, DWORD dwLocalUsersMask); - static int ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int StartGame_SignInReturned(void *pParam,bool bContinue, int iPad); - static int MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result); + protected: + static int KeyboardCompleteWorldNameCallback(LPVOID lpParam,const bool bRes); +#ifdef _WINDOWS64 + static int KeyboardCompleteWorldNameCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif + void handlePress(F64 controlId, F64 childId); + void handleSliderMove(F64 sliderId, F64 currentValue); + + static void CreateGame(UIScene_CreateWorldMenu* pClass, DWORD dwLocalUsersMask); + static int ConfirmCreateReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); + static int StartGame_SignInReturned(void *pParam,bool bContinue, int iPad); + static int MustSignInReturnedPSN(void *pParam,int iPad,C4JStorage::EMessageResult result); #ifdef __ORBIS__ - //static int PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); - static int ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result); + //static int PSPlusReturned(void *pParam,int iPad,C4JStorage::EMessageResult result); + static int ContinueOffline(void *pParam,int iPad,C4JStorage::EMessageResult result); #endif - virtual void checkStateAndStartGame(); + virtual void checkStateAndStartGame(); }; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp index 2a8ac9f8e..7de592254 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp +++ b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.cpp @@ -112,8 +112,20 @@ void UIScene_DebugCreateSchematic::handlePress(F64 controlId, F64 childId) case eControl_EndX: case eControl_EndY: case eControl_EndZ: - m_keyboardCallbackControl = (eControls)((int)controlId); + m_keyboardCallbackControl = (eControls)((int)controlId); +#ifdef _WINDOWS64 + { + KeyboardInitData kbData; + kbData.title = L"Enter something"; + kbData.initialText = L""; + kbData.charLimit = 25; + kbData.lpParam = this; + kbData.Func = &UIScene_DebugCreateSchematic::KeyboardCompleteCallbackNew; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); + } +#else InputManager.RequestKeyboard(L"Enter something",L"",(DWORD)0,25,&UIScene_DebugCreateSchematic::KeyboardCompleteCallback,this,C_4JInput::EKeyboardMode_Default); +#endif break; }; } @@ -213,4 +225,53 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(LPVOID lpParam,bool b return 0; } + +#ifdef _WINDOWS64 +int UIScene_DebugCreateSchematic::KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted) +{ + UIScene_DebugCreateSchematic *pClass = (UIScene_DebugCreateSchematic *)lpParam; + if(!text.empty()) + { + int iVal = _fromString(text); + switch(pClass->m_keyboardCallbackControl) + { + case eControl_Name: + pClass->m_textInputName.setLabel(text.c_str()); + swprintf(pClass->m_data->name, 64, L"%ls", text.c_str()); + break; + case eControl_StartX: + pClass->m_textInputStartX.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->startX = iVal; + break; + case eControl_StartY: + pClass->m_textInputStartY.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->startY = iVal; + break; + case eControl_StartZ: + pClass->m_textInputStartZ.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->startZ = iVal; + break; + case eControl_EndX: + pClass->m_textInputEndX.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->endX = iVal; + break; + case eControl_EndY: + pClass->m_textInputEndY.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->endY = iVal; + break; + case eControl_EndZ: + pClass->m_textInputEndZ.setLabel(text.c_str()); + if(iVal >= (LEVEL_MAX_WIDTH * -16) || iVal < (LEVEL_MAX_WIDTH * 16)) + pClass->m_data->endZ = iVal; + break; + } + } + return 0; +} +#endif #endif \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.h b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.h index cbfe785d0..779744e86 100644 --- a/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.h +++ b/Minecraft.Client/Common/UI/UIScene_DebugCreateSchematic.h @@ -68,6 +68,9 @@ protected: virtual void handleCheckboxToggled(F64 controlId, bool selected); private: - static int KeyboardCompleteCallback(LPVOID lpParam,const bool bRes); + static int KeyboardCompleteCallback(LPVOID lpParam, const bool bRes); +#ifdef _WINDOWS64 + static int KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif }; #endif \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp index fb1cc301a..90924f17d 100644 --- a/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp +++ b/Minecraft.Client/Common/UI/UIScene_Keyboard.cpp @@ -1,19 +1,28 @@ #include "stdafx.h" #include "UI.h" #include "UIScene_Keyboard.h" +#include "..\..\Tesselator.h" #define KEYBOARD_DONE_TIMER_ID 0 #define KEYBOARD_DONE_TIMER_TIME 100 +extern char chGlobalText[256]; + UIScene_Keyboard::UIScene_Keyboard(int iPad, void *initData, UILayer *parentLayer) : UIScene(iPad, parentLayer) { // Setup all the Iggy references we need for this scene initialiseMovie(); - m_EnterTextLabel.init(L"Enter Sign Text"); + if (initData != NULL) + { + m_initData = *((KeyboardInitData *)initData); + } - m_KeyboardTextInput.init(L"", -1); - m_KeyboardTextInput.SetCharLimit(15); + wstring labelText = m_initData.title.empty() ? L"Enter Text" : m_initData.title; + m_EnterTextLabel.init(labelText); + + m_KeyboardTextInput.init(m_initData.initialText.empty() ? L"" : m_initData.initialText, -1); + m_KeyboardTextInput.SetCharLimit(m_initData.charLimit > 0 ? m_initData.charLimit : 15); m_ButtonSpace.init(L"Space", -1); m_ButtonCursorLeft.init(L"Cursor Left", -1); @@ -90,6 +99,12 @@ void UIScene_Keyboard::handleInput(int iPad, int key, bool repeat, bool pressed, switch(key) { case ACTION_MENU_CANCEL: +#ifdef _WINDOWS64 + if(m_initData.Func != NULL) + { + m_initData.Func(m_initData.lpParam, L"", false); + } +#endif navigateBack(); handled = true; break; @@ -176,6 +191,41 @@ void UIScene_Keyboard::KeyboardDonePressed() // Debug app.DebugPrintf("UI Keyboard - DONE - [%ls]\n", m_KeyboardTextInput.getLabel()); - // ToDo: Keyboard can now pass on its final string value and close itself down + // Capture the final string value from the keyboard text input + m_capturedText = m_KeyboardTextInput.getLabel(); + +#ifdef _WINDOWS64 + // Invoke the callback if one was provided + if(m_initData.Func != NULL) + { + m_initData.Func(m_initData.lpParam, m_capturedText, true); + } + + +#endif navigateBack(); +} + +void UIScene_Keyboard::render(S32 width, S32 height, C4JRender::eViewportType viewport) +{ + ui.setupRenderPosition(viewport); + + // Draw a semi transparent dark overlay behind the keyboard + glEnable(GL_BLEND); + glDisable(GL_TEXTURE_2D); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + glColor4f(0.0f, 0.0f, 0.0f, 1.0f); + + Tesselator *t = Tesselator::getInstance(); + t->begin(); + t->vertex(0.0f, (float)height, 0.0f); + t->vertex((float)width, (float)height, 0.0f); + t->vertex((float)width, 0.0f, 0.0f); + t->vertex(0.0f, 0.0f, 0.0f); + t->end(); + + glEnable(GL_TEXTURE_2D); + glDisable(GL_BLEND); + + UIScene::render(width, height, viewport); } \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_Keyboard.h b/Minecraft.Client/Common/UI/UIScene_Keyboard.h index f4e4c899d..055f8c2a3 100644 --- a/Minecraft.Client/Common/UI/UIScene_Keyboard.h +++ b/Minecraft.Client/Common/UI/UIScene_Keyboard.h @@ -1,11 +1,14 @@ #pragma once #include "UIScene.h" +#include "UIStructs.h" class UIScene_Keyboard : public UIScene { private: bool m_bKeyboardDonePressed; + KeyboardInitData m_initData; + wstring m_capturedText; protected: UIControl_Label m_EnterTextLabel; @@ -58,22 +61,25 @@ protected: // TODO: This should be pure virtual in this class virtual wstring getMoviePath(); -private: - void KeyboardDonePressed(); + private: + void KeyboardDonePressed(); -public: - virtual EUIScene getSceneType() { return eUIScene_Keyboard;} + public: + virtual EUIScene getSceneType() { return eUIScene_Keyboard;} - // Returns true if this scene handles input - //virtual bool stealsFocus() { return false; } + // RENDERING + virtual void render(S32 width, S32 height, C4JRender::eViewportType viewport); - // Returns true if this scene has focus for the pad passed in - //virtual bool hasFocus(int iPad) { return false; } - // Returns true if this scene has focus for the pad passed in + // Returns true if this scene handles input + //virtual bool stealsFocus() { return false; } + + // Returns true if this scene has focus for the pad passed in + //virtual bool hasFocus(int iPad) { return false; } + // Returns true if this scene has focus for the pad passed in #ifndef __PS3__ virtual bool hasFocus(int iPad) { return bHasFocus; } #endif - // Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden - virtual bool hidesLowerScenes() { return false; } + // Returns true if lower scenes in this scenes layer, or in any layer below this scenes layers should be hidden + virtual bool hidesLowerScenes() { return true; } }; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp index d6f89832c..7b6b3e14f 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.cpp @@ -573,7 +573,15 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) case eControl_EditSeed: { m_bIgnoreInput=true; -#ifdef __PS3__ +#ifdef _WINDOWS64 + KeyboardInitData kbData; + kbData.title = app.GetString(IDS_CREATE_NEW_WORLD_SEED); + kbData.initialText = m_editSeed.getLabel(); + kbData.charLimit = 60; + kbData.lpParam = this; + kbData.Func = &UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallbackNew; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +#elif defined(__PS3__) int language = XGetLanguage(); switch(language) { @@ -595,6 +603,19 @@ void UIScene_LaunchMoreOptionsMenu::handlePress(F64 controlId, F64 childId) } } +#ifdef _WINDOWS64 +int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted) +{ + UIScene_LaunchMoreOptionsMenu *pClass = (UIScene_LaunchMoreOptionsMenu *)lpParam; + pClass->m_bIgnoreInput = false; + if(bAccepted) + { + pClass->m_editSeed.setLabel(text.c_str()); + pClass->m_params->seed = text; + } + return 0; +} +#endif void UIScene_LaunchMoreOptionsMenu::handleSliderMove(F64 sliderId, F64 currentValue) { diff --git a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h index 367db10d3..be311adf1 100644 --- a/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_LaunchMoreOptionsMenu.h @@ -1,6 +1,7 @@ #pragma once #include "UIScene.h" +#include "UIStructs.h" class UIScene_LaunchMoreOptionsMenu : public UIScene { @@ -145,6 +146,9 @@ public: virtual void handleFocusChange(F64 controlId, F64 childId); virtual void handleTimerComplete(int id); static int KeyboardCompleteSeedCallback(LPVOID lpParam,const bool bRes); +#ifdef _WINDOWS64 + static int KeyboardCompleteSeedCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif virtual void handlePress(F64 controlId, F64 childId); virtual void handleSliderMove(F64 sliderId, F64 currentValue); diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp index c29bac2d3..d6da288d0 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.cpp @@ -171,7 +171,15 @@ void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) { m_iEditingLine = (int)controlId; m_bIgnoreInput = true; -#ifdef _XBOX_ONE +#ifdef _WINDOWS64 + KeyboardInitData kbData; + kbData.title = app.GetString(IDS_SIGN_TITLE); + kbData.initialText = m_textInputLines[m_iEditingLine].getLabel(); + kbData.charLimit = 15; + kbData.lpParam = this; + kbData.Func = &UIScene_SignEntryMenu::KeyboardCompleteCallbackNew; + ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData); +#elif defined(_XBOX_ONE) // 4J-PB - Xbox One uses the Windows virtual keyboard, and doesn't have the Xbox 360 Latin keyboard type, so we can't restrict the input set to alphanumeric. The closest we get is the emailSmtpAddress type. int language = XGetLanguage(); switch(language) @@ -193,6 +201,19 @@ void UIScene_SignEntryMenu::handlePress(F64 controlId, F64 childId) } } +#ifdef _WINDOWS64 +int UIScene_SignEntryMenu::KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted) +{ + UIScene_SignEntryMenu *pClass = (UIScene_SignEntryMenu *)lpParam; + pClass->m_bIgnoreInput = false; + if(bAccepted) + { + pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(text.c_str()); + } + return 0; +} +#endif + void UIScene_SignEntryMenu::handleDestroy() { #ifdef __PSVITA__ diff --git a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.h b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.h index 28b37d531..5ff5dab14 100644 --- a/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.h +++ b/Minecraft.Client/Common/UI/UIScene_SignEntryMenu.h @@ -1,6 +1,7 @@ #pragma once #include "UIScene.h" +#include "UIStructs.h" class SignTileEntity; @@ -54,5 +55,8 @@ public: protected: void handlePress(F64 controlId, F64 childId); static int KeyboardCompleteCallback(LPVOID lpParam,const bool bRes); +#ifdef _WINDOWS64 + static int KeyboardCompleteCallbackNew(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif virtual void handleDestroy(); }; \ No newline at end of file diff --git a/Minecraft.Client/Common/UI/UIStructs.h b/Minecraft.Client/Common/UI/UIStructs.h index c41f2276e..080d5621e 100644 --- a/Minecraft.Client/Common/UI/UIStructs.h +++ b/Minecraft.Client/Common/UI/UIStructs.h @@ -422,6 +422,27 @@ typedef struct _SignInInfo bool requireOnline; } SignInInfo; +// Keyboard +typedef struct _KeyboardInitData +{ + wstring initialText; + wstring title; + int charLimit; + LPVOID lpParam; +#ifdef _WINDOWS64 + int( *Func)(LPVOID lpParam, const wstring &text, bool bAccepted); +#endif + + _KeyboardInitData() + { + charLimit = 25; + lpParam = NULL; +#ifdef _WINDOWS64 + Func = NULL; +#endif + } +} KeyboardInitData; + // Credits typedef struct { diff --git a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp index fc7633947..ee8e5bcd1 100644 --- a/Minecraft.Client/Windows64/KeyboardMouseInput.cpp +++ b/Minecraft.Client/Windows64/KeyboardMouseInput.cpp @@ -66,7 +66,6 @@ void KeyboardMouseInput::OnKeyDown(WPARAM vk) { if (vk < 256) { - if (!m_keyState[vk]) m_keyPressedAccum[vk] = true; m_keyState[vk] = true; } } @@ -103,12 +102,9 @@ void KeyboardMouseInput::OnRawMouseInput(LPARAM lParam) void KeyboardMouseInput::OnMouseButton(int button, bool down) { - if (button >= 0 && button < 3) - { - if (down && !m_mouseButtons[button]) m_mousePressedAccum[button] = true; - if (!down && m_mouseButtons[button]) m_mouseReleasedAccum[button] = true; - m_mouseButtons[button] = down; - } + if (button < 0 || button >= 3) return; + + m_mouseButtons[button] = down; } void KeyboardMouseInput::OnMouseWheel(int delta) diff --git a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp index 78ab76fef..292217cad 100644 --- a/Minecraft.Client/Windows64/Windows64_Minecraft.cpp +++ b/Minecraft.Client/Windows64/Windows64_Minecraft.cpp @@ -1,4 +1,4 @@ -// Minecraft.cpp : Defines the entry point for the application. +// Minecraft.cpp : Defines the entry point for the application. // #include "stdafx.h" @@ -512,17 +512,31 @@ void ClearGlobalText() uint16_t *GetGlobalText() { //copy the ch text to ui16 - char * pchBuffer=(char *)ui16GlobalText; + char * pchBuffer=(char *)ui16GlobalText; for(int i=0;i<256;i++) { pchBuffer[i*2]=chGlobalText[i]; } return ui16GlobalText; } + void SeedEditBox() { - DialogBox(hMyInst, MAKEINTRESOURCE(IDD_SEED), - g_hWnd, reinterpret_cast(DlgProc)); + KeyboardInitData kbData; + + kbData.title = + reinterpret_cast(chGlobalText); + + kbData.initialText = + reinterpret_cast(chGlobalText); + + kbData.charLimit = 25; + kbData.lpParam = nullptr; + + ui.NavigateToScene( + ProfileManager.GetPrimaryPad(), + eUIScene_Keyboard, + &kbData); }