From 840e87ce39fe2319cbcfc4ff97c2781ce36e5549 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Thu, 27 Mar 2014 22:44:19 -0400 Subject: hexen: Allow abort on startup by pressing escape. Vanilla Hexen allows the game startup to be aborted by pressing the escape key. This can also be used to abort netgame startup. Add back this functionality by polling the SDL event loop; this feature only works if the graphical startup is enabled, but that's good enough. --- src/hexen/d_net.c | 4 +++- src/hexen/st_start.c | 8 ++++---- src/i_videohr.c | 23 +++++++++++++++++++++++ src/i_videohr.h | 1 + 4 files changed, 31 insertions(+), 5 deletions(-) diff --git a/src/hexen/d_net.c b/src/hexen/d_net.c index f3b7766e..5c64f7ed 100644 --- a/src/hexen/d_net.c +++ b/src/hexen/d_net.c @@ -33,6 +33,7 @@ #include "i_system.h" #include "i_timer.h" #include "i_video.h" +#include "i_videohr.h" #include "h2def.h" #include "p_local.h" #include "s_sound.h" @@ -239,7 +240,8 @@ static boolean StartupProgress(int now_ready, int total) ready = now_ready; - return true; + // Allow the user to hit escape during netgame startup to abort. + return !I_CheckAbortHR(); } // diff --git a/src/hexen/st_start.c b/src/hexen/st_start.c index 58df878e..b8cf389a 100644 --- a/src/hexen/st_start.c +++ b/src/hexen/st_start.c @@ -204,11 +204,11 @@ void ST_UpdateNetNotches(int notchPosition) void ST_Progress(void) { - // haleyjd FIXME: any way to get input here? SDL event loop? -#ifdef __WATCOMC__ // Check for ESC press -- during startup all events eaten here - I_StartupReadKeys(); -#endif + if (I_CheckAbortHR()) + { + I_Quit(); + } if (using_graphical_startup) { diff --git a/src/i_videohr.c b/src/i_videohr.c index 94fc5309..5a491def 100644 --- a/src/i_videohr.c +++ b/src/i_videohr.c @@ -220,3 +220,26 @@ void I_BlackPaletteHR(void) I_SetPaletteHR(blackpal); } +// Check if the user has hit the escape key to abort startup. +boolean I_CheckAbortHR(void) +{ + SDL_Event ev; + boolean result = false; + + // Not initialized? + if (hr_surface == NULL) + { + return false; + } + + while (SDL_PollEvent(&ev)) + { + if (ev.type == SDL_KEYDOWN && ev.key.keysym.sym == SDLK_ESCAPE) + { + result = true; + } + } + + return result; +} + diff --git a/src/i_videohr.h b/src/i_videohr.h index 5de5158f..12b2abf4 100644 --- a/src/i_videohr.h +++ b/src/i_videohr.h @@ -37,6 +37,7 @@ void I_InitPaletteHR(void); void I_SetPaletteHR(const byte *palette); void I_FadeToPaletteHR(const byte *palette); void I_BlackPaletteHR(void); +boolean I_CheckAbortHR(void); #endif /* #ifndef I_VIDEOHR_H */ -- cgit v1.2.3