mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-25 22:42:04 +02:00
Tutorial implemented
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "../../lib/serializer/CTypeList.h"
|
||||
#include "../../lib/filesystem/Filesystem.h"
|
||||
#include "../../lib/filesystem/CCompressedStream.h"
|
||||
#include "../../lib/mapping/CMapInfo.h"
|
||||
#include "../../lib/VCMIDirs.h"
|
||||
#include "../../lib/CStopWatch.h"
|
||||
#include "../../lib/NetPacksLobby.h"
|
||||
@@ -183,7 +184,7 @@ static std::function<void()> genCommand(CMenuScreen * menu, std::vector<std::str
|
||||
case 2:
|
||||
return std::bind(CMainMenu::openLobby, ESelectionScreen::campaignList, true, nullptr, ELoadMode::NONE);
|
||||
case 3:
|
||||
return std::bind(CInfoWindow::showInfoDialog, CGI->generaltexth->translate("vcmi.mainMenu.tutorialNotImplemented"), std::vector<std::shared_ptr<CComponent>>(), PlayerColor(1));
|
||||
return std::bind(CMainMenu::startTutorial);
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -198,7 +199,7 @@ static std::function<void()> genCommand(CMenuScreen * menu, std::vector<std::str
|
||||
case 2:
|
||||
return std::bind(CMainMenu::openLobby, ESelectionScreen::loadGame, true, nullptr, ELoadMode::CAMPAIGN);
|
||||
case 3:
|
||||
return std::bind(CInfoWindow::showInfoDialog, CGI->generaltexth->translate("vcmi.mainMenu.tutorialNotImplemented"), std::vector<std::shared_ptr<CComponent>>(), PlayerColor(1));
|
||||
return std::bind(CMainMenu::startTutorial);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -371,6 +372,34 @@ void CMainMenu::openCampaignScreen(std::string name)
|
||||
logGlobal->error("Unknown campaign set: %s", name);
|
||||
}
|
||||
|
||||
void CMainMenu::startTutorial()
|
||||
{
|
||||
ResourceID tutorialMap("Maps/Tutorial.tut", EResType::MAP);
|
||||
if(!CResourceHandler::get()->existsResource(tutorialMap))
|
||||
{
|
||||
CInfoWindow::showInfoDialog(CGI->generaltexth->translate("vcmi.mainMenu.tutorialNotExist"), std::vector<std::shared_ptr<CComponent>>(), PlayerColor(1));
|
||||
return;
|
||||
}
|
||||
|
||||
auto mapInfo = std::make_shared<CMapInfo>();
|
||||
mapInfo->mapInit(tutorialMap.getName());
|
||||
|
||||
CMainMenu::openLobby(ESelectionScreen::newGame, true, nullptr, ELoadMode::NONE);
|
||||
|
||||
GH.dispatchMainThread([mapInfo](){
|
||||
while(!CSH->c || !CSH->c->handler)
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||
|
||||
while(!CSH->mi || mapInfo->fileURI != CSH->mi->fileURI)
|
||||
{
|
||||
CSH->setMapInfo(mapInfo);
|
||||
boost::this_thread::sleep(boost::posix_time::milliseconds(50));
|
||||
}
|
||||
|
||||
CSH->sendStartGame();
|
||||
});
|
||||
}
|
||||
|
||||
std::shared_ptr<CMainMenu> CMainMenu::create()
|
||||
{
|
||||
if(!CMM)
|
||||
|
||||
Reference in New Issue
Block a user