Fix save list, delete save, exit without saving, and blank username on Windows64 (#539)
* Fix world save rename not applying new name
KeyboardCompleteWorldNameCallback had no _WINDOWS64 branch, so the
typed name was validated then silently discarded on every rename attempt.
Write the new name to a worldname.txt sidecar file next to the save
(Windows64\GameHDD\{folder}\worldname.txt) and update the in-memory
display name immediately. ReadLevelNameFromSaveFile now checks for this
sidecar first so renamed saves persist correctly across restarts.
* Fixed gamertag being blank upon renaming and re-joining a save
* Save deletion fix, exiting without saving fix
* Add native in-game keyboard UI for world naming and renaming
This commit is contained in:
@@ -84,6 +84,10 @@ UIScene_CreateWorldMenu::UIScene_CreateWorldMenu(int iPad, void *initData, UILay
|
||||
m_iGameModeId = GameType::SURVIVAL->getId();
|
||||
m_pDLCPack = NULL;
|
||||
m_bRebuildTouchBoxes = false;
|
||||
#ifdef _WINDOWS64
|
||||
m_bDirectEditing = false;
|
||||
m_iDirectEditCooldown = 0;
|
||||
#endif
|
||||
|
||||
m_bMultiplayerAllowed = ProfileManager.IsSignedInLive( m_iPad ) && ProfileManager.AllowedToPlayMultiplayer(m_iPad);
|
||||
// 4J-PB - read the settings for the online flag. We'll only save this setting if the user changed it.
|
||||
@@ -289,6 +293,54 @@ void UIScene_CreateWorldMenu::tick()
|
||||
{
|
||||
UIScene::tick();
|
||||
|
||||
#ifdef _WINDOWS64
|
||||
if (m_iDirectEditCooldown > 0)
|
||||
m_iDirectEditCooldown--;
|
||||
|
||||
if (m_bDirectEditing)
|
||||
{
|
||||
wchar_t ch;
|
||||
bool changed = false;
|
||||
while (g_KBMInput.ConsumeChar(ch))
|
||||
{
|
||||
if (ch == 0x08) // backspace
|
||||
{
|
||||
if (!m_worldName.empty())
|
||||
{
|
||||
m_worldName.pop_back();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
else if (ch == 0x0D) // enter - confirm
|
||||
{
|
||||
m_bDirectEditing = false;
|
||||
m_iDirectEditCooldown = 4; // absorb the matching ACTION_MENU_OK that follows
|
||||
m_editWorldName.setLabel(m_worldName.c_str());
|
||||
}
|
||||
else if ((int)m_worldName.length() < 25)
|
||||
{
|
||||
m_worldName += ch;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Escape cancels and restores the original name
|
||||
if (m_bDirectEditing && g_KBMInput.IsKeyPressed(VK_ESCAPE))
|
||||
{
|
||||
m_worldName = m_worldNameBeforeEdit;
|
||||
m_bDirectEditing = false;
|
||||
m_iDirectEditCooldown = 4;
|
||||
m_editWorldName.setLabel(m_worldName.c_str());
|
||||
m_buttonCreateWorld.setEnable(!m_worldName.empty());
|
||||
}
|
||||
else if (changed)
|
||||
{
|
||||
m_editWorldName.setLabel(m_worldName.c_str());
|
||||
m_buttonCreateWorld.setEnable(!m_worldName.empty());
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if(m_iSetTexturePackDescription >= 0 )
|
||||
{
|
||||
UpdateTexturePackDescription( m_iSetTexturePackDescription );
|
||||
@@ -354,6 +406,9 @@ int UIScene_CreateWorldMenu::ContinueOffline(void *pParam,int iPad,C4JStorage::E
|
||||
void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, bool pressed, bool released, bool &handled)
|
||||
{
|
||||
if(m_bIgnoreInput) return;
|
||||
#ifdef _WINDOWS64
|
||||
if (m_bDirectEditing || m_iDirectEditCooldown > 0) { handled = true; return; }
|
||||
#endif
|
||||
|
||||
ui.AnimateKeyPress(m_iPad, key, repeat, pressed, released);
|
||||
|
||||
@@ -408,6 +463,9 @@ void UIScene_CreateWorldMenu::handleInput(int iPad, int key, bool repeat, bool p
|
||||
void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
|
||||
{
|
||||
if(m_bIgnoreInput) return;
|
||||
#ifdef _WINDOWS64
|
||||
if (m_bDirectEditing || m_iDirectEditCooldown > 0) return;
|
||||
#endif
|
||||
|
||||
//CD - Added for audio
|
||||
ui.PlayUISFX(eSFX_Press);
|
||||
@@ -417,7 +475,28 @@ void UIScene_CreateWorldMenu::handlePress(F64 controlId, F64 childId)
|
||||
case eControl_EditWorldName:
|
||||
{
|
||||
m_bIgnoreInput=true;
|
||||
#ifdef _WINDOWS64
|
||||
if (Win64_IsControllerConnected())
|
||||
{
|
||||
UIKeyboardInitData kbData;
|
||||
kbData.title = app.GetString(IDS_CREATE_NEW_WORLD);
|
||||
kbData.defaultText = m_editWorldName.getLabel();
|
||||
kbData.maxChars = 25;
|
||||
kbData.callback = &UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback;
|
||||
kbData.lpParam = this;
|
||||
ui.NavigateToScene(m_iPad, eUIScene_Keyboard, &kbData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// PC without controller: edit the name field directly in-place.
|
||||
m_bIgnoreInput = false; // Don't block input - m_bDirectEditing is the guard
|
||||
m_worldNameBeforeEdit = m_worldName;
|
||||
m_bDirectEditing = true;
|
||||
g_KBMInput.ClearCharBuffer();
|
||||
}
|
||||
#else
|
||||
InputManager.RequestKeyboard(app.GetString(IDS_CREATE_NEW_WORLD),m_editWorldName.getLabel(),(DWORD)0,25,&UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback,this,C_4JInput::EKeyboardMode_Default);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
case eControl_GameModeToggle:
|
||||
@@ -729,7 +808,11 @@ int UIScene_CreateWorldMenu::KeyboardCompleteWorldNameCallback(LPVOID lpParam,bo
|
||||
{
|
||||
uint16_t pchText[128];
|
||||
ZeroMemory(pchText, 128 * sizeof(uint16_t) );
|
||||
#ifdef _WINDOWS64
|
||||
Win64_GetKeyboardText(pchText, 128);
|
||||
#else
|
||||
InputManager.GetText(pchText);
|
||||
#endif
|
||||
|
||||
if(pchText[0]!=0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user