mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-08-20 09:57:10 +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.World/Headers/net.minecraft.world.level.tile.entity.h"
|
||||||
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
||||||
#include "../../Minecraft.Client/Minecraft.h"
|
#include "../../Minecraft.Client/Minecraft.h"
|
||||||
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||||
#include "UIScene_AnvilMenu.h"
|
#include "UIScene_AnvilMenu.h"
|
||||||
|
|
||||||
UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData,
|
UIScene_AnvilMenu::UIScene_AnvilMenu(int iPad, void* _initData,
|
||||||
|
|
@ -297,11 +298,9 @@ int UIScene_AnvilMenu::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
||||||
pClass->setIgnoreInput(false);
|
pClass->setIgnoreInput(false);
|
||||||
|
|
||||||
if (bRes) {
|
if (bRes) {
|
||||||
uint16_t pchText[128];
|
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
pClass->setEditNameValue(str);
|
||||||
InputManager.GetText(pchText);
|
pClass->m_itemName = std::move(str);
|
||||||
pClass->setEditNameValue((wchar_t*)pchText);
|
|
||||||
pClass->m_itemName = (wchar_t*)pchText;
|
|
||||||
pClass->updateItemName();
|
pClass->updateItemName();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -718,13 +718,10 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
|
||||||
pClass->m_bIgnoreInput = false;
|
pClass->m_bIgnoreInput = false;
|
||||||
// 4J HEG - No reason to set value if keyboard was cancelled
|
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||||
if (bRes) {
|
if (bRes) {
|
||||||
uint16_t pchText[128];
|
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
if (!str.empty()) {
|
||||||
InputManager.GetText(pchText);
|
pClass->m_editWorldName.setLabel(str);
|
||||||
|
pClass->m_worldName = std::move(str);
|
||||||
if (pchText[0] != 0) {
|
|
||||||
pClass->m_editWorldName.setLabel((wchar_t*)pchText);
|
|
||||||
pClass->m_worldName = (wchar_t*)pchText;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pClass->m_buttonCreateWorld.setEnable(!pClass->m_worldName.empty());
|
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 pccFriendsAllowed = true;
|
||||||
bool bContentRestricted = false;
|
bool bContentRestricted = false;
|
||||||
|
|
||||||
ProfileManager.AllowedPlayerCreatedContent(
|
GetAllowedPlayerCreatedContentFlags(ProfileManager.GetPrimaryPad(),
|
||||||
ProfileManager.GetPrimaryPad(), false, &pccAllowed,
|
false, &pccAllowed,
|
||||||
&pccFriendsAllowed);
|
&pccFriendsAllowed);
|
||||||
#if defined(__PS3__) || defined(__PSVITA__)
|
#if defined(__PS3__) || defined(__PSVITA__)
|
||||||
if (isOnlineGame && isSignedInLive) {
|
if (isOnlineGame && isSignedInLive) {
|
||||||
ProfileManager.GetChatAndContentRestrictions(
|
ProfileManager.GetChatAndContentRestrictions(
|
||||||
|
|
@ -1346,9 +1343,9 @@ int UIScene_CreateWorldMenu::StartGame_SignInReturned(void* pParam,
|
||||||
bool pccAllowed = true;
|
bool pccAllowed = true;
|
||||||
bool pccFriendsAllowed = true;
|
bool pccFriendsAllowed = true;
|
||||||
|
|
||||||
ProfileManager.AllowedPlayerCreatedContent(
|
GetAllowedPlayerCreatedContentFlags(ProfileManager.GetPrimaryPad(),
|
||||||
ProfileManager.GetPrimaryPad(), false, &pccAllowed,
|
false, &pccAllowed,
|
||||||
&pccFriendsAllowed);
|
&pccFriendsAllowed);
|
||||||
if (!pccAllowed && !pccFriendsAllowed) noUGC = true;
|
if (!pccAllowed && !pccFriendsAllowed) noUGC = true;
|
||||||
|
|
||||||
if (isOnlineGame && (noPrivileges || noUGC)) {
|
if (isOnlineGame && (noPrivileges || noUGC)) {
|
||||||
|
|
|
||||||
|
|
@ -141,12 +141,9 @@ int UIScene_DebugCreateSchematic::KeyboardCompleteCallback(void* lpParam,
|
||||||
UIScene_DebugCreateSchematic* pClass =
|
UIScene_DebugCreateSchematic* pClass =
|
||||||
(UIScene_DebugCreateSchematic*)lpParam;
|
(UIScene_DebugCreateSchematic*)lpParam;
|
||||||
|
|
||||||
uint16_t pchText[128];
|
const char* text = InputManager.GetText();
|
||||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
if (text[0] != '\0') {
|
||||||
InputManager.GetText(pchText);
|
std::wstring value = convStringToWstring(text);
|
||||||
|
|
||||||
if (pchText[0] != 0) {
|
|
||||||
std::wstring value = (wchar_t*)pchText;
|
|
||||||
int iVal = 0;
|
int iVal = 0;
|
||||||
if (!value.empty()) iVal = _fromString<int>(value);
|
if (!value.empty()) iVal = _fromString<int>(value);
|
||||||
switch (pClass->m_keyboardCallbackControl) {
|
switch (pClass->m_keyboardCallbackControl) {
|
||||||
|
|
|
||||||
|
|
@ -119,12 +119,9 @@ void UIScene_DebugSetCamera::handleCheckboxToggled(F64 controlId,
|
||||||
|
|
||||||
int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
int UIScene_DebugSetCamera::KeyboardCompleteCallback(void* lpParam, bool bRes) {
|
||||||
UIScene_DebugSetCamera* pClass = (UIScene_DebugSetCamera*)lpParam;
|
UIScene_DebugSetCamera* pClass = (UIScene_DebugSetCamera*)lpParam;
|
||||||
uint16_t pchText[2048]; //[128];
|
const char* text = InputManager.GetText();
|
||||||
ZeroMemory(pchText, 2048 /*128*/ * sizeof(uint16_t));
|
if (text[0] != '\0') {
|
||||||
InputManager.GetText(pchText);
|
std::wstring value = convStringToWstring(text);
|
||||||
|
|
||||||
if (pchText[0] != 0) {
|
|
||||||
std::wstring value = (wchar_t*)pchText;
|
|
||||||
double val = 0;
|
double val = 0;
|
||||||
if (!value.empty()) val = _fromString<double>(value);
|
if (!value.empty()) val = _fromString<double>(value);
|
||||||
switch (pClass->m_keyboardCallbackControl) {
|
switch (pClass->m_keyboardCallbackControl) {
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../../Minecraft.World/Platform/stdafx.h"
|
#include "../../Minecraft.World/Platform/stdafx.h"
|
||||||
#include "UI.h"
|
#include "UI.h"
|
||||||
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||||
#include "UIScene_LaunchMoreOptionsMenu.h"
|
#include "UIScene_LaunchMoreOptionsMenu.h"
|
||||||
|
|
||||||
#define GAME_CREATE_ONLINE_TIMER_ID 0
|
#define GAME_CREATE_ONLINE_TIMER_ID 0
|
||||||
|
|
@ -589,21 +590,13 @@ int UIScene_LaunchMoreOptionsMenu::KeyboardCompleteSeedCallback(void* lpParam,
|
||||||
bool bRes) {
|
bool bRes) {
|
||||||
UIScene_LaunchMoreOptionsMenu* pClass =
|
UIScene_LaunchMoreOptionsMenu* pClass =
|
||||||
(UIScene_LaunchMoreOptionsMenu*)lpParam;
|
(UIScene_LaunchMoreOptionsMenu*)lpParam;
|
||||||
pClass->m_bIgnoreInput = false;
|
|
||||||
// 4J HEG - No reason to set value if keyboard was cancelled
|
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||||
if (bRes) {
|
if (bRes) {
|
||||||
#ifdef __PSVITA__
|
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||||
// CD - Changed to 2048 [SCE_IME_MAX_TEXT_LENGTH]
|
pClass->m_editSeed.setLabel(str);
|
||||||
uint16_t pchText[2048];
|
pClass->m_params->seed = std::move(str);
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
pClass->m_bIgnoreInput = false;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1177,12 +1177,9 @@ int UIScene_LoadOrJoinMenu::KeyboardCompleteWorldNameCallback(void* lpParam,
|
||||||
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam;
|
UIScene_LoadOrJoinMenu* pClass = (UIScene_LoadOrJoinMenu*)lpParam;
|
||||||
pClass->m_bIgnoreInput = false;
|
pClass->m_bIgnoreInput = false;
|
||||||
if (bRes) {
|
if (bRes) {
|
||||||
std::uint16_t ui16Text[128];
|
const char* text = InputManager.GetText();
|
||||||
ZeroMemory(ui16Text, 128 * sizeof(std::uint16_t));
|
|
||||||
InputManager.GetText(ui16Text);
|
|
||||||
|
|
||||||
// check the name is valid
|
// check the name is valid
|
||||||
if (ui16Text[0] != 0) {
|
if (text[0] != '\0') {
|
||||||
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \
|
#if (defined __PS3__ || defined __ORBIS__ || defined _DURANGO || \
|
||||||
defined(__PSVITA__))
|
defined(__PSVITA__))
|
||||||
// open the save and overwrite the metadata
|
// open the save and overwrite the metadata
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include "../../Minecraft.World/Platform/stdafx.h"
|
#include "../../Minecraft.World/Platform/stdafx.h"
|
||||||
#include "UI.h"
|
#include "UI.h"
|
||||||
|
#include "../../Minecraft.World/Util/StringHelpers.h"
|
||||||
#include "UIScene_SignEntryMenu.h"
|
#include "UIScene_SignEntryMenu.h"
|
||||||
#include "../../Minecraft.Client/Minecraft.h"
|
#include "../../Minecraft.Client/Minecraft.h"
|
||||||
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
#include "../../Minecraft.Client/Player/MultiPlayerLocalPlayer.h"
|
||||||
|
|
@ -17,6 +18,7 @@ UIScene_SignEntryMenu::UIScene_SignEntryMenu(int iPad, void* _initData,
|
||||||
SignEntryScreenInput* initData = (SignEntryScreenInput*)_initData;
|
SignEntryScreenInput* initData = (SignEntryScreenInput*)_initData;
|
||||||
m_sign = initData->sign;
|
m_sign = initData->sign;
|
||||||
|
|
||||||
|
m_iEditingLine = 0;
|
||||||
m_bConfirmed = false;
|
m_bConfirmed = false;
|
||||||
m_bIgnoreInput = 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
|
// 4J HEG - No reason to set value if keyboard was cancelled
|
||||||
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
|
UIScene_SignEntryMenu* pClass = (UIScene_SignEntryMenu*)lpParam;
|
||||||
pClass->m_bIgnoreInput = false;
|
pClass->m_bIgnoreInput = false;
|
||||||
if (bRes) {
|
if (bRes && pClass->m_iEditingLine >= 0 && pClass->m_iEditingLine < 4) {
|
||||||
uint16_t pchText[128];
|
std::wstring str = convStringToWstring(InputManager.GetText());
|
||||||
ZeroMemory(pchText, 128 * sizeof(uint16_t));
|
if (str.size() > 15) str.resize(15);
|
||||||
InputManager.GetText(pchText);
|
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(str);
|
||||||
pClass->m_textInputLines[pClass->m_iEditingLine].setLabel(
|
|
||||||
(wchar_t*)pchText);
|
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,11 +3,11 @@
|
||||||
"4jlibs": {
|
"4jlibs": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1774012501,
|
"lastModified": 1774836469,
|
||||||
"narHash": "sha256-NoM5LtKcU+3LFPVZUtep1L+hfZS6YSQ4P/xkJU/2NY4=",
|
"narHash": "sha256-ukp6tLThQugPlREYFDDB6IaunjGte08f0Ler/c8cvaY=",
|
||||||
"owner": "4jcraft",
|
"owner": "4jcraft",
|
||||||
"repo": "4jlibs",
|
"repo": "4jlibs",
|
||||||
"rev": "df5f4a1fc3288fdc021b3d8ee2abaed3083de460",
|
"rev": "ab37891dabba90cf1e568660f750cebf46ba83f6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue