From b776b93b0c410c743264894cd88ebedf69dce265 Mon Sep 17 00:00:00 2001 From: mateuszb Date: Tue, 19 Feb 2013 20:39:09 +0000 Subject: [PATCH] * a bit of campaign prologue/epilogue screen --- client/CPreGame.cpp | 26 ++++++++++++++++++++++++++ client/CPreGame.h | 13 +++++++++++++ lib/Mapping/CCampaignHandler.cpp | 21 +++++++++++++++++++++ lib/Mapping/CCampaignHandler.h | 6 ++++-- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/client/CPreGame.cpp b/client/CPreGame.cpp index 981244cb7..dae1c0cbe 100644 --- a/client/CPreGame.cpp +++ b/client/CPreGame.cpp @@ -3589,6 +3589,7 @@ void CBonusSelection::startMap() if (scenario.prolog.hasPrologEpilog) { + //GH.pushInt(new CPrologEpilogVideo(scenario.prolog)); tlog1 << "Video: " << scenario.prolog.prologVideo <<"\n"; tlog1 << "Audio: " << scenario.prolog.prologMusic <<"\n"; tlog1 << "Text: " << scenario.prolog.prologText <<"\n"; @@ -4081,3 +4082,28 @@ void CLoadingScreen::showAll(SDL_Surface *to) CWindowObject::showAll(to); } + +CPrologEpilogVideo::CPrologEpilogVideo( CCampaignScenario::SScenarioPrologEpilog _spe ) + : spe(_spe), curTxtH(300) +{ + OBJ_CONSTRUCTION_CAPTURING_ALL; + + CCS->videoh->open(CCampaignHandler::prologVideoName(spe.prologVideo)); + + auto lines = CMessage::breakText(spe.prologText, 50, EFonts::FONT_BIG); + + txt = CSDL_Ext::newSurface(500, 60 * lines.size()); + graphics->fonts[FONT_BIG]->renderTextLinesCenter(txt, lines, Colors::METALLIC_GOLD, Point(0,0)); +} + +void CPrologEpilogVideo::show( SDL_Surface * to ) +{ + blitAt(txt, 50, 200-curTxtH, to); + CCS->videoh->show(0, 0, to); + curTxtH = std::max(curTxtH - 10, to->h - txt->h); +} + +void CPrologEpilogVideo::clickLeft( tribool down, bool previousState ) +{ + GH.popInt(this); +} diff --git a/client/CPreGame.h b/client/CPreGame.h index 61e98e7a1..ccfa61c2a 100644 --- a/client/CPreGame.h +++ b/client/CPreGame.h @@ -539,6 +539,19 @@ public: CHotSeatPlayers(const std::string &firstPlayer); }; + +class CPrologEpilogVideo : public CIntObject +{ + CCampaignScenario::SScenarioPrologEpilog spe; + SDL_Surface * txt; + int curTxtH; +public: + CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog _spe); + + void clickLeft(tribool down, bool previousState); + void show(SDL_Surface * to); +}; + /// Campaign screen where you can choose one out of three starting bonuses class CBonusSelection : public CIntObject { diff --git a/lib/Mapping/CCampaignHandler.cpp b/lib/Mapping/CCampaignHandler.cpp index c4878642a..345470ad8 100644 --- a/lib/Mapping/CCampaignHandler.cpp +++ b/lib/Mapping/CCampaignHandler.cpp @@ -467,3 +467,24 @@ CCampaignState::CCampaignState( unique_ptr _camp ) : camp(std::move(_ mapsRemaining.push_back(i); } } + +static std::string indexToString(std::string fname, ui8 index) +{ + CLegacyConfigParser parser(fname); + for(int i=0; i preconditionRegions; //what we need to conquer to conquer this one (stored as bitfield in h3c) ui8 regionColor; ui8 difficulty; - ui8 conquered; + bool conquered; std::string regionText; struct DLL_LINKAGE SScenarioPrologEpilog { - ui8 hasPrologEpilog; + bool hasPrologEpilog; ui8 prologVideo; // from CmpMovie.txt ui8 prologMusic; // from CmpMusic.txt std::string prologText; @@ -179,6 +179,8 @@ class DLL_LINKAGE CCampaignHandler /// headerOnly - only header will be decompressed, returned vector wont have any maps static std::vector< std::vector > getFile(const std::string & name, bool headerOnly); public: + static std::string prologVideoName(ui8 index); + static std::string prologMusicName(ui8 index); static CCampaignHeader getHeader( const std::string & name); //name - name of appropriate file