aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp')
-rw-r--r--Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp83
1 files changed, 83 insertions, 0 deletions
diff --git a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp
index f2ecd0d4..2bd06bc6 100644
--- a/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp
+++ b/Minecraft.Client/Common/UI/UIScene_CreateWorldMenu.cpp
@@ -84,6 +84,10 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay
m_iGameModeId = GameType::SURVIVAL->getId();
m_pDLCPack = NULL;
m_bRebuildTouchBoxes = false;
+#ifdef _WINDOWS64
+ m_bDirectEditing = false;
+ m_iDirectEditCooldown = 0;
+#endif
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
@@ -289,6 +293,54 @@ void UIScene_CreateWorldMenu::tick()
{
UIScene::tick();
+#ifdef _WINDOWS64
+ if (m_iDirectEditCooldown > 0)
+ m_iDirectEditCooldown--;
+
+ if (m_bDirectEditing)
+ {
+ wchar_t ch;
+ bool changed = false;
+ while (g_KBMInput.ConsumeChar(ch))
+ {
+ if (ch == 0x08) // backspace
+ {
+ if (!m_worldName.empty())
+ {
+ m_worldName.pop_back();
+ changed = true;
+ }
+ }
+ else if (ch == 0x0D) // enter - confirm
+ {
+ m_bDirectEditing = false;
+ m_iDirectEditCooldown = 4; // absorb the matching ACTION_MENU_OK that follows
+ m_editWorldName.setLabel(m_worldName.c_str());
+ }
+ else if ((int)m_worldName.length() < 25)
+ {
+ m_worldName += ch;
+ changed = true;
+ }
+ }
+
+ // Escape cancels and restores the original name
+ if (m_bDirectEditing && g_KBMInput.IsKeyPressed(VK_ESCAPE))
+ {
+ m_worldName = m_worldNameBeforeEdit;
+ m_bDirectEditing = false;
+ m_iDirectEditCooldown = 4;
+ m_editWorldName.setLabel(m_worldName.c_str());
+ m_buttonCreateWorld.setEnable(!m_worldName.empty());
+ }
+ else if (changed)
+ {
+ m_editWorldName.setLabel(m_worldName.c_str());
+ m_buttonCreateWorld.setEnable(!m_worldName.empty());
+ }
+ }
+#endif
+
if(m_iSetTexturePackDescription >= 0 )
{
UpdateTexturePackDescription( m_iSetTexturePackDescription );
@@ -354,6 +406,9 @@ int UIScene_CreateWorldMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::E
void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
{
if(m_bIgnoreInput) return;
+#ifdef _WINDOWS64
+ if (m_bDirectEditing || m_iDirectEditCooldown > 0) { handled = true; return; }
+#endif
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
@@ -408,6 +463,9 @@ void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, bool p
void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
{
if(m_bIgnoreInput) return;
+#ifdef _WINDOWS64
+ if (m_bDirectEditing || m_iDirectEditCooldown > 0) return;
+#endif
//CD - Added for audio
ui.PlayUISFX(eSFX_Press);
@@ -417,7 +475,28 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
case eControl_EditWorldName:
{
m_bIgnoreInput=true;
+#ifdef _WINDOWS64
+ if (Win64_IsControllerConnected())
+ {
+ UIKeyboardInitData kbData;
+ kbData.title = app.GetString(IDS_CREATE_NEW_WORLD);
+ kbData.defaultText = m_editWorldName.getLabel();
+ kbData.maxChars = 25;
+ kbData.callback = &UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback;
+ kbData.lpParam = this;
+ ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData);
+ }
+ else
+ {
+ // PC without controller: edit the name field directly in-place.
+ m_bIgnoreInput = false; // Don't block input - m_bDirectEditing is the guard
+ m_worldNameBeforeEdit = m_worldName;
+ m_bDirectEditing = true;
+ g_KBMInput.ClearCharBuffer();
+ }
+#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:
@@ -729,7 +808,11 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bo
{
uint16_t pchText[128];
ZeroMemory(pchText, 128 * sizeof(uint16_t) );
+#ifdef _WINDOWS64
+ Win64_GetKeyboardText(pchText, 128);
+#else
InputManager.GetText(pchText);
+#endif
if(pchText[0]!=0)
{