2018-01-05 19:21:07 +02:00
|
|
|
/*
|
|
|
|
* CPrologEpilogVideo.cpp, part of VCMI engine
|
|
|
|
*
|
|
|
|
* Authors: listed in file AUTHORS in main folder
|
|
|
|
*
|
|
|
|
* License: GNU General Public License v2.0 or later
|
|
|
|
* Full text of license available in license.txt file, in main folder
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "StdInc.h"
|
|
|
|
|
|
|
|
#include "CPrologEpilogVideo.h"
|
|
|
|
#include "../CGameInfo.h"
|
|
|
|
#include "../CMusicHandler.h"
|
|
|
|
#include "../CVideoHandler.h"
|
|
|
|
#include "../gui/CGuiHandler.h"
|
|
|
|
#include "../widgets/TextControls.h"
|
2023-06-02 15:42:18 +02:00
|
|
|
#include "../render/Canvas.h"
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
|
2023-06-25 20:16:03 +02:00
|
|
|
CPrologEpilogVideo::CPrologEpilogVideo(CampaignScenarioPrologEpilog _spe, std::function<void()> callback)
|
2018-01-05 19:21:07 +02:00
|
|
|
: CWindowObject(BORDERED), spe(_spe), positionCounter(0), voiceSoundHandle(-1), exitCb(callback)
|
|
|
|
{
|
|
|
|
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
|
|
|
|
addUsedEvents(LCLICK);
|
|
|
|
pos = center(Rect(0, 0, 800, 600));
|
|
|
|
updateShadow();
|
|
|
|
|
2023-04-17 02:47:54 +02:00
|
|
|
CCS->videoh->open(spe.prologVideo);
|
|
|
|
CCS->musich->playMusic("Music/" + spe.prologMusic, true, true);
|
2018-01-05 19:21:07 +02:00
|
|
|
// MPTODO: Custom campaign crashing on this?
|
|
|
|
// voiceSoundHandle = CCS->soundh->playSound(CCampaignHandler::prologVoiceName(spe.prologVideo));
|
|
|
|
|
2022-11-26 23:12:20 +02:00
|
|
|
text = std::make_shared<CMultiLineLabel>(Rect(100, 500, 600, 100), EFonts::FONT_BIG, ETextAlignment::CENTER, Colors::METALLIC_GOLD, spe.prologText);
|
2018-01-05 19:21:07 +02:00
|
|
|
text->scrollTextTo(-100);
|
|
|
|
}
|
|
|
|
|
2023-06-02 15:42:18 +02:00
|
|
|
void CPrologEpilogVideo::show(Canvas & to)
|
2018-01-05 19:21:07 +02:00
|
|
|
{
|
2023-06-02 15:42:18 +02:00
|
|
|
to.drawColor(pos, Colors::BLACK);
|
2018-01-05 19:21:07 +02:00
|
|
|
//BUG: some videos are 800x600 in size while some are 800x400
|
|
|
|
//VCMI should center them in the middle of the screen. Possible but needs modification
|
|
|
|
//of video player API which I'd like to avoid until we'll get rid of Windows-specific player
|
2023-06-02 15:42:18 +02:00
|
|
|
CCS->videoh->update(pos.x, pos.y, to.getInternalSurface(), true, false);
|
2018-01-05 19:21:07 +02:00
|
|
|
|
|
|
|
//move text every 5 calls/frames; seems to be good enough
|
|
|
|
++positionCounter;
|
|
|
|
if(positionCounter % 5 == 0)
|
|
|
|
text->scrollTextBy(1);
|
|
|
|
else
|
|
|
|
text->showAll(to); // blit text over video, if needed
|
|
|
|
|
|
|
|
if(text->textSize.y + 100 < positionCounter / 5)
|
|
|
|
clickLeft(false, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CPrologEpilogVideo::clickLeft(tribool down, bool previousState)
|
|
|
|
{
|
2018-07-25 00:36:48 +02:00
|
|
|
close();
|
2018-01-05 19:21:07 +02:00
|
|
|
CCS->soundh->stopSound(voiceSoundHandle);
|
|
|
|
exitCb();
|
|
|
|
}
|