Răsfoiți Sursa

a bit more of prologue/epilogue screen

mateuszb 12 ani în urmă
părinte
comite
92995964f3
3 a modificat fișierele cu 26 adăugiri și 20 ștergeri
  1. 22 9
      client/CPreGame.cpp
  2. 2 1
      client/CPreGame.h
  3. 2 10
      lib/Mapping/CCampaignHandler.cpp

+ 22 - 9
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<void()> 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();
 }

+ 2 - 1
client/CPreGame.h

@@ -545,8 +545,9 @@ class CPrologEpilogVideo : public CIntObject
 	CCampaignScenario::SScenarioPrologEpilog spe;
 	SDL_Surface * txt;
 	int curTxtH;
+	std::function<void()> exitCb;
 public:
-	CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog _spe);
+	CPrologEpilogVideo(CCampaignScenario::SScenarioPrologEpilog _spe, std::function<void()> callback);
 
 	void clickLeft(tribool down, bool previousState);
 	void show(SDL_Surface * to);

+ 2 - 10
lib/Mapping/CCampaignHandler.cpp

@@ -468,22 +468,14 @@ CCampaignState::CCampaignState( unique_ptr<CCampaign> _camp ) : camp(std::move(_
 	}
 }
 
-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);
+	return "";
 }
 
 std::string CCampaignHandler::prologMusicName(ui8 index)
 {
-	return indexToString("DATA/CMPMUSIC", index);
+	return "";
 }