From e30c72c82922b13438e8c386496002cfcd713046 Mon Sep 17 00:00:00 2001 From: ehouse Date: Sun, 26 Oct 2008 15:33:21 +0000 Subject: [PATCH] make -q option take number of seconds to pause before quitting --- xwords4/linux/cursesmain.c | 4 +++- xwords4/linux/gtkmain.c | 3 ++- xwords4/linux/linuxmain.c | 8 ++++---- xwords4/linux/main.h | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index b46ccfa4d..74ff2d0ca 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -334,11 +334,13 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc ) catGameHistory( &globals->cGlobals ); } - if ( globals->cGlobals.params->quitAfter ) { + if ( globals->cGlobals.params->quitAfter >= 0 ) { + sleep( globals->cGlobals.params->quitAfter ); globals->timeToExit = XP_TRUE; } else if ( globals->cGlobals.params->undoWhenDone ) { server_handleUndo( globals->cGlobals.game.server ); } else { + /* This is modal. Don't show if quitting */ cursesShowFinalScores( globals ); } } /* curses_util_notifyGameOver */ diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 02510a81f..12e1338bb 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -1119,7 +1119,8 @@ gtk_util_notifyGameOver( XW_UtilCtxt* uc ) printFinalScores( globals ); - if ( globals->cGlobals.params->quitAfter ) { + if ( globals->cGlobals.params->quitAfter >= 0 ) { + sleep( globals->cGlobals.params->quitAfter ); quit( NULL, globals ); } else if ( globals->cGlobals.params->undoWhenDone ) { server_handleUndo( globals->cGlobals.game.server ); diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index 0804771e1..29c0f3491 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -180,7 +180,7 @@ usage( char* appName, char* msg ) # endif #endif "\t [-f file] # use this file to save/load game\n" - "\t [-q] # quit when game over (useful for robot-only)\n" + "\t [-q nSecs] # quit with pause when game over (useful for robot-only)\n" "\t [-S] # slow robot down \n" "\t [-i] # print game history when game over\n" "\t [-U] # call 'Undo' after game ends\n" @@ -674,7 +674,7 @@ main( int argc, char** argv ) mainParams.connInfo.ip.hostName = "localhost"; #endif mainParams.gi.boardSize = 15; - mainParams.quitAfter = XP_FALSE; + mainParams.quitAfter = -1; mainParams.sleepOnAnchor = XP_FALSE; mainParams.printHistory = XP_FALSE; mainParams.undoWhenDone = XP_FALSE; @@ -707,7 +707,7 @@ main( int argc, char** argv ) #if defined PLATFORM_GTK "h:I" #endif - "kKf:ln:Nsd:e:r:b:qw:Sit:Umvc" + "kKf:ln:Nsd:e:r:b:q:w:Sit:Umvc" #ifdef XWFEATURE_RELAY "a:p:C:H" #endif @@ -823,7 +823,7 @@ main( int argc, char** argv ) hostName = optarg; break; case 'q': - mainParams.quitAfter = XP_TRUE; + mainParams.quitAfter = atoi(optarg); break; case 'b': mainParams.gi.boardSize = atoi(optarg); diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index 138dc0029..d30161041 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -52,7 +52,7 @@ typedef struct LaunchParams { XP_U16 nLocalPlayers; XP_U16 nHidden; XP_Bool askNewGame; - XP_Bool quitAfter; + XP_S16 quitAfter; XP_Bool sleepOnAnchor; XP_Bool printHistory; XP_Bool undoWhenDone;