mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-23 07:23:05 +00:00
refactor: use convStringToWstring for text input instead of uint16 helpers
GetText now returns UTF-8 directly so callers go through simdutf via convStringToWstring(). Remove dead uint16_to_wstring helpers.
This commit is contained in:
parent
e89198f56c
commit
95e0a14b36
|
|
@ -298,11 +298,9 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
|||
pClass->setIgnoreInput(false);
|
||||
|
||||
if (bRes) {
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
pClass->setEditNameValue(uint16_to_wstring(pchText));
|
||||
pClass->m_itemName = uint16_to_wstring(pchText);
|
||||
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||
pClass->setEditNameValue(str);
|
||||
pClass->m_itemName = std::move(str);
|
||||
pClass->updateItemName();
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -718,13 +718,10 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
|
|||
pClass->m_bIgnoreInput = false;
|
||||
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||
if (bRes) {
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
|
||||
if (pchText[0] != 0) {
|
||||
pClass->m_editWorldName.setLabel(uint16_to_wstring(pchText));
|
||||
pClass->m_worldName = uint16_to_wstring(pchText);
|
||||
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||
if (!str.empty()) {
|
||||
pClass->m_editWorldName.setLabel(str);
|
||||
pClass->m_worldName = std::move(str);
|
||||
}
|
||||
|
||||
pClass->m_buttonCreateWorld.setEnable(!pClass->m_worldName.empty());
|
||||
|
|
|
|||
|
|
@ -141,12 +141,9 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void* lpParam,
|
|||
UIScene_DebugCreateSchematic* pClass =
|
||||
(UIScene_DebugCreateSchematic*)lpParam;
|
||||
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
|
||||
if (pchText[0] != 0) {
|
||||
std::wstring value = uint16_to_wstring(pchText);
|
||||
const char* text = InputManager.GetText();
|
||||
if (text[0] != '\0') {
|
||||
std::wstring value = convStringToWstring(text);
|
||||
int iVal = 0;
|
||||
if (!value.empty()) iVal = _fromString<int>(value);
|
||||
switch (pClass->m_keyboardCallbackControl) {
|
||||
|
|
|
|||
|
|
@ -119,12 +119,9 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId,
|
|||
|
||||
int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
||||
UIScene_DebugSetCamera* pClass = (UIScene_DebugSetCamera*)lpParam;
|
||||
uint16_t pchText[2048]; //[128];
|
||||
ZeroMemory(pchText, 2048 /*128*/ * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
|
||||
if (pchText[0] != 0) {
|
||||
std::wstring value = uint16_to_wstring(pchText);
|
||||
const char* text = InputManager.GetText();
|
||||
if (text[0] != '\0') {
|
||||
std::wstring value = convStringToWstring(text);
|
||||
double val = 0;
|
||||
if (!value.empty()) val = _fromString<double>(value);
|
||||
switch (pClass->m_keyboardCallbackControl) {
|
||||
|
|
|
|||
|
|
@ -592,17 +592,9 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void* lpParam,
|
|||
(UIScene_LaunchMoreOptionsMenu*)lpParam;
|
||||
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||
if (bRes) {
|
||||
#ifdef __PSVITA__
|
||||
// CD - Changed to 2048 [SCE_IME_MAX_TEXT_LENGTH]
|
||||
uint16_t pchText[2048];
|
||||
ZeroMemory(pchText, 2048 * sizeof(uint16_t));
|
||||
#else
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
#endif
|
||||
InputManager.GetText(pchText);
|
||||
pClass->m_editSeed.setLabel(uint16_to_wstring(pchText));
|
||||
pClass->m_params->seed = uint16_to_wstring(pchText);
|
||||
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||
pClass->m_editSeed.setLabel(str);
|
||||
pClass->m_params->seed = std::move(str);
|
||||
}
|
||||
pClass->m_bIgnoreInput = false;
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -1177,12 +1177,9 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
|
|||
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
if (bRes) {
|
||||
std::uint16_t ui16Text[128];
|
||||
ZeroMemory(ui16Text, 128 * sizeof(std::uint16_t));
|
||||
InputManager.GetText(ui16Text);
|
||||
|
||||
const char* text = InputManager.GetText();
|
||||
// check the name is valid
|
||||
if (ui16Text[0] != 0) {
|
||||
if (text[0] != '\0') {
|
||||
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \
|
||||
defined(__PSVITA__))
|
||||
// open the save and overwrite the metadata
|
||||
|
|
|
|||
|
|
@ -143,10 +143,7 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
|||
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) {
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
std::wstring str = uint16_to_wstring(pchText);
|
||||
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||
if (str.size() > 15) str.resize(15);
|
||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,18 +36,6 @@ bool equalsIgnoreCase(const std::wstring& a, const std::wstring& b) {
|
|||
return out;
|
||||
}
|
||||
|
||||
size_t uint16_len(const uint16_t* str) {
|
||||
return std::char_traits<char16_t>::length(
|
||||
reinterpret_cast<const char16_t*>(str));
|
||||
}
|
||||
|
||||
std::u16string uint16_to_u16string(const uint16_t* str) {
|
||||
return std::u16string(reinterpret_cast<const char16_t*>(str), uint16_len(str));
|
||||
}
|
||||
|
||||
std::wstring uint16_to_wstring(const uint16_t* str) {
|
||||
return u16string_to_wstring(uint16_to_u16string(str));
|
||||
}
|
||||
|
||||
std::wstring convStringToWstring(const std::string& converting) {
|
||||
std::wstring converted(converting.length(), L' ');
|
||||
|
|
|
|||
|
|
@ -29,9 +29,6 @@ T _fromHEXString(const std::wstring& s) {
|
|||
return t;
|
||||
}
|
||||
|
||||
size_t uint16_len(const uint16_t* str);
|
||||
std::u16string uint16_to_u16string(const uint16_t* str);
|
||||
std::wstring uint16_to_wstring(const uint16_t* str);
|
||||
|
||||
std::wstring convStringToWstring(const std::string& converting);
|
||||
std::wstring u16string_to_wstring(const std::u16string& converting);
|
||||
|
|
|
|||
Loading…
Reference in a new issue