From 92995964f395e1b4b11c70e0601296461f2e7d73 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Wed, 20 Feb 2013 21:01:18 +0000 Subject: [PATCH] a bit more of prologue/epilogue screen --- client/CPreGame.cpp | 31 ++++++++++++++++++++++--------- client/CPreGame.h | 3 ++- lib/Mapping/CCampaignHandler.cpp | 12 ++---------- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index dae1c0cbe..57b680924 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -3587,16 +3587,23 @@ void CBonusSelection::startMap() tlog1 << "Starting scenario " << int(ourCampaign->currentMap) << "\n"; + auto exitCb = [si]() + { + CGP->showLoadingScreen(boost::bind(&startGame, si, (CConnection *)nullptr)); + }; + if (scenario.prolog.hasPrologEpilog) { - //GH.pushInt(new CPrologEpilogVideo(scenario.prolog)); + GH.pushInt(new CPrologEpilogVideo(scenario.prolog, exitCb)); tlog1 << "Video: " << scenario.prolog.prologVideo <<"\n"; tlog1 << "Audio: " << scenario.prolog.prologMusic <<"\n"; tlog1 << "Text: " << scenario.prolog.prologText <<"\n"; } else + { tlog1 << "Without prolog\n"; - CGP->showLoadingScreen(boost::bind(&startGame, si, (CConnection *)nullptr)); + exitCb(); + } } void CBonusSelection::selectBonus( int id ) @@ -4083,27 +4090,33 @@ void CLoadingScreen::showAll(SDL_Surface *to) CWindowObject::showAll(to); } -CPrologEpilogVideo::CPrologEpilogVideo( CCampaignScenario::SScenarioPrologEpilog _spe ) - : spe(_spe), curTxtH(300) +CPrologEpilogVideo::CPrologEpilogVideo( CCampaignScenario::SScenarioPrologEpilog _spe, std::function callback ) + : spe(_spe), exitCb(callback) { OBJ_CONSTRUCTION_CAPTURING_ALL; + addUsedEvents(LCLICK); + pos = Rect(screen); CCS->videoh->open(CCampaignHandler::prologVideoName(spe.prologVideo)); - auto lines = CMessage::breakText(spe.prologText, 50, EFonts::FONT_BIG); + auto lines = CMessage::breakText(spe.prologText, 500, EFonts::FONT_BIG); - txt = CSDL_Ext::newSurface(500, 60 * lines.size()); - graphics->fonts[FONT_BIG]->renderTextLinesCenter(txt, lines, Colors::METALLIC_GOLD, Point(0,0)); + txt = CSDL_Ext::newSurface(500, 25 * lines.size()); + curTxtH = screen->h; + graphics->fonts[FONT_BIG]->renderTextLinesCenter(txt, lines, Colors::METALLIC_GOLD, Point(txt->w/2, txt->h/2)); + SDL_SaveBMP(txt, "txtsrfc.bmp"); } void CPrologEpilogVideo::show( SDL_Surface * to ) { - blitAt(txt, 50, 200-curTxtH, to); + memset(to->pixels, 0, to->h*to->pitch); //make bg black + blitAt(txt, (to->w-txt->w)/2, curTxtH, to); CCS->videoh->show(0, 0, to); - curTxtH = std::max(curTxtH - 10, to->h - txt->h); + curTxtH = std::max(curTxtH - 1, to->h - txt->h); } void CPrologEpilogVideo::clickLeft( tribool down, bool previousState ) { GH.popInt(this); + exitCb(); } diff --git a/client/CPreGame.h b/client/CPreGame.h index ccfa61c2a..8a178e805 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -545,8 +545,9 @@ class CPrologEpilogVideo : public CIntObject CCampaignScenario::SScenarioPrologEpilog spe; SDL_Surface * txt; int curTxtH; + std::function exitCb; public: - CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog _spe); + CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog _spe, std::function callback); void clickLeft(tribool down, bool previousState); void show(SDL_Surface * to); diff --git a/lib/Mapping/CCampaignHandler.cpp b/lib/Mapping/CCampaignHandler.cpp index 345470ad8..27d000d9d 100644 --- a/lib/Mapping/CCampaignHandler.cpp +++ b/lib/Mapping/CCampaignHandler.cpp @@ -468,22 +468,14 @@ CCampaignState::CCampaignState( unique_ptr _camp ) : camp(std::move(_ } } -static std::string indexToString(std::string fname, ui8 index) -{ - CLegacyConfigParser parser(fname); - for(int i=0; i