1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

fix video implementation error; implement paging; video loading

This commit is contained in:
Laserlicht 2023-11-16 22:39:50 +01:00 committed by GitHub
parent 2cfbcd067b
commit 1bf05d43a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 17 deletions

View File

@ -214,6 +214,10 @@
"SOUNDS/":
[
{"type" : "dir", "path" : "/Sounds"}
],
"VIDEO/":
[
{"type" : "dir", "path" : "/Video"}
]
}
}

View File

@ -41,8 +41,11 @@ extern "C" {
static int lodRead(void* opaque, uint8_t* buf, int size)
{
auto video = reinterpret_cast<CVideoPlayer *>(opaque);
int bytes = static_cast<int>(video->data->read(buf, size));
if(bytes == 0)
return AVERROR_EOF;
return static_cast<int>(video->data->read(buf, size));
return bytes;
}
static si64 lodSeek(void * opaque, si64 pos, int whence)
@ -59,8 +62,11 @@ static si64 lodSeek(void * opaque, si64 pos, int whence)
static int lodReadAudio(void* opaque, uint8_t* buf, int size)
{
auto video = reinterpret_cast<CVideoPlayer *>(opaque);
int bytes = static_cast<int>(video->dataAudio->read(buf, size));
if(bytes == 0)
return AVERROR_EOF;
return static_cast<int>(video->dataAudio->read(buf, size));
return bytes;
}
static si64 lodSeekAudio(void * opaque, si64 pos, int whence)

View File

@ -26,11 +26,11 @@
#include "../render/Canvas.h"
CTutorialWindow::CTutorialWindow(const TutorialMode & m)
: CWindowObject(BORDERED, ImagePath::builtin("DIBOXBCK")), mode { m }
: CWindowObject(BORDERED, ImagePath::builtin("DIBOXBCK")), mode { m }, page { 0 }
{
OBJ_CONSTRUCTION_CAPTURING_ALL_NO_DISPOSE;
pos = Rect(pos.x, pos.y, 540, 400); //video: 480x320
pos = Rect(pos.x, pos.y, 380, 400); //video: 320x240
background = std::make_shared<CFilledTexture>(ImagePath::builtin("DIBOXBCK"), Rect(0, 0, pos.w, pos.h));
updateShadow();
@ -39,14 +39,25 @@ CTutorialWindow::CTutorialWindow(const TutorialMode & m)
addUsedEvents(LCLICK);
buttonOk = std::make_shared<CButton>(Point(239, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CTutorialWindow::close, this), EShortcut::GLOBAL_ACCEPT); //62x28
buttonLeft = std::make_shared<CButton>(Point(5, 177), AnimationPath::builtin("HSBTNS3"), CButton::tooltip(), std::bind(&CTutorialWindow::previous, this), EShortcut::MOVE_LEFT); //22x46
buttonRight = std::make_shared<CButton>(Point(513, 177), AnimationPath::builtin("HSBTNS5"), CButton::tooltip(), std::bind(&CTutorialWindow::next, this), EShortcut::MOVE_RIGHT); //22x46
if(mode == TutorialMode::TOUCH_ADVENTUREMAP) videos = { "RightClick", "MapPanning", "MapZooming" };
else if(mode == TutorialMode::TOUCH_BATTLE) videos = { "BattleDirection", "BattleDirectionAbort", "AbortSpell" };
buttonLeft->block(true);
labelTitle = std::make_shared<CLabel>(190, 15, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, "Touchscreen Intro");
buttonOk = std::make_shared<CButton>(Point(159, 367), AnimationPath::builtin("IOKAY"), CButton::tooltip(), std::bind(&CTutorialWindow::close, this), EShortcut::GLOBAL_ACCEPT); //62x28
buttonLeft = std::make_shared<CButton>(Point(5, 217), AnimationPath::builtin("HSBTNS3"), CButton::tooltip(), std::bind(&CTutorialWindow::previous, this), EShortcut::MOVE_LEFT); //22x46
buttonRight = std::make_shared<CButton>(Point(352, 217), AnimationPath::builtin("HSBTNS5"), CButton::tooltip(), std::bind(&CTutorialWindow::next, this), EShortcut::MOVE_RIGHT); //22x46
labelTitle = std::make_shared<CLabel>(270, 15, FONT_BIG, ETextAlignment::CENTER, Colors::YELLOW, "Touchscreen Intro");
labelInformation = std::make_shared<CMultiLineLabel>(Rect(5, 50, 530, 60), EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
setContent();
}
void CTutorialWindow::setContent()
{
video = "tutorial/" + videos[page];
buttonLeft->block(page<1);
buttonRight->block(page>videos.size() - 2);
labelInformation = std::make_shared<CMultiLineLabel>(Rect(5, 40, 370, 60), EFonts::FONT_MEDIUM, ETextAlignment::CENTER, Colors::WHITE, "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.");
}
void CTutorialWindow::openWindowFirstTime(const TutorialMode & m)
@ -72,31 +83,34 @@ void CTutorialWindow::close()
void CTutorialWindow::next()
{
page++;
setContent();
deactivate();
activate();
}
void CTutorialWindow::previous()
{
page--;
setContent();
deactivate();
activate();
}
void CTutorialWindow::show(Canvas & to)
{
CCS->videoh->update(pos.x + 200, pos.y + 200, to.getInternalSurface(), true, false,
CCS->videoh->update(pos.x + 30, pos.y + 120, to.getInternalSurface(), true, false,
[&]()
{
CCS->videoh->close();
CCS->videoh->open(VideoPath::builtin(video));
});
redraw();
CIntObject::show(to);
}
void CTutorialWindow::activate()
{
video = "tutorial/BattleDirection";
CCS->videoh->open(VideoPath::builtin(video));
CIntObject::activate();
}
@ -104,4 +118,4 @@ void CTutorialWindow::activate()
void CTutorialWindow::deactivate()
{
CCS->videoh->close();
}
}

View File

@ -35,10 +35,14 @@ class CTutorialWindow : public CWindowObject
std::shared_ptr<CMultiLineLabel> labelInformation;
std::string video;
std::vector<std::string> videos;
int page;
void close();
void next();
void previous();
void setContent();
public:
CTutorialWindow(const TutorialMode & m);