From 4950b556c91364b83446f408cc847f8ca3cb34f4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 16 Apr 2021 18:43:59 +0200 Subject: [PATCH] - handled SW's screens. --- source/core/screenjob.cpp | 6 +- source/core/screenjob.h | 1 + source/games/duke/src/2d_d.cpp | 9 +-- source/games/duke/src/2d_r.cpp | 22 +++---- source/games/sw/src/2d.cpp | 108 +++++++++++++++++++-------------- 5 files changed, 78 insertions(+), 68 deletions(-) diff --git a/source/core/screenjob.cpp b/source/core/screenjob.cpp index cbcb39a27..6f7b53436 100644 --- a/source/core/screenjob.cpp +++ b/source/core/screenjob.cpp @@ -59,7 +59,11 @@ IMPLEMENT_CLASS(DImageScreen, true, false) bool DSkippableScreenJob::OnEvent(event_t* evt) { - if (evt->type == EV_GUI_KeyDown) state = skipped; + if (evt->type == EV_KeyDown) + { + state = skipped; + Skipped(); + } return true; } diff --git a/source/core/screenjob.h b/source/core/screenjob.h index cdf72014a..82e053781 100644 --- a/source/core/screenjob.h +++ b/source/core/screenjob.h @@ -85,6 +85,7 @@ protected: {} bool OnEvent(event_t* evt) override; + virtual void Skipped() {} }; //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/2d_d.cpp b/source/games/duke/src/2d_d.cpp index 71ea4825d..b41789177 100644 --- a/source/games/duke/src/2d_d.cpp +++ b/source/games/duke/src/2d_d.cpp @@ -447,14 +447,9 @@ public: { } - bool OnEvent(event_t* evt) override + void Skipped() override { - if (evt->type == EV_GUI_KeyDown) - { - state = skipped; - FX_StopAllSounds(); - } - return true; + FX_StopAllSounds(); } void OnTick() override diff --git a/source/games/duke/src/2d_r.cpp b/source/games/duke/src/2d_r.cpp index 2dd27f388..f7eecc088 100644 --- a/source/games/duke/src/2d_r.cpp +++ b/source/games/duke/src/2d_r.cpp @@ -481,11 +481,8 @@ public: FormatTime(currentLevel->parTime, tempbuf); BigText(191, 64, tempbuf, -1); - if (!isNamWW2GI()) - { - FormatTime(currentLevel->designerTime, tempbuf); - BigText(191, 80, tempbuf, -1); - } + FormatTime(currentLevel->designerTime, tempbuf); + BigText(191, 80, tempbuf, -1); } } @@ -556,21 +553,18 @@ public: }; -class DRRRAEndOfGame : public DScreenJob +class DRRRAEndOfGame : public DSkippableScreenJob { public: - DRRRAEndOfGame() : DScreenJob(fadein|fadeout) + DRRRAEndOfGame() : DSkippableScreenJob(fadein|fadeout) { } - bool OnEvent(event_t* ev) override + + void Skipped() override { - if (ev->type == EV_GUI_KeyDown) - { - S_StopSound(35); - state = skipped; - } - return true; + S_StopSound(35); } + void OnTick() override { if (ticks == 1) S_PlaySound(35, CHAN_AUTO, CHANF_UI); diff --git a/source/games/sw/src/2d.cpp b/source/games/sw/src/2d.cpp index cfe9a88b2..8256b0be3 100644 --- a/source/games/sw/src/2d.cpp +++ b/source/games/sw/src/2d.cpp @@ -45,20 +45,23 @@ BEGIN_SW_NS // //--------------------------------------------------------------------------- -class DSWDRealmsScreen : public DScreenJob +class DSWDRealmsScreen : public DSkippableScreenJob { public: - DSWDRealmsScreen() : DScreenJob(fadein | fadeout) {} + DSWDRealmsScreen() : DSkippableScreenJob(fadein | fadeout) {} - int Frame(uint64_t clock, bool skiprequest) override + void OnTick() override + { + if (ticks > 5 * GameTicRate) state = finished; + } + + void Draw(double) override { - const uint64_t duration = 5'000'000'000; const auto tex = tileGetTexture(THREED_REALMS_PIC, true); const int translation = TRANSLATION(Translation_BasePalettes, DREALMSPAL); twod->ClearScreen(); DrawTexture(twod, tex, 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_TranslationIndex, translation, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); - return skiprequest ? -1 : clock < duration ? 1 : 0; } }; @@ -166,7 +169,7 @@ DScreenJob* GetFinishAnim(int num) // //--------------------------------------------------------------------------- -class DSWCreditsScreen : public DScreenJob +class DSWCreditsScreen : public DSkippableScreenJob { enum { @@ -177,21 +180,23 @@ class DSWCreditsScreen : public DScreenJob int starttime; int curpic; - int Frame(uint64_t clock, bool skiprequest) + void Skipped() override { - twod->ClearScreen(); - int seconds = int(clock / 1'000'000'000); - if (clock == 0) + StopSound(); + } + + void OnTick() override + { + if (ticks == 1) { // Lo Wang feel like singing! PlaySound(DIGI_JG95012, v3df_none, CHAN_VOICE, CHANF_UI); } if (state == 0) { - if (skiprequest || !soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) + if (!soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, CHAN_VOICE)) { - skiprequest = false; - starttime = seconds; + starttime = ticks; state = 1; StopSound(); curpic = CREDITS1_PIC; @@ -205,15 +210,19 @@ class DSWCreditsScreen : public DScreenJob } else { - if (seconds >= starttime + 8) + if (ticks >= starttime + 8 * GameTicRate) { curpic = CREDITS1_PIC + CREDITS2_PIC - curpic; - starttime = seconds; + starttime = ticks; } - DrawTexture(twod, tileGetTexture(curpic, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); } - if (skiprequest) StopSound(); - return skiprequest ? -1 : 1; + } + + void Draw(double) override + { + twod->ClearScreen(); + if (state == 1) + DrawTexture(twod, tileGetTexture(curpic, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); } }; @@ -377,31 +386,41 @@ private: (*(*State)->Animator)(0); } - int Frame(uint64_t clock, bool skiprequest) + bool OnEvent(event_t* ev) override { - twod->ClearScreen(); - int currentclock = int(clock * 120 / 1'000'000'000); + if (ev->type == EV_KeyDown) + { + if (State >= s_BonusRest && State < &s_BonusRest[countof(s_BonusRest)]) + { + State = s_BonusAnim[STD_RANDOM_RANGE(countof(s_BonusAnim))]; + Tics = 0; + nextclock = ticks; + } + } + return true; + } - if (clock == 0) + void OnTick() override + { + if (ticks == 1) { PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]); } + while (ticks > nextclock) + { + nextclock++; + gStateControl(&State, &Tics); + } - if (skiprequest && State >= s_BonusRest && State < &s_BonusRest[countof(s_BonusRest)]) + if (State == State->NextState) { - State = s_BonusAnim[STD_RANDOM_RANGE(countof(s_BonusAnim))]; - Tics = 0; - skiprequest = false; - nextclock = currentclock; - } - else - { - while (currentclock > nextclock) - { - nextclock += synctics; - gStateControl(&State, &Tics); - } + state = finished; + StopSound(); } + } + + void Draw(double) override + { twod->ClearScreen(); DrawTexture(twod, tileGetTexture(BONUS_SCREEN_PIC, true), 0, 0, DTA_FullscreenEx, FSMode_ScaleToFit43, DTA_LegacyRenderStyle, STYLE_Normal, TAG_DONE); MNU_DrawString(160, 20, currentLevel->DisplayName(), 1, 19, 0); @@ -437,10 +456,6 @@ private: MNU_DrawString(60, BONUS_LINE(line), ds, 1, 16); MNU_DrawString(160, 185, GStrings("PRESSKEY"), 1, 19, 0); - - int ret = (State == State->NextState)? 0 : skiprequest ? -1 : 1; - if (ret != 1) StopSound(); - return ret; } }; @@ -466,12 +481,17 @@ enum }; -class DSWMultiSummaryScreen : public DScreenJob +class DSWMultiSummaryScreen : public DSkippableScreenJob { short death_total[MAX_SW_PLAYERS_REG]{}; short kills[MAX_SW_PLAYERS_REG]{}; - int Frame(uint64_t clock, bool skiprequest) + void Skipped() override + { + StopSound(); + } + + void Draw(double) override { if (clock == 0) PlaySong(nullptr, ThemeSongs[1], ThemeTrack[1]); @@ -571,8 +591,6 @@ class DSWMultiSummaryScreen : public DScreenJob y += STAT_OFF_Y; } - if (skiprequest) StopSound(); - return skiprequest ? -1 : 1; } }; @@ -635,7 +653,7 @@ class DSWLoadScreen : public DScreenJob public: DSWLoadScreen(MapRecord* maprec) : DScreenJob(0), rec(maprec) {} - int Frame(uint64_t clock, bool skiprequest) + void Draw(double) override { const int TITLE_PIC = 2324; twod->ClearScreen(); @@ -643,8 +661,6 @@ public: MNU_DrawString(160, 170, /*DemoMode ? GStrings("TXT_LBDEMO") :*/ GStrings("TXT_ENTERING"), 1, 16, 0); MNU_DrawString(160, 180, rec->DisplayName(), 1, 16, 0); - - return 0; } };