1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-24 08:32:34 +02:00

Tutorial implemented

This commit is contained in:
nordsoft 2023-08-09 03:54:09 +04:00
parent ad8695ac91
commit 1def98a862
5 changed files with 41 additions and 5 deletions

View File

@ -38,6 +38,7 @@
"vcmi.radialWheel.splitUnit" : "Split creature to another slot",
"vcmi.mainMenu.tutorialNotImplemented" : "Sorry, tutorial is not implemented yet\n",
"vcmi.mainMenu.tutorialNotExist" : "Tutorial map is not found\n",
"vcmi.mainMenu.highscoresNotImplemented" : "Sorry, high scores menu is not implemented yet\n",
"vcmi.mainMenu.serverConnecting" : "Connecting...",
"vcmi.mainMenu.serverAddressEnter" : "Enter address:",

View File

@ -222,9 +222,13 @@ void SelectionTab::toggleMode()
switch(tabType)
{
case ESelectionScreen::newGame:
inputName->disable();
parseMaps(getFiles("Maps/", EResType::MAP));
break;
{
inputName->disable();
auto files = getFiles("Maps/", EResType::MAP);
files.erase(ResourceID("Maps/Tutorial.tut", EResType::MAP));
parseMaps(files);
break;
}
case ESelectionScreen::loadGame:
inputName->disable();

View File

@ -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)

View File

@ -148,6 +148,7 @@ public:
static void openLobby(ESelectionScreen screenType, bool host, const std::vector<std::string> * names, ELoadMode loadMode);
static void openCampaignLobby(const std::string & campaignFileName);
static void openCampaignLobby(std::shared_ptr<CampaignState> campaign);
static void startTutorial();
void openCampaignScreen(std::string name);
static std::shared_ptr<CMainMenu> create();

View File

@ -129,6 +129,7 @@ EResType::Type EResTypeHelper::getTypeFromExtension(std::string extension)
{".MSG", EResType::MASK},
{".H3C", EResType::CAMPAIGN},
{".H3M", EResType::MAP},
{".TUT", EResType::MAP},
{".FNT", EResType::BMP_FONT},
{".TTF", EResType::TTF_FONT},
{".BMP", EResType::IMAGE},