From e3dac2cd1fb70db6f94bd855b6c93d44383eb91b Mon Sep 17 00:00:00 2001 From: mcmartin Date: Mon, 7 Jul 2003 02:51:42 +0000 Subject: [PATCH] F10 at main menu quits game git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1031 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/ChangeLog | 1 + sc2/src/sc2code/confirm.c | 5 +++- sc2/src/sc2code/controls.h | 3 ++- .../sc2code/libs/graphics/sdl/sdl_common.c | 9 ++++++- sc2/src/sc2code/libs/input/sdl/input.c | 1 + sc2/src/sc2code/restart.c | 27 +++++++------------ 6 files changed, 26 insertions(+), 20 deletions(-) diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 9f63ece68..25d72078e 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.3: +- Exiting from the main menu with F10 now exits the game -Michael - Changed lander speed to 35 FPS, which matches reported 3DO speed (Bug #22) -Michael - Added a Menu-Delete key for the Super-Melee menu (#123) -Michael diff --git a/sc2/src/sc2code/confirm.c b/sc2/src/sc2code/confirm.c index a56434969..d6f405fb3 100644 --- a/sc2/src/sc2code/confirm.c +++ b/sc2/src/sc2code/confirm.c @@ -72,6 +72,7 @@ BOOLEAN DoConfirmExit (void) { BOOLEAN result; + static BOOLEAN in_confirm = FALSE; fprintf (stderr, "Confirming Exit!\n"); if (LOBYTE (GLOBAL (CurrentActivity)) != SUPER_MELEE) SuspendGameClock (); @@ -79,7 +80,7 @@ DoConfirmExit (void) PauseTrack (); SetSemaphore (GraphicsSem); - if (GLOBAL (CurrentActivity) & CHECK_ABORT) + if (in_confirm) { result = FALSE; ExitRequested = FALSE; @@ -92,6 +93,7 @@ DoConfirmExit (void) CONTEXT oldContext; BOOLEAN response = TRUE, done; + in_confirm = TRUE; oldContext = SetContext (ScreenContext); r.extent.width = CONFIRM_WIN_WIDTH; @@ -167,6 +169,7 @@ DoConfirmExit (void) } fprintf (stderr, "Exit was %sconfirmed.\n", result ? "" : "NOT "); + in_confirm = FALSE; return (result); } diff --git a/sc2/src/sc2code/controls.h b/sc2/src/sc2code/controls.h index 9727cfb63..33568c715 100644 --- a/sc2/src/sc2code/controls.h +++ b/sc2/src/sc2code/controls.h @@ -62,7 +62,8 @@ void SetMenuRepeatDelay (DWORD min, DWORD max, DWORD step, BOOLEAN gestalt); void SetDefaultMenuRepeatDelay (void); void ResetKeyRepeat (void); BOOLEAN PauseGame (void); -extern BOOLEAN DoConfirmExit (void); +BOOLEAN DoConfirmExit (void); +void TFB_Abort (void); BATTLE_INPUT_STATE p1_combat_summary (void); BATTLE_INPUT_STATE p2_combat_summary (void); diff --git a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c index 889e748ef..8a7103184 100644 --- a/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/sc2code/libs/graphics/sdl/sdl_common.c @@ -38,6 +38,7 @@ SDL_Surface *SDL_Screens[TFB_GFX_NUMSCREENS]; volatile int TransitionAmount = 255; SDL_Rect TransitionClipRect; +static volatile BOOLEAN abortFlag = FALSE; int GfxFlags = 0; @@ -46,6 +47,12 @@ static TFB_Palette palette[256]; #define FPS_PERIOD 1000 int RenderedFrames = 0; +void +TFB_Abort (void) +{ + abortFlag = TRUE; +} + int TFB_InitGraphics (int driver, int flags, int width, int height, int bpp) { @@ -123,7 +130,7 @@ TFB_ProcessEvents () break; } } - if (ImmediateInputState.abort) + if (ImmediateInputState.abort || abortFlag) exit (0); if (ImmediateInputState.debug) { diff --git a/sc2/src/sc2code/libs/input/sdl/input.c b/sc2/src/sc2code/libs/input/sdl/input.c index 593e2f535..c889d7388 100644 --- a/sc2/src/sc2code/libs/input/sdl/input.c +++ b/sc2/src/sc2code/libs/input/sdl/input.c @@ -168,6 +168,7 @@ TFB_InitInput (int driver, int flags) VControl_ResetInput (); InputInitialized = TRUE; + atexit (TFB_UninitInput); return 0; } diff --git a/sc2/src/sc2code/restart.c b/sc2/src/sc2code/restart.c index 1c6097a57..d469773fd 100644 --- a/sc2/src/sc2code/restart.c +++ b/sc2/src/sc2code/restart.c @@ -86,9 +86,6 @@ DoRestart (PMENU_STATE pMS) { /* Cancel any presses of the Pause or Exit keys. */ GamePaused = FALSE; - ExitRequested = FALSE; - GameExiting = FALSE; - if (!pMS->Initialized) { @@ -104,6 +101,10 @@ DoRestart (PMENU_STATE pMS) #ifdef TESTING else if (InputState & DEVICE_EXIT) return (FALSE); #endif /* TESTING */ + else if (GameExiting) + { + return (FALSE); + } else if (!(CurrentMenuState.up || CurrentMenuState.down || CurrentMenuState.left || CurrentMenuState.right || CurrentMenuState.select)) @@ -250,6 +251,7 @@ LastActivity = WON_LAST_BATTLE; UnbatchGraphics (); FlushInput (); + GameExiting = FALSE; DoInput ((PVOID)&MenuState, TRUE); SetSemaphore (GraphicsSem); @@ -257,22 +259,13 @@ LastActivity = WON_LAST_BATTLE; ClearSemaphore (GraphicsSem); DestroyDrawable (ReleaseDrawable (s.frame)); + if (GameExiting) + { + TFB_Abort (); + } + if (GLOBAL (CurrentActivity) == (ACTIVITY)~0) goto TimedOut; -#ifdef TESTING -if (GLOBAL (CurrentActivity) & CHECK_ABORT) -{ - WaitForSoundEnd (WAIT_ALL_SOUNDS); - StopSound (); - - FreeSC2Data (); - FreeLanderData (); - FreeIPData (); - FreeHyperData (); - FlushColorXForms (); - return (FALSE); -} -#endif /* TESTING */ TimeOut = XFormColorMap ((COLORMAPPTR)black_buf, ONE_SECOND / 2); }