1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-08-13 19:54:17 +02:00

* a bit of campaign prologue/epilogue screen

This commit is contained in:
mateuszb
2013-02-19 20:39:09 +00:00
parent a63b30e516
commit b776b93b0c
4 changed files with 64 additions and 2 deletions

View File

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

View File

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

View File

@@ -467,3 +467,24 @@ CCampaignState::CCampaignState( unique_ptr<CCampaign> _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<index-1; ++i)
parser.endLine();
return parser.readString();
}
std::string CCampaignHandler::prologVideoName(ui8 index)
{
return indexToString("DATA/CMPMOVIE", index);
}
std::string CCampaignHandler::prologMusicName(ui8 index)
{
return indexToString("DATA/CMPMUSIC", index);
}

View File

@@ -89,13 +89,13 @@ public:
std::set<ui8> 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<ui8> > 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