- fixed: SW's intro cutscene must not terminate its sound.

Fixes #201.
This commit is contained in:
Christoph Oelckers 2020-08-18 00:04:48 +02:00
parent 65cb267d56
commit a535f62d4a
4 changed files with 12 additions and 9 deletions

View file

@ -99,12 +99,13 @@ class DAnmPlayer : public DScreenJob
AnimTextures animtex; AnimTextures animtex;
const AnimSound* animSnd; const AnimSound* animSnd;
const int* frameTicks; const int* frameTicks;
bool nostopsound;
public: public:
bool isvalid() { return numframes > 0; } bool isvalid() { return numframes > 0; }
DAnmPlayer(FileReader& fr, const AnimSound* ans, const int *frameticks) DAnmPlayer(FileReader& fr, const AnimSound* ans, const int *frameticks, bool nosoundcutoff)
: animSnd(ans), frameTicks(frameticks) : animSnd(ans), frameTicks(frameticks), nostopsound(nosoundcutoff)
{ {
buffer = fr.ReadPadded(1); buffer = fr.ReadPadded(1);
fr.Close(); fr.Close();
@ -138,7 +139,7 @@ public:
{ {
twod->ClearScreen(); twod->ClearScreen();
DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false, TAG_DONE); DrawTexture(twod, animtex.GetFrame(), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_Masked, false, TAG_DONE);
if (skiprequest) soundEngine->StopAllChannels(); if (skiprequest && !nostopsound) soundEngine->StopAllChannels();
return skiprequest? -1 : 1; return skiprequest? -1 : 1;
} }
@ -169,7 +170,7 @@ public:
} }
} }
curframe++; curframe++;
if (skiprequest) soundEngine->StopAllChannels(); if (skiprequest && !nostopsound) soundEngine->StopAllChannels();
return skiprequest ? -1 : curframe < numframes? 1 : 0; return skiprequest ? -1 : curframe < numframes? 1 : 0;
} }
@ -325,7 +326,7 @@ public:
// //
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
DScreenJob* PlayVideo(const char* filename, const AnimSound* ans, const int* frameticks) DScreenJob* PlayVideo(const char* filename, const AnimSound* ans, const int* frameticks, bool nosoundcutoff)
{ {
auto nothing = []()->DScreenJob* { return Create<DScreenJob>(); }; auto nothing = []()->DScreenJob* { return Create<DScreenJob>(); };
if (!filename) if (!filename)
@ -355,7 +356,7 @@ DScreenJob* PlayVideo(const char* filename, const AnimSound* ans, const int* fra
if (!memcmp(id, "LPF ", 4)) if (!memcmp(id, "LPF ", 4))
{ {
auto anm = Create<DAnmPlayer>(fr, ans, frameticks); auto anm = Create<DAnmPlayer>(fr, ans, frameticks, nosoundcutoff);
if (!anm->isvalid()) if (!anm->isvalid())
{ {
Printf("%s: invalid ANM file.\n", filename); Printf("%s: invalid ANM file.\n", filename);

View file

@ -106,4 +106,4 @@ struct AnimSound
int soundnum; int soundnum;
}; };
DScreenJob *PlayVideo(const char *filename, const AnimSound *ans = nullptr, const int *frameticks = nullptr); DScreenJob *PlayVideo(const char *filename, const AnimSound *ans = nullptr, const int *frameticks = nullptr, bool nosoundstop = false);

View file

@ -89,7 +89,7 @@ void Logo(const CompletionFunc& completion)
JobDesc jobs[3]; JobDesc jobs[3];
int job = 0; int job = 0;
jobs[job++] = { Create<DSWDRealmsScreen>() }; jobs[job++] = { Create<DSWDRealmsScreen>() };
jobs[job++] = { PlayVideo("sw.anm", logosound, logoframetimes)}; jobs[job++] = { PlayVideo("sw.anm", logosound, logoframetimes, true)};
RunScreenJob(jobs, job, completion, true, true); RunScreenJob(jobs, job, completion, true, true);
} }
else completion(false); else completion(false);

View file

@ -5726,7 +5726,9 @@ KeyMain:
// print to the console, and the user quote display. // print to the console, and the user quote display.
FStringf msg("%s %s", GStrings("TXTS_FORTUNE"), quoteMgr.GetQuote(QUOTE_COOKIE + cookie)); FStringf msg("%s %s", GStrings("TXTS_FORTUNE"), quoteMgr.GetQuote(QUOTE_COOKIE + cookie));
Printf(TEXTCOLOR_SAPPHIRE "%s\n", msg.GetChars()); Printf(TEXTCOLOR_SAPPHIRE "%s\n", msg.GetChars());
adduserquote(msg.GetChars()); strncpy(pp->cookieQuote, msg, 255);
pp->cookieQuote[255] = 0;
pp->cookieTime = totalclock + 540;
} }
SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup SetFadeAmt(pp,ITEMFLASHAMT,ITEMFLASHCLR); // Flash blue on item pickup