From 1166b00af2ec3464857abb6e52698408e50dc3b5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 26 Apr 2021 22:56:37 +0200 Subject: [PATCH] - switched intro movie playing over to the new system Not tested yet. --- source/core/screenjob.cpp | 75 ++++++++++++++++++++++----- source/core/screenjob.h | 3 ++ source/games/blood/src/blood.cpp | 6 +-- source/games/duke/src/2d_d.cpp | 33 ------------ source/games/duke/src/2d_r.cpp | 53 ------------------- source/games/duke/src/dispatch.cpp | 4 -- source/games/duke/src/duke3d.h | 1 - source/games/duke/src/gameloop.cpp | 3 +- source/games/exhumed/src/gameloop.cpp | 3 +- source/games/sw/src/game.cpp | 6 +-- wadsrc/static/zscript/screenjob.zs | 2 +- 11 files changed, 69 insertions(+), 120 deletions(-) diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index 8f8c5e342..467b04cd0 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -193,16 +193,13 @@ void AddGenericVideo(DObject* runner, const FString& fn, int soundid, int fps) void CutsceneDef::Create(DObject* runner) { - if (function.CompareNoCase("none") != 0) + if (function.IsNotEmpty()) { - if (function.IsNotEmpty()) - { - CallCreateFunction(function, runner); - } - else if (video.IsNotEmpty()) - { - AddGenericVideo(runner, video, sound, framespersec); - } + CallCreateFunction(function, runner); + } + else if (video.IsNotEmpty()) + { + AddGenericVideo(runner, video, sound, framespersec); } } @@ -212,12 +209,17 @@ void CutsceneDef::Create(DObject* runner) // //============================================================================= -void StartCutscene(CutsceneDef& cs, int flags, CompletionFunc completion_) +bool StartCutscene(CutsceneDef& cs, int flags, CompletionFunc completion_) { - completion = completion_; - runner = CreateRunner(); - cs.Create(runner); - gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission; + if (cs.function.CompareNoCase("none") != 0) + { + completion = completion_; + runner = CreateRunner(); + cs.Create(runner); + gameaction = (flags & SJ_BLOCKUI) ? ga_intro : ga_intermission; + return true; + } + return false; } @@ -291,3 +293,48 @@ void ScreenJobDraw() } } } + + +void PlayLogos(gameaction_t complete_ga, gameaction_t def_ga, bool stopmusic) +{ + Mus_Stop(); + FX_StopAllSounds(); // JBF 20031228 + if (userConfig.nologo) + { + gameaction = def_ga; + } + else + { + if (!StartCutscene(globalCutscenes.Intro, SJ_BLOCKUI, [=](bool) { gameaction = complete_ga; })) gameaction = def_ga; + } +} + +/* +Duke: + if (!userConfig.nologo) fi.ShowLogo([](bool) { gameaction = ga_mainmenunostopsound; }); + else gameaction = ga_mainmenunostopsound; + + +Blood: + if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos(); + else + { + gameaction = ga_mainmenu; + } + RunScreenJob(jobs, [](bool) { + Mus_Stop(); + gameaction = ga_mainmenu; + }, SJ_BLOCKUI); + +Exhumed: + if (!userConfig.nologo) DoTitle([](bool) { gameaction = ga_mainmenu; }); + else gameaction = ga_mainmenu; + +SW: + if (!userConfig.nologo) Logo([](bool) + { + gameaction = ga_mainmenunostopsound; + }); + else gameaction = ga_mainmenu; + +*/ \ No newline at end of file diff --git a/source/core/screenjob.h b/source/core/screenjob.h index 91fd47c71..53c1e08d7 100644 --- a/source/core/screenjob.h +++ b/source/core/screenjob.h @@ -4,6 +4,7 @@ #include "v_2ddrawer.h" #include "d_eventbase.h" #include "s_soundinternal.h" +#include "gamestate.h" using CompletionFunc = std::function; struct JobDesc; @@ -195,3 +196,5 @@ void DeleteScreenJob(); bool ScreenJobResponder(event_t* ev); bool ScreenJobTick(); void ScreenJobDraw(); + +void PlayLogos(gameaction_t complete_ga, gameaction_t def_ga, bool stopmusic); diff --git a/source/games/blood/src/blood.cpp b/source/games/blood/src/blood.cpp index 0c7d38cd2..f4ca01954 100644 --- a/source/games/blood/src/blood.cpp +++ b/source/games/blood/src/blood.cpp @@ -528,11 +528,7 @@ void GameInterface::Startup() } else { - if (!userConfig.nologo && gGameOptions.nGameType == 0) playlogos(); - else - { - gameaction = ga_mainmenu; - } + PlayLogos(ga_mainmenu, ga_mainmenu, true); } } diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 3ec25ccaa..100ba4964 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -145,39 +145,6 @@ static void BigText(double x, double y, const char* text, int align = -1, double DrawText(twod, BigFont, CR_UNTRANSLATED, x, y - 12, text, DTA_FullscreenScale, FSMode_Fit320x200, DTA_Alpha, alpha, TAG_DONE); } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void Logo_d(const CompletionFunc &completion) -{ -#if 0 - Mus_Stop(); - FX_StopAllSounds(); // JBF 20031228 - - static const AnimSound logosound[] = - { - { 1, FLY_BY+1 }, - { 19, PIPEBOMB_EXPLODE+1 }, - { -1, -1 } - }; - static const int logoframetimes[] = { 9, 9, 9 }; - - TArray jobs; - int job = 0; - if (!userConfig.nologo) - { - if (!isShareware()) jobs.Push(PlayVideo("logo.anm", logosound, logoframetimes)); - if (!isNam()) jobs.Push(Create()); - } - jobs.Push(Create()); - RunScreenJob(jobs, completion, SJ_BLOCKUI); -#endif -} - - //--------------------------------------------------------------------------- // // diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index d64a0e355..7aef5a9a3 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -139,59 +139,6 @@ static void BigText(double x, double y, const char* text, int align, double alph } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -void Logo_r(const CompletionFunc& completion) -{ -#if 0 - Mus_Stop(); - FX_StopAllSounds(); // JBF 20031228 - - static const AnimSound introsound[] = - { - { 1, 29+1 }, - { -1, -1 } - }; - - static const AnimSound rednecksound[] = - { - { 1, 478+1 }, - { -1, -1 } - }; - - static const AnimSound xatrixsound[] = - { - { 1, 479+1 }, - { -1, -1 } - }; - - static const int framespeed[] = { 9, 9, 9 }; // same for all 3 anims - - TArray jobs; - - if (userConfig.nologo) - { - completion(false); - return; - } - else if (!isRRRA()) - { - jobs.Push(PlayVideo("rr_intro.anm", introsound, framespeed)); - jobs.Push(PlayVideo("redneck.anm", rednecksound, framespeed)); - jobs.Push(PlayVideo("xatlogo.anm", xatrixsound, framespeed)); - } - else - { - jobs.Push(PlayVideo("redint.mve")); - } - RunScreenJob(jobs, completion, SJ_BLOCKUI); -#endif -} - #if 0 //--------------------------------------------------------------------------- // diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 7e9ae2675..bf5918bb0 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -105,8 +105,6 @@ void think_r(); void animatesprites_d(int x, int y, int a, int smoothratio); void animatesprites_r(int x, int y, int a, int smoothratio); -void Logo_d(const CompletionFunc&); -void Logo_r(const CompletionFunc&); void InitFonts_d(); void InitFonts_r(); void PrintPaused_d(); @@ -120,7 +118,6 @@ void SetDispatcher() if (!isRR()) { fi = { - Logo_d, InitFonts_d, PrintPaused_d, @@ -167,7 +164,6 @@ void SetDispatcher() else { fi = { - Logo_r, InitFonts_r, PrintPaused_r, diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 8628373d7..4f31aef02 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -71,7 +71,6 @@ struct GameInterface : public ::GameInterface struct Dispatcher { // global stuff - void (*ShowLogo)(const CompletionFunc& completion); void (*InitFonts)(); void (*PrintPaused)(); diff --git a/source/games/duke/src/gameloop.cpp b/source/games/duke/src/gameloop.cpp index 3b5791477..2c5b20025 100644 --- a/source/games/duke/src/gameloop.cpp +++ b/source/games/duke/src/gameloop.cpp @@ -133,8 +133,7 @@ void GameInterface::Startup() } else { - if (!userConfig.nologo) fi.ShowLogo([](bool) { gameaction = ga_mainmenunostopsound; }); - else gameaction = ga_mainmenunostopsound; + PlayLogos(ga_mainmenunostopsound, ga_mainmenunostopsound, false); } } diff --git a/source/games/exhumed/src/gameloop.cpp b/source/games/exhumed/src/gameloop.cpp index c741d2a5e..50ff8a55c 100644 --- a/source/games/exhumed/src/gameloop.cpp +++ b/source/games/exhumed/src/gameloop.cpp @@ -167,8 +167,7 @@ void GameInterface::Startup() } else { - if (!userConfig.nologo) DoTitle([](bool) { gameaction = ga_mainmenu; }); - else gameaction = ga_mainmenu; + PlayLogos(ga_mainmenu, ga_mainmenu, false); } } diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 0c3af8e89..c228e73fe 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -650,11 +650,7 @@ void GameInterface::Startup() } else { - if (!userConfig.nologo) Logo([](bool) - { - gameaction = ga_mainmenunostopsound; - }); - else gameaction = ga_mainmenu; + PlayLogos(ga_mainmenunostopsound, ga_mainmenu, false); } } diff --git a/wadsrc/static/zscript/screenjob.zs b/wadsrc/static/zscript/screenjob.zs index 91ccba7dd..088a4ce2a 100644 --- a/wadsrc/static/zscript/screenjob.zs +++ b/wadsrc/static/zscript/screenjob.zs @@ -47,7 +47,7 @@ class ScreenJob : Object int DrawFrame(double smoothratio) { - if (jobstate != running) smoothratio = 1; // this is necessary because the ticker won't be incremented anymore to avoid having a negative time span. + if (jobstate != running) smoothratio = 1; // this is necessary to avoid having a negative time span because the ticker won't be incremented anymore. Draw(smoothratio); if (jobstate == skipped) return -1; if (jobstate == finished) return 0;