mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-07-15 18:58:12 +00:00
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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user