mirror of
https://github.com/vcmi/vcmi.git
synced 2025-04-11 11:31:52 +02:00
Unblock UI while tutorial loading
This commit is contained in:
parent
f4869cbfb0
commit
ef7008a753
@ -386,18 +386,29 @@ void CMainMenu::startTutorial()
|
|||||||
|
|
||||||
CMainMenu::openLobby(ESelectionScreen::newGame, true, nullptr, ELoadMode::NONE);
|
CMainMenu::openLobby(ESelectionScreen::newGame, true, nullptr, ELoadMode::NONE);
|
||||||
|
|
||||||
GH.dispatchMainThread([mapInfo](){
|
std::thread waitForConnectionThread([mapInfo](){
|
||||||
while(!CSH->c || !CSH->c->handler)
|
boost::this_thread::sleep(boost::posix_time::milliseconds(100)); //delay this thread
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
|
||||||
|
|
||||||
while(!CSH->mi || mapInfo->fileURI != CSH->mi->fileURI)
|
//connecting to server
|
||||||
|
while(CSH->state != EClientState::LOBBY)
|
||||||
{
|
{
|
||||||
CSH->setMapInfo(mapInfo);
|
if(CSH->state == EClientState::CONNECTION_CANCELLED || CSH->state == EClientState::NONE)
|
||||||
|
return;
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||||
}
|
}
|
||||||
|
|
||||||
CSH->sendStartGame();
|
//start game from main thread
|
||||||
|
GH.dispatchMainThread([mapInfo]()
|
||||||
|
{
|
||||||
|
while(!CSH->si || mapInfo->fileURI != CSH->si->mapname)
|
||||||
|
{
|
||||||
|
CSH->setMapInfo(mapInfo);
|
||||||
|
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||||
|
}
|
||||||
|
CSH->sendStartGame();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
waitForConnectionThread.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<CMainMenu> CMainMenu::create()
|
std::shared_ptr<CMainMenu> CMainMenu::create()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user