1
0
mirror of https://github.com/XProger/OpenLara.git synced 2025-08-24 05:42:56 +02:00

play logo FMV; loading screen skipping; fix click at start playing of PSX FMVs

This commit is contained in:
XProger
2018-07-15 04:30:05 +03:00
parent a079eacaba
commit ff8159003c
5 changed files with 102 additions and 23 deletions

View File

@@ -26,7 +26,7 @@ namespace Game {
if (level->level.isTitle() && id != TR::LVL_MAX) if (level->level.isTitle() && id != TR::LVL_MAX)
playVideo = false; playVideo = false;
level->init(playVideo); level->init(id == TR::LVL_MAX, playVideo);
UI::game = level; UI::game = level;
#if !defined(_OS_PSP) && !defined(_OS_CLOVER) #if !defined(_OS_PSP) && !defined(_OS_CLOVER)

View File

@@ -868,6 +868,31 @@ namespace TR {
} }
} }
const char* getGameLogo(Version version) {
if (version & VER_TR1) {
CHECK_FILE("FMV/CORELOGO.FMV");
CHECK_FILE("FMV/CORE.RPL");
CHECK_FILE("video/1/CORELOGO.FMV");
return "video/1/CORE.RPL";
}
if (version & VER_TR2) {
CHECK_FILE("FMV/LOGO.FMV");
CHECK_FILE("FMV/LOGO.RPL");
CHECK_FILE("video/2/LOGO.FMV");
return "video/2/LOGO.RPL";
}
if (version & VER_TR3) {
CHECK_FILE("FMV/LOGO.FMV");
CHECK_FILE("fmv/logo.rpl");
CHECK_FILE("video/3/LOGO.FMV");
return "video/3/logo.rpl";
}
return NULL;
}
const char* getGameVideo(LevelID id) { const char* getGameVideo(LevelID id) {
switch (id) { switch (id) {
// TR1 // TR1

View File

@@ -214,6 +214,9 @@ struct Inventory {
Texture *background[2]; Texture *background[2];
Video *video; Video *video;
bool playLogo;
bool playVideo;
bool active; bool active;
bool chosen; bool chosen;
float phaseRing, phasePage, phaseChoose, phaseSelect; float phaseRing, phasePage, phaseChoose, phaseSelect;
@@ -478,6 +481,14 @@ struct Inventory {
new Stream(TR::getGameScreen(inv->game->getLevel()->id), loadTitleBG, inv); new Stream(TR::getGameScreen(inv->game->getLevel()->id), loadTitleBG, inv);
} }
static void loadLogo(Stream *stream, void *userData) {
Inventory *inv = (Inventory*)userData;
if (stream)
inv->video = new Video(stream);
else
inv->skipVideo();
}
Inventory(IGame *game) : game(game), active(false), chosen(false), index(0), targetIndex(0), page(PAGE_OPTION), targetPage(PAGE_OPTION), itemsCount(0), playerIndex(0), changeTimer(0.0f), nextLevel(TR::LVL_MAX), lastKey(cMAX) { Inventory(IGame *game) : game(game), active(false), chosen(false), index(0), targetIndex(0), page(PAGE_OPTION), targetPage(PAGE_OPTION), itemsCount(0), playerIndex(0), changeTimer(0.0f), nextLevel(TR::LVL_MAX), lastKey(cMAX) {
TR::LevelID id = game->getLevel()->id; TR::LevelID id = game->getLevel()->id;
@@ -545,10 +556,21 @@ struct Inventory {
delete background[i]; delete background[i];
} }
void init(bool playVideo) { void startVideo() {
new Stream(playVideo ? TR::getGameVideo(game->getLevel()->id) : NULL, loadVideo, this); new Stream(playVideo ? TR::getGameVideo(game->getLevel()->id) : NULL, loadVideo, this);
} }
void init(bool playLogo, bool playVideo) {
this->playLogo = playLogo;
this->playVideo = playVideo;
if (playLogo) {
new Stream(TR::getGameLogo(game->getLevel()->version), loadLogo, this);
return;
}
startVideo();
}
bool isActive() { bool isActive() {
return active || phaseRing > 0.0f; return active || phaseRing > 0.0f;
} }
@@ -919,6 +941,16 @@ struct Inventory {
void skipVideo() { void skipVideo() {
delete video; delete video;
video = NULL; video = NULL;
if (playLogo) {
playLogo = false;
if (playVideo) {
startVideo();
return;
}
}
playVideo = false;
game->playTrack(0); game->playTrack(0);
if (game->getLevel()->isTitle()) { if (game->getLevel()->isTitle()) {
titleTimer = 0.0f; titleTimer = 0.0f;
@@ -928,10 +960,17 @@ struct Inventory {
} }
void update() { void update() {
if (video && (Input::state[0][cInventory] || Input::state[0][cAction] || Input::state[0][cJump] || if (titleTimer > 1.0f && (
Input::state[0][cInventory] || Input::state[0][cAction] || Input::state[0][cJump] ||
Input::state[1][cInventory] || Input::state[1][cAction] || Input::state[1][cJump] || Input::state[1][cInventory] || Input::state[1][cAction] || Input::state[1][cJump] ||
Input::down[ikCtrl] || Input::down[ikEnter] || Input::down[ikAlt])) Input::down[ikCtrl] || Input::down[ikEnter] || Input::down[ikAlt]))
{
if (video) {
if (video->time > 0.5f)
skipVideo(); skipVideo();
} else if (titleTimer > 1.0f && titleTimer < 2.5f)
titleTimer = 1.0f;
}
if (video) { if (video) {
video->update(); video->update();
@@ -1555,14 +1594,14 @@ struct Inventory {
Texture *tmp = background[0]; Texture *tmp = background[0];
float sy = 1.0f; float sy = 1.0f;
if (game->getLevel()->version & TR::VER_TR1) if ((game->getLevel()->version & TR::VER_TR1) && !playLogo)
sy = 1.2f; sy = 1.2f;
background[0] = video->frameTex[0]; background[0] = video->frameTex[0];
renderTitleBG(1.0f, sy, 255); renderTitleBG(1.0f, sy, 255);
background[0] = video->frameTex[1]; background[0] = video->frameTex[1];
renderTitleBG(1.0f, sy, clamp(int((video->time / video->step) * 255), 0, 255)); renderTitleBG(1.0f, sy, clamp(int((video->stepTimer / video->step) * 255), 0, 255));
background[0] = tmp; background[0] = tmp;

View File

@@ -759,8 +759,8 @@ struct Level : IGame {
Sound::stopAll(); Sound::stopAll();
} }
void init(bool playVideo) { void init(bool playLogo, bool playVideo) {
inventory->init(playVideo); inventory->init(playLogo, playVideo);
} }
void addPlayer(int index) { void addPlayer(int index) {

View File

@@ -1099,14 +1099,27 @@ struct Video {
int i = 0; int i = 0;
while (i < count) { while (i < count) {
if (xa->pos >= COUNT(xa->buffer)) { if (xa->pos >= COUNT(xa->buffer)) {
if (aFrames[curAudioFrame].size == 0) if (aFrames[curAudioFrame].size == 0) {
curAudioFrame = (curAudioFrame + 1) % AUDIO_MAX_FRAMES; curAudioFrame = (curAudioFrame + 1) % AUDIO_MAX_FRAMES;
if (aFrames[curAudioFrame].size == 0) { if (aFrames[curAudioFrame].size == 0) {
// check next 3 frames for audio frame
stream->setPos(oldPos); stream->setPos(oldPos);
for (int j = 0; j < 3; j++) {
nextFrame(); nextFrame();
oldPos = stream->pos;
curAudioFrame = aFrameIndex; curAudioFrame = aFrameIndex;
if (curAudioFrame != -1 && aFrames[curAudioFrame].size != 0)
break;
}
if (curAudioFrame == -1) { // no audio frames found!
ASSERT(false);
memset(frames, 0, count * sizeof(Sound::Frame));
return count;
}
oldPos = stream->pos;
}
} }
} }
stream->setPos(aFrames[curAudioFrame].pos); stream->setPos(aFrames[curAudioFrame].pos);
@@ -1126,12 +1139,12 @@ struct Video {
Decoder *decoder; Decoder *decoder;
Texture *frameTex[2]; Texture *frameTex[2];
Color32 *frameData; Color32 *frameData;
float time, step; float step, stepTimer, time;
bool isPlaying; bool isPlaying;
bool needUpdate; bool needUpdate;
Sound::Sample *sample; Sound::Sample *sample;
Video(Stream *stream) : decoder(NULL), time(0.0f), isPlaying(false) { Video(Stream *stream) : decoder(NULL), time(0.0f), stepTimer(0.0f), isPlaying(false) {
frameTex[0] = frameTex[1] = NULL; frameTex[0] = frameTex[1] = NULL;
if (!stream) return; if (!stream) return;
@@ -1154,7 +1167,8 @@ struct Video {
sample = Sound::play(decoder); sample = Sound::play(decoder);
step = 1.0f / decoder->fps; step = 1.0f / decoder->fps;
time = step; stepTimer = step;
time = 0.0f;
isPlaying = true; isPlaying = true;
} }
@@ -1171,10 +1185,11 @@ struct Video {
void update() { void update() {
if (!isPlaying) return; if (!isPlaying) return;
time += Core::deltaTime; stepTimer += Core::deltaTime;
if (time < step) if (stepTimer < step)
return; return;
time -= step; stepTimer -= step;
time += step;
#ifdef VIDEO_TEST #ifdef VIDEO_TEST
int t = Core::getTime(); int t = Core::getTime();
while (decoder->decodeVideo(frameData)) {} while (decoder->decodeVideo(frameData)) {}