diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index bdf206649..61161c503 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -95,6 +95,7 @@ typedef struct MenuList { } MenuList; static XP_Bool handleQuit( CursesAppGlobals* globals ); +static XP_Bool handleResend( CursesAppGlobals* globals ); static XP_Bool handleRight( CursesAppGlobals* globals ); static XP_Bool handleSpace( CursesAppGlobals* globals ); static XP_Bool handleRet( CursesAppGlobals* globals ); @@ -123,6 +124,7 @@ static XP_Bool handleRootKeyHide( CursesAppGlobals* globals ); const MenuList g_sharedMenuList[] = { { handleQuit, "Quit", "Q", 'Q' }, + { handleResend, "Resend", "R", 'R' }, { handleRight, "Tab right", "", '\t' }, { handleSpace, "Raise focus", "", ' ' }, { handleRet, "Click/tap", "", '\r' }, @@ -336,12 +338,14 @@ curses_util_notifyGameOver( XW_UtilCtxt* uc ) catGameHistory( &globals->cGlobals ); } + catFinalScores( &globals->cGlobals ); + if ( globals->cGlobals.params->quitAfter >= 0 ) { sleep( globals->cGlobals.params->quitAfter ); handleQuit( globals ); } else if ( globals->cGlobals.params->undoWhenDone ) { server_handleUndo( globals->cGlobals.game.server ); - } else { + } else if ( !globals->cGlobals.params->skipGameOver ) { /* This is modal. Don't show if quitting */ cursesShowFinalScores( globals ); } @@ -487,6 +491,15 @@ handleQuit( CursesAppGlobals* globals ) return XP_TRUE; } /* handleQuit */ +static XP_Bool +handleResend( CursesAppGlobals* globals ) +{ + if ( !!globals->cGlobals.game.comms ) { + comms_resendAll( globals->cGlobals.game.comms ); + } + return XP_TRUE; +} + static void checkAssignFocus( BoardCtxt* board ) { diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index 60fbe3f1c..4a6841531 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -65,7 +65,6 @@ static void sendOnClose( XWStreamCtxt* stream, void* closure ); #endif static void setCtrlsForTray( GtkAppGlobals* globals ); -static void printFinalScores( GtkAppGlobals* globals ); static void new_game( GtkWidget* widget, GtkAppGlobals* globals ); static void new_game_impl( GtkAppGlobals* globals, XP_Bool fireConnDlg ); @@ -718,7 +717,7 @@ final_scores( GtkWidget* XP_UNUSED(widget), GtkAppGlobals* globals ) XP_Bool gameOver = server_getGameIsOver( globals->cGlobals.game.server ); if ( gameOver ) { - printFinalScores( globals ); + catFinalScores( &globals->cGlobals ); } else { if ( gtkask( "Are you sure everybody wants to end the game now?", GTK_BUTTONS_YES_NO ) ) { @@ -1233,35 +1232,43 @@ gtk_util_yOffsetChange( XW_UtilCtxt* uc, XP_U16 XP_UNUSED(oldOffset), } /* gtk_util_yOffsetChange */ static void -printFinalScores( GtkAppGlobals* globals ) +gtkShowFinalScores( const CommonGlobals* cGlobals ) { XWStreamCtxt* stream; + XP_UCHAR* text; - stream = mem_stream_make( MEMPOOL - globals->cGlobals.params->vtMgr, - globals, CHANNEL_NONE, catOnClose ); - server_writeFinalScores( globals->cGlobals.game.server, stream ); - stream_putU8( stream, '\n' ); - stream_destroy( stream ); -} /* printFinalScores */ + stream = mem_stream_make( MPPARM(cGlobals->params->util->mpool) + cGlobals->params->vtMgr, + NULL, CHANNEL_NONE, NULL ); + server_writeFinalScores( cGlobals->game.server, stream ); + + text = strFromStream( stream ); + + (void)gtkask( text, GTK_BUTTONS_OK ); + + free( text ); +} /* gtkShowFinalScores */ static void gtk_util_notifyGameOver( XW_UtilCtxt* uc ) { GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure; + CommonGlobals* cGlobals = &globals->cGlobals; - if ( globals->cGlobals.params->printHistory ) { - catGameHistory( &globals->cGlobals ); + if ( cGlobals->params->printHistory ) { + catGameHistory( cGlobals ); } - printFinalScores( globals ); + catFinalScores( cGlobals ); - if ( globals->cGlobals.params->quitAfter >= 0 ) { - sleep( globals->cGlobals.params->quitAfter ); + if ( cGlobals->params->quitAfter >= 0 ) { + sleep( cGlobals->params->quitAfter ); quit( NULL, globals ); - } else if ( globals->cGlobals.params->undoWhenDone ) { - server_handleUndo( globals->cGlobals.game.server ); - board_draw( globals->cGlobals.game.board ); + } else if ( cGlobals->params->undoWhenDone ) { + server_handleUndo( cGlobals->game.server ); + board_draw( cGlobals->game.board ); + } else if ( !cGlobals->params->skipGameOver ) { + gtkShowFinalScores( cGlobals ); } } /* gtk_util_notifyGameOver */ diff --git a/xwords4/linux/linuxmain.c b/xwords4/linux/linuxmain.c index df7d1055e..01189d0e5 100644 --- a/xwords4/linux/linuxmain.c +++ b/xwords4/linux/linuxmain.c @@ -134,8 +134,6 @@ catOnClose( XWStreamCtxt* stream, void* XP_UNUSED(closure) ) XP_U16 nBytes; char* buffer; - XP_LOGF( "catOnClose" ); - nBytes = stream_getSize( stream ); buffer = malloc( nBytes + 1 ); stream_getBytes( stream, buffer, nBytes ); @@ -162,6 +160,19 @@ catGameHistory( CommonGlobals* cGlobals ) } } /* catGameHistory */ +void +catFinalScores( const CommonGlobals* cGlobals ) +{ + XWStreamCtxt* stream; + + stream = mem_stream_make( MPPARM(cGlobals->params->util->mpool) + cGlobals->params->vtMgr, + NULL, CHANNEL_NONE, catOnClose ); + server_writeFinalScores( cGlobals->game.server, stream ); + stream_putU8( stream, '\n' ); + stream_destroy( stream ); +} /* printFinalScores */ + XP_UCHAR* strFromStream( XWStreamCtxt* stream ) { @@ -214,6 +225,7 @@ usage( char* appName, char* msg ) "\t [-L] # duplicate all packets sent\n" "\t [-P] # pick tiles face up\n" "\t [-F] # ask for turn confirmation\n" + "\t [-o] # skip (modal) gameOver notification\n" "\t [-c] # explain robot scores after each move\n" "\t [-C INVITE] # invite used to groups games on relay\n" "\t\t # (max of four players total, local and remote)\n" @@ -797,7 +809,7 @@ main( int argc, char** argv ) #if defined PLATFORM_GTK "h:I" #endif - "0b:cd:e:Ff:iKkLlmNn:Pr:Ssq:t:Uw:v" + "0b:cod:e:Ff:iKkLlmNn:Pr:Ssq:t:Uw:v" #ifdef XWFEATURE_SLOW_ROBOT "z:" #endif @@ -821,6 +833,9 @@ main( int argc, char** argv ) case '?': usage(argv[0], NULL); break; + case 'o': + mainParams.skipGameOver = XP_TRUE; + break; case 'c': mainParams.showRobotScores = XP_TRUE; break; diff --git a/xwords4/linux/linuxmain.h b/xwords4/linux/linuxmain.h index f9e2ab517..a14a9de62 100644 --- a/xwords4/linux/linuxmain.h +++ b/xwords4/linux/linuxmain.h @@ -58,6 +58,7 @@ XP_UCHAR* strFromStream( XWStreamCtxt* stream ); void catGameHistory( CommonGlobals* cGlobals ); void catOnClose( XWStreamCtxt* stream, void* closure ); +void catFinalScores( const CommonGlobals* cGlobals ); XP_Bool file_exists( const char* fileName ); XWStreamCtxt* streamFromFile( CommonGlobals* cGlobals, char* name, void* closure ); diff --git a/xwords4/linux/main.h b/xwords4/linux/main.h index 204b4a94c..417c61150 100644 --- a/xwords4/linux/main.h +++ b/xwords4/linux/main.h @@ -66,6 +66,7 @@ typedef struct LaunchParams { XP_Bool showRobotScores; XP_Bool noHeartbeat; XP_Bool duplicatePackets; + XP_Bool skipGameOver; #ifdef XWFEATURE_SEARCHLIMIT XP_Bool allowHintRect; #endif