Add cancel join

Adds the Cancel Join tooltip to the "Connecting to host"
progress bar
This commit is contained in:
irice7 2026-03-09 11:00:48 -07:00 committed by neoapps-dev
parent 0073f5569b
commit e8ac5b16ea
3 changed files with 38 additions and 0 deletions

View file

@ -54,6 +54,8 @@ int64_t CGameNetworkManager::messageQueue[512];
int64_t CGameNetworkManager::byteQueue[512]; int64_t CGameNetworkManager::byteQueue[512];
int CGameNetworkManager::messageQueuePos = 0; int CGameNetworkManager::messageQueuePos = 0;
CRITICAL_SECTION bCancelRequestedCS;
CGameNetworkManager::CGameNetworkManager() CGameNetworkManager::CGameNetworkManager()
{ {
m_bInitialised = false; m_bInitialised = false;
@ -80,9 +82,12 @@ void CGameNetworkManager::Initialise()
#else #else
s_pPlatformNetworkManager = new CPlatformNetworkManagerStub(); s_pPlatformNetworkManager = new CPlatformNetworkManagerStub();
#endif #endif
m_bCancelRequested = false;
s_pPlatformNetworkManager->Initialise( this, flagIndexSize ); s_pPlatformNetworkManager->Initialise( this, flagIndexSize );
m_bNetworkThreadRunning = false; m_bNetworkThreadRunning = false;
m_bInitialised = true; m_bInitialised = true;
InitializeCriticalSection(&bCancelRequestedCS);
} }
void CGameNetworkManager::Terminate() void CGameNetworkManager::Terminate()
@ -435,6 +440,24 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
app.DebugPrintf("ticking connection A\n"); app.DebugPrintf("ticking connection A\n");
connection->tick(); connection->tick();
EnterCriticalSection(&bCancelRequestedCS);
bool bCancelled = g_NetworkManager.m_bCancelRequested;
if (bCancelled)
{
if (!app.GetGameStarted())
{
app.DebugPrintf("Cancel requested, closing connection\n");
g_NetworkManager.m_bCancelRequested = false;
LeaveCriticalSection(&bCancelRequestedCS);
connection->close();
break;
}
}
LeaveCriticalSection(&bCancelRequestedCS);
// 4J Stu - We were ticking this way too fast which could cause the connection to time out // 4J Stu - We were ticking this way too fast which could cause the connection to time out
// The connections should tick at 20 per second // The connections should tick at 20 per second
Sleep(50); Sleep(50);
@ -552,6 +575,10 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft *minecraft, LPVOID lpParame
else if ( connection->isClosed() || !IsInSession()) else if ( connection->isClosed() || !IsInSession())
{ {
// assert(false); // assert(false);
// Set to NULL because we're returning to home
// The level is not reset when you leave the progress UI which causes a crash
Minecraft::GetInstance()->setLevel(NULL);
MinecraftServer::HaltServer(); MinecraftServer::HaltServer();
return false; return false;
} }
@ -769,6 +796,9 @@ CGameNetworkManager::eJoinGameResult CGameNetworkManager::JoinGame(FriendSession
void CGameNetworkManager::CancelJoinGame(LPVOID lpParam) void CGameNetworkManager::CancelJoinGame(LPVOID lpParam)
{ {
EnterCriticalSection(&bCancelRequestedCS);
g_NetworkManager.m_bCancelRequested = true;
LeaveCriticalSection(&bCancelRequestedCS);
#ifdef _XBOX_ONE #ifdef _XBOX_ONE
s_pPlatformNetworkManager->CancelJoinGame(); s_pPlatformNetworkManager->CancelJoinGame();
#endif #endif
@ -1452,6 +1482,9 @@ void CGameNetworkManager::StateChange_AnyToStarting()
LoadingInputParams *loadingParams = new LoadingInputParams(); LoadingInputParams *loadingParams = new LoadingInputParams();
loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc; loadingParams->func = &CGameNetworkManager::RunNetworkGameThreadProc;
loadingParams->lpParam = nullptr; loadingParams->lpParam = nullptr;
loadingParams->cancelText = IDS_TOOLTIPS_CANCEL_JOIN;
loadingParams->cancelFunc = &CGameNetworkManager::CancelJoinGame;
loadingParams->waitForThreadToDelete = TRUE;
UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData(); UIFullscreenProgressCompletionData *completionData = new UIFullscreenProgressCompletionData();
completionData->bShowBackground=TRUE; completionData->bShowBackground=TRUE;

View file

@ -213,6 +213,7 @@ private:
int GetJoiningReadyPercentage(); int GetJoiningReadyPercentage();
bool m_bLastDisconnectWasLostRoomOnly; bool m_bLastDisconnectWasLostRoomOnly;
bool m_bFullSessionMessageOnNextSessionChange; bool m_bFullSessionMessageOnNextSessionChange;
bool m_bCancelRequested;
#if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__ #if defined __PS3__ || defined __PSVITA__ || defined __ORBIS__
bool m_bSignedOutofPSN; bool m_bSignedOutofPSN;
#endif #endif

View file

@ -287,7 +287,11 @@ void UIScene_FullscreenProgress::handleInput(int iPad, int key, bool repeat, boo
case ACTION_MENU_CANCEL: case ACTION_MENU_CANCEL:
if( pressed && m_cancelFunc != nullptr && !m_bWasCancelled ) if( pressed && m_cancelFunc != nullptr && !m_bWasCancelled )
{ {
m_cancelText = -1;
updateTooltips();
m_bWasCancelled = true; m_bWasCancelled = true;
m_cancelFunc( m_cancelFuncParam ); m_cancelFunc( m_cancelFuncParam );
} }
break; break;