From 2fba557a3d9a3ae01eea3c2e93dcf689ae11c4b4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 4 Jul 2020 22:30:18 +0200 Subject: [PATCH] - fixed menu loop --- source/games/duke/src/d_menu.cpp | 2 +- source/games/duke/src/zz_demo.cpp | 104 +++++++++++++++++------------- 2 files changed, 60 insertions(+), 46 deletions(-) diff --git a/source/games/duke/src/d_menu.cpp b/source/games/duke/src/d_menu.cpp index c089b3a19..473c03938 100644 --- a/source/games/duke/src/d_menu.cpp +++ b/source/games/duke/src/d_menu.cpp @@ -141,7 +141,7 @@ class DukeMainMenu : public DukeListMenu double x = origin.X + 160; if (RRRA) { - DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterOffset, true, TAG_DONE); + DrawTexture(twod, tileGetTexture(TILE_THREEDEE), x-5, origin.Y+57, DTA_FullscreenScale, 3, DTA_VirtualWidth, 320, DTA_VirtualHeight, 200, DTA_ScaleX, 0.253, DTA_ScaleY, 0.253, DTA_CenterBottomOffset, true, TAG_DONE); } else if (isRR()) { diff --git a/source/games/duke/src/zz_demo.cpp b/source/games/duke/src/zz_demo.cpp index 5ef55157d..8d7a3d4f6 100644 --- a/source/games/duke/src/zz_demo.cpp +++ b/source/games/duke/src/zz_demo.cpp @@ -29,7 +29,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_DUKE_NS - //////////////////// int32_t G_PlaybackDemo(void) @@ -44,57 +43,63 @@ int32_t G_PlaybackDemo(void) if (ready2send) return 0; - while (int in_menu = g_player[myconnectindex].ps->gm & MODE_MENU) +RECHECK: + in_menu = g_player[myconnectindex].ps->gm&MODE_MENU; + + if (foundemo == 0) { - if (foundemo == 0) + ud.recstat = 0; + + //fadepal(0,0,0, 0,252,28); + drawbackground(); + //M_DisplayMenus(); + videoNextPage(); + //fadepal(0,0,0, 252,0,-28); + ud.reccnt = 0; + } + + if (foundemo == 0 || in_menu || inputState.CheckAllInput() || numplayers > 1) + { + FX_StopAllSounds(); + M_StartControlPanel(false); + } + + ready2send = 0; + + inputState.ClearAllInput(); + + while (true) + { + // Main loop here. It also runs when there's no demo to show, + // so maybe a better name for this function would be + // G_MainLoopWhenNotInGame()? + + if (G_FPSLimit()) { - ud.recstat = 0; - - //fadepal(0,0,0, 0,252,28); - drawbackground(); - //M_DisplayMenus(); - videoNextPage(); - //fadepal(0,0,0, 252,0,-28); - ud.reccnt = 0; - } - - if (foundemo == 0 || in_menu || inputState.CheckAllInput() || numplayers > 1) - { - FX_StopAllSounds(); - M_StartControlPanel(false); - } - - ready2send = 0; - - inputState.ClearAllInput(); - - while (true) - { - // Main loop here. It also runs when there's no demo to show, - // so maybe a better name for this function would be - // G_MainLoopWhenNotInGame()? - if (foundemo == 0) { drawbackground(); } - if ((g_player[myconnectindex].ps->gm & MODE_MENU) && (g_player[myconnectindex].ps->gm & MODE_EOL)) + if ((g_player[myconnectindex].ps->gm&MODE_MENU) && (g_player[myconnectindex].ps->gm&MODE_EOL)) { videoNextPage(); - break; + goto RECHECK; } - else if (g_player[myconnectindex].ps->gm & MODE_TYPE) + else if (g_player[myconnectindex].ps->gm&MODE_TYPE) { - if ((g_player[myconnectindex].ps->gm & MODE_TYPE) != MODE_TYPE) + if ((g_player[myconnectindex].ps->gm&MODE_TYPE) != MODE_TYPE) { g_player[myconnectindex].ps->gm = 0; - M_StartControlPanel(false); - } + M_StartControlPanel(false); + } } else { + //if (ud.recstat != 2) + //M_DisplayMenus(); + if ((g_netServer || ud.multimode > 1))// && !Menu_IsTextInput(m_currentMenu)) { ControlInfo noshareinfo; @@ -107,22 +112,31 @@ int32_t G_PlaybackDemo(void) if (VOLUMEONE) { - if ((g_player[myconnectindex].ps->gm & MODE_MENU) == 0) - rotatesprite_fs((320 - 50) << 16, 9 << 16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2 + 8 + 16 + 128); + if ((g_player[myconnectindex].ps->gm&MODE_MENU) == 0) + rotatesprite_fs((320-50)<<16, 9<<16, 65536L, 0, TILE_BETAVERSION, 0, 0, 2+8+16+128); } videoNextPage(); - G_HandleAsync(); - - if (g_player[myconnectindex].ps->gm == MODE_GAME) - { - // user wants to play a game, quit showing demo! - return 0; - } } - ud.multimode = numplayers; // fixes 2 infinite loops after watching demo + G_HandleAsync(); + + if (g_player[myconnectindex].ps->gm == MODE_GAME) + { + // user wants to play a game, quit showing demo! + return 0; + } } + + ud.multimode = numplayers; // fixes 2 infinite loops after watching demo + + // if we're in the menu, try next demo immediately + if (g_player[myconnectindex].ps->gm&MODE_MENU) + goto RECHECK; + + + // finished playing a demo and not in menu: + // return so that e.g. the title can be shown return 1; }