1
0
mirror of https://github.com/vcmi/vcmi.git synced 2025-06-15 00:05:02 +02:00

Added VideoWidget to hide implementation details

This commit is contained in:
Ivan Savenko
2024-05-02 22:14:50 +03:00
parent d27b854cb1
commit d08c7b7b8f
20 changed files with 228 additions and 285 deletions

View File

@ -20,10 +20,10 @@
#include "../gui/CGuiHandler.h"
#include "../gui/Shortcut.h"
#include "../gui/WindowHandler.h"
#include "../media/IVideoPlayer.h"
#include "../widgets/Images.h"
#include "../widgets/Buttons.h"
#include "../widgets/TextControls.h"
#include "../widgets/VideoWidget.h"
#include "../render/Canvas.h"
CTutorialWindow::CTutorialWindow(const TutorialMode & m)
@ -54,7 +54,10 @@ CTutorialWindow::CTutorialWindow(const TutorialMode & m)
void CTutorialWindow::setContent()
{
video = "tutorial/" + videos[page];
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
auto video = VideoPath::builtin("tutorial/" + videos[page]);
videoPlayer = std::make_shared<VideoWidget>(Point(30, 120), video);
buttonLeft->block(page<1);
buttonRight->block(page>videos.size() - 2);
@ -98,26 +101,3 @@ void CTutorialWindow::previous()
deactivate();
activate();
}
void CTutorialWindow::show(Canvas & to)
{
CCS->videoh->update(pos.x + 30, pos.y + 120, to.getInternalSurface(), true, false,
[&]()
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin(video));
});
CIntObject::show(to);
}
void CTutorialWindow::activate()
{
CCS->videoh->open(VideoPath::builtin(video));
CIntObject::activate();
}
void CTutorialWindow::deactivate()
{
CCS->videoh->close();
}