Add text input support: safe uint16_t* to wstring conversion

Replace unsafe (wchar_t*)pchText casts with uint16_to_wstring() in all
keyboard callbacks. The direct cast is incorrect on platforms where
wchar_t is 4 bytes (Linux/macOS). New helpers in StringHelpers route
through u16string for proper UTF-16 to wchar_t conversion.

- Add uint16_len, uint16_to_u16string, uint16_to_wstring to StringHelpers
- Fix casts in AnvilMenu, CreateWorldMenu, DebugCreateSchematic,
  DebugSetCamera, LaunchMoreOptionsMenu, SignEntryMenu
- Truncate sign text to 15 chars in SignEntryMenu
- Move m_bIgnoreInput reset after if-block in LaunchMoreOptionsMenu
This commit is contained in:
MatthewBeshay
2026-03-30 12:46:50 +11:00
parent dcc937da5e
commit 1ead072c45
8 changed files with 39 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
#include "../../Minecraft.World/Platform/stdafx.h"
#include "UI.h"
#include "../../Minecraft.World/Util/StringHelpers.h"
#include "UIScene_SignEntryMenu.h"
#include "../../Minecraft.Client/Minecraft.h"
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
@@ -144,8 +145,9 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
uint16_t pchText[128];
ZeroMemory(pchText, 128 * sizeof(uint16_t));
InputManager.GetText(pchText);
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(
(wchar_t*)pchText);
std::wstring str = uint16_to_wstring(pchText);
str.resize(15);
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
}
return 0;
}