mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-10 20:17:14 +00:00
Merge pull request #344 from MatthewBeshay/feat/text-input-support
Feat/text input support
This commit is contained in:
commit
e7af3b42bb
|
|
@ -4,6 +4,7 @@
|
|||
#include "../../Minecraft.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
||||
#include "../../Minecraft.Client/Minecraft.h"
|
||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||
#include "UIScene_AnvilMenu.h"
|
||||
|
||||
UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData,
|
||||
|
|
@ -297,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((wchar_t*)pchText);
|
||||
pClass->m_itemName = (wchar_t*)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((wchar_t*)pchText);
|
||||
pClass->m_worldName = (wchar_t*)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());
|
||||
|
|
@ -901,9 +898,9 @@ IDS_PRO_NOTONLINE_TEXT, uiIDA, 1, ProfileManager.GetPrimaryPad()); return;
|
|||
bool pccFriendsAllowed = true;
|
||||
bool bContentRestricted = false;
|
||||
|
||||
ProfileManager.AllowedPlayerCreatedContent(
|
||||
ProfileManager.GetPrimaryPad(), false, &pccAllowed,
|
||||
&pccFriendsAllowed);
|
||||
GetAllowedPlayerCreatedContentFlags(ProfileManager.GetPrimaryPad(),
|
||||
false, &pccAllowed,
|
||||
&pccFriendsAllowed);
|
||||
#if defined(__PS3__) || defined(__PSVITA__)
|
||||
if (isOnlineGame && isSignedInLive) {
|
||||
ProfileManager.GetChatAndContentRestrictions(
|
||||
|
|
@ -1346,9 +1343,9 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam,
|
|||
bool pccAllowed = true;
|
||||
bool pccFriendsAllowed = true;
|
||||
|
||||
ProfileManager.AllowedPlayerCreatedContent(
|
||||
ProfileManager.GetPrimaryPad(), false, &pccAllowed,
|
||||
&pccFriendsAllowed);
|
||||
GetAllowedPlayerCreatedContentFlags(ProfileManager.GetPrimaryPad(),
|
||||
false, &pccAllowed,
|
||||
&pccFriendsAllowed);
|
||||
if (!pccAllowed && !pccFriendsAllowed) noUGC = true;
|
||||
|
||||
if (isOnlineGame && (noPrivileges || noUGC)) {
|
||||
|
|
|
|||
|
|
@ -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 = (wchar_t*)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 = (wchar_t*)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) {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "../../Minecraft.World/Platform/stdafx.h"
|
||||
#include "UI.h"
|
||||
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||
#include "UIScene_LaunchMoreOptionsMenu.h"
|
||||
|
||||
#define GAME_CREATE_ONLINE_TIMER_ID 0
|
||||
|
|
@ -589,21 +590,13 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void* lpParam,
|
|||
bool bRes) {
|
||||
UIScene_LaunchMoreOptionsMenu* pClass =
|
||||
(UIScene_LaunchMoreOptionsMenu*)lpParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
// 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((wchar_t*)pchText);
|
||||
pClass->m_params->seed = (wchar_t*)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
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
@ -17,6 +18,7 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void* _initData,
|
|||
SignEntryScreenInput* initData = (SignEntryScreenInput*)_initData;
|
||||
m_sign = initData->sign;
|
||||
|
||||
m_iEditingLine = 0;
|
||||
m_bConfirmed = false;
|
||||
m_bIgnoreInput = false;
|
||||
|
||||
|
|
@ -140,12 +142,10 @@ int UIScene_SignEntryMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
|||
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
|
||||
pClass->m_bIgnoreInput = false;
|
||||
if (bRes) {
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
||||
InputManager.GetText(pchText);
|
||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(
|
||||
(wchar_t*)pchText);
|
||||
if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) {
|
||||
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||
if (str.size() > 15) str.resize(15);
|
||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,11 @@
|
|||
"4jlibs": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1774012501,
|
||||
"narHash": "sha256-NoM5LtKcU+3LFPVZUtep1L+hfZS6YSQ4P/xkJU/2NY4=",
|
||||
"lastModified": 1774836469,
|
||||
"narHash": "sha256-ukp6tLThQugPlREYFDDB6IaunjGte08f0Ler/c8cvaY=",
|
||||
"owner": "4jcraft",
|
||||
"repo": "4jlibs",
|
||||
"rev": "df5f4a1fc3288fdc021b3d8ee2abaed3083de460",
|
||||
"rev": "ab37891dabba90cf1e568660f750cebf46ba83f6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
|
|
|||
Loading…
Reference in a new issue