diff --git a/xwords4/common/board.c b/xwords4/common/board.c index 4b5e8c9e5..568ad8df4 100644 --- a/xwords4/common/board.c +++ b/xwords4/common/board.c @@ -214,8 +214,10 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, board->showColors = (XP_Bool)stream_getBits( stream, 1 ); board->showCellValues = (XP_Bool)stream_getBits( stream, 1 ); #ifdef KEYBOARD_NAV - if ( version >= STREAM_VERS_RELAY ) { + if ( version >= STREAM_VERS_KEYNAV ) { board->focussed = (BoardObjectType)stream_getBits( stream, 2 ); + board->focusHasDived = (BoardObjectType)stream_getBits( stream, 1 ); + board->scoreCursorLoc = (BoardObjectType)stream_getBits( stream, 2 ); } #endif @@ -233,7 +235,7 @@ board_makeFromStream( MPFORMAL XWStreamCtxt* stream, ModelCtxt* model, MAX_TRAY_TILES ); board->tradeInProgress[i] = (XP_Bool)stream_getBits( stream, 1 ); #ifdef KEYBOARD_NAV - if ( version >= STREAM_VERS_RELAY ) { + if ( version >= STREAM_VERS_KEYNAV ) { board->bdCursor[i].col = stream_getBits( stream, 4 ); board->bdCursor[i].row = stream_getBits( stream, 4 ); board->trayCursorLoc[i] = stream_getBits( stream, 3 ); @@ -275,6 +277,8 @@ board_writeToStream( BoardCtxt* board, XWStreamCtxt* stream ) stream_putBits( stream, 1, board->showCellValues ); #ifdef KEYBOARD_NAV stream_putBits( stream, 2, board->focussed ); + stream_putBits( stream, 1, board->focusHasDived ); + stream_putBits( stream, 2, board->scoreCursorLoc ); #endif XP_ASSERT( !!board->server ); @@ -1135,7 +1139,8 @@ drawBoard( BoardCtxt* board ) drawTradeWindowIf( board ); - draw_boardFinished( board->draw ); + draw_objFinished( board->draw, OBJ_BOARD, &board->boardBounds, + dfsFor( board, OBJ_BOARD ) ); board->needsDrawing = !allDrawn; } @@ -1310,7 +1315,8 @@ drawScoreBoard( BoardCtxt* board ) } #endif - draw_scoreFinished( board->draw ); + draw_objFinished( board->draw, OBJ_SCORE, &board->scoreBdBounds, + dfsFor( board, OBJ_SCORE ) ); } board->scoreBoardInvalid = XP_FALSE; @@ -1703,7 +1709,8 @@ board_requestHint( BoardCtxt* board, board_pushTimerSave( board ); #ifdef XWFEATURE_SEARCHLIMIT - XP_ASSERT( board->gi->allowHintRect || !board->hasHintRect[selPlayer] ); + XP_ASSERT( board->gi->allowHintRect + || !board->hasHintRect[selPlayer] ); #endif searchComplete = engine_findMove(engine, model, model_getDictionary(model), @@ -1823,12 +1830,15 @@ figureBoardRect( BoardCtxt* board ) boardBounds.height = (model_numRows( board->model ) - board->yOffset) * board->boardVScale; - if ( board->trayVisState != TRAY_HIDDEN && board->boardObscuresTray ) { - boardBounds.height = board->trayBounds.top - boardBounds.top; - } else { - XP_U16 trayBottom = board->trayBounds.top + board->trayBounds.height; - if ( trayBottom < boardBounds.top + boardBounds.height ) { - boardBounds.height = trayBottom - boardBounds.top; + if ( board->boardObscuresTray ) { + if ( board->trayVisState != TRAY_HIDDEN ) { + boardBounds.height = board->trayBounds.top - boardBounds.top; + } else { + XP_U16 trayBottom; + trayBottom = board->trayBounds.top + board->trayBounds.height; + if ( trayBottom < boardBounds.top + boardBounds.height ) { + boardBounds.height = trayBottom - boardBounds.top; + } } } /* round down */ diff --git a/xwords4/common/draw.h b/xwords4/common/draw.h index 39b84607b..564f25446 100644 --- a/xwords4/common/draw.h +++ b/xwords4/common/draw.h @@ -97,7 +97,9 @@ typedef struct DrawCtxVTable { const DictionaryCtxt* dict, const XP_Rect* rect, DrawFocusState dfs ); - void DRAW_VTABLE_NAME(boardFinished) ( DrawCtx* dctx ); + void DRAW_VTABLE_NAME(objFinished)( DrawCtx* dctx, BoardObjectType typ, + const XP_Rect* rect, + DrawFocusState dfs ); /* rect is not const: set by callee */ XP_Bool DRAW_VTABLE_NAME(vertScrollBoard) (DrawCtx* dctx, XP_Rect* rect, @@ -106,8 +108,6 @@ typedef struct DrawCtxVTable { XP_Bool DRAW_VTABLE_NAME(trayBegin) ( DrawCtx* dctx, const XP_Rect* rect, XP_U16 owner, DrawFocusState dfs ); - void DRAW_VTABLE_NAME(trayFinished) ( DrawCtx* dctx ); - void DRAW_VTABLE_NAME(measureRemText) ( DrawCtx* dctx, const XP_Rect* r, XP_S16 nTilesLeft, XP_U16* width, XP_U16* height ); @@ -126,10 +126,10 @@ typedef struct DrawCtxVTable { const XP_Rect* rOuter, const DrawScoreInfo* dsi ); - void DRAW_VTABLE_NAME(score_pendingScore) ( DrawCtx* dctx, const XP_Rect* rect, - XP_S16 score, XP_U16 playerNum ); - - void DRAW_VTABLE_NAME(scoreFinished) ( DrawCtx* dctx ); + void DRAW_VTABLE_NAME(score_pendingScore) ( DrawCtx* dctx, + const XP_Rect* rect, + XP_S16 score, + XP_U16 playerNum ); void DRAW_VTABLE_NAME(drawTimer) ( DrawCtx* dctx, const XP_Rect* rInner, const XP_Rect* rOuter, @@ -215,9 +215,8 @@ struct DrawCtx { #define draw_destroyCtxt(dc) CALL_DRAW_NAME0(destroyCtxt, dc) #define draw_boardBegin( dc,d,r,f ) CALL_DRAW_NAME3(boardBegin, dc, d,r,f) -#define draw_boardFinished( dc ) CALL_DRAW_NAME0(boardFinished, (dc)) +#define draw_objFinished( dc, t, r, d ) CALL_DRAW_NAME3(objFinished, (dc), (t), (r), (d)) #define draw_trayBegin( dc, r, o, f ) CALL_DRAW_NAME3(trayBegin,dc, r, o, f) -#define draw_trayFinished( dc ) CALL_DRAW_NAME0(trayFinished,dc) #define draw_vertScrollBoard( dc, r, d ) \ CALL_DRAW_NAME2(vertScrollBoard, (dc),(r),(d)) #define draw_scoreBegin( dc, r, t, f ) \ @@ -232,8 +231,6 @@ struct DrawCtx { CALL_DRAW_NAME3(score_drawPlayer,(dc),(ri),(ro),(dsi)) #define draw_score_pendingScore(dc, r, s, p ) \ CALL_DRAW_NAME3(score_pendingScore,(dc), (r), (s), (p)) -#define draw_scoreFinished( dc ) \ - CALL_DRAW_NAME0(scoreFinished,dc) #define draw_drawTimer( dc, ri, ro, plyr, sec ) \ CALL_DRAW_NAME4(drawTimer,(dc),(ri),(ro),(plyr),(sec)) #define draw_drawCell( dc, rect, txt, bmap, t, o, bon, hi, bl, h, s ) \ diff --git a/xwords4/common/game.c b/xwords4/common/game.c index 367f25c86..698c64f65 100644 --- a/xwords4/common/game.c +++ b/xwords4/common/game.c @@ -158,12 +158,13 @@ game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util, board_prefsChanged( game->board, cp ); } /* game_reset */ -void +XP_Bool game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game, CurGameInfo* gi, DictionaryCtxt* dict, XW_UtilCtxt* util, DrawCtx* draw, CommonPrefs* cp, TransportSend sendProc, void* closure ) { + XP_Bool success = XP_FALSE; XP_U8 strVersion; #ifndef XWFEATURE_STANDALONE_ONLY XP_Bool hasComms; @@ -171,36 +172,42 @@ game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game, strVersion = stream_getU8( stream ); XP_DEBUGF( "strVersion = %d", (XP_U16)strVersion ); - stream_setVersion( stream, strVersion ); + if ( strVersion <= CUR_STREAM_VERS ) { + stream_setVersion( stream, strVersion ); - gi_readFromStream( MPPARM(mpool) stream, gi ); + gi_readFromStream( MPPARM(mpool) stream, gi ); #ifndef XWFEATURE_STANDALONE_ONLY - hasComms = stream_getU8( stream ); - if ( hasComms ) { - game->comms = comms_makeFromStream( MPPARM(mpool) stream, util, - sendProc, closure ); - comms_start( game->comms ); - } else { - game->comms = NULL; - } + hasComms = stream_getU8( stream ); + if ( hasComms ) { + game->comms = comms_makeFromStream( MPPARM(mpool) stream, util, + sendProc, closure ); + comms_start( game->comms ); + } else { + game->comms = NULL; + } #endif - game->model = model_makeFromStream( MPPARM(mpool) stream, dict, util ); + game->model = model_makeFromStream( MPPARM(mpool) stream, dict, util ); - game->server = server_makeFromStream( MPPARM(mpool) stream, - game->model, + game->server = server_makeFromStream( MPPARM(mpool) stream, + game->model, #ifndef XWFEATURE_STANDALONE_ONLY - game->comms, + game->comms, #else - (CommsCtxt*)NULL, + (CommsCtxt*)NULL, #endif - util, gi->nPlayers ); + util, gi->nPlayers ); - game->board = board_makeFromStream( MPPARM(mpool) stream, game->model, - game->server, draw, util, - gi->nPlayers ); - server_prefsChanged( game->server, cp ); - board_prefsChanged( game->board, cp ); + game->board = board_makeFromStream( MPPARM(mpool) stream, game->model, + game->server, draw, util, + gi->nPlayers ); + server_prefsChanged( game->server, cp ); + board_prefsChanged( game->board, cp ); + success = XP_TRUE; + } else { + XP_LOGF( "%s: aborting; stream version too new!", __FUNCTION__ ); + } + return success; } /* game_makeFromStream */ void diff --git a/xwords4/common/game.h b/xwords4/common/game.h index 5450f94e6..df7c349fa 100644 --- a/xwords4/common/game.h +++ b/xwords4/common/game.h @@ -30,11 +30,16 @@ extern "C" { #endif +#define STREAM_VERS_KEYNAV 0x04 #define STREAM_VERS_RELAY 0x03 #define STREAM_VERS_41B4 0x02 #define STREAM_VERS_405 0x01 -#define CUR_STREAM_VERS STREAM_VERS_RELAY +#ifdef KEYBOARD_NAV +# define CUR_STREAM_VERS STREAM_VERS_KEYNAV +#else +# define CUR_STREAM_VERS STREAM_VERS_RELAY +#endif typedef struct LocalPlayer { XP_UCHAR* name; @@ -81,11 +86,11 @@ void game_reset( MPFORMAL XWGame* game, CurGameInfo* gi, XW_UtilCtxt* util, XP_U16 gameID, CommonPrefs* cp, TransportSend sendproc, void* closure ); -void game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game, - CurGameInfo* gi, - DictionaryCtxt* dict, XW_UtilCtxt* util, - DrawCtx* draw, CommonPrefs* cp, - TransportSend sendProc, void* closure ); +XP_Bool game_makeFromStream( MPFORMAL XWStreamCtxt* stream, XWGame* game, + CurGameInfo* gi, + DictionaryCtxt* dict, XW_UtilCtxt* util, + DrawCtx* draw, CommonPrefs* cp, + TransportSend sendProc, void* closure ); void game_saveToStream( const XWGame* game, const CurGameInfo* gi, XWStreamCtxt* stream ); diff --git a/xwords4/common/tray.c b/xwords4/common/tray.c index 6a56611c2..e46d70db0 100644 --- a/xwords4/common/tray.c +++ b/xwords4/common/tray.c @@ -190,7 +190,8 @@ drawTray( BoardCtxt* board ) #endif } - draw_trayFinished(board->draw); + draw_objFinished( board->draw, OBJ_TRAY, &board->trayBounds, + dfsFor( board, OBJ_TRAY ) ); board->trayInvalBits = 0; } diff --git a/xwords4/linux/cursesdraw.c b/xwords4/linux/cursesdraw.c index c5b6d50bb..174e9a7f0 100644 --- a/xwords4/linux/cursesdraw.c +++ b/xwords4/linux/cursesdraw.c @@ -26,6 +26,7 @@ #include "cursesmain.h" #include "draw.h" #include "board.h" +#include "dbgutil.h" typedef struct CursesDrawCtx { DrawCtxVTable* vtable; @@ -83,45 +84,31 @@ curses_draw_destroyCtxt( DrawCtx* XP_UNUSED(p_dctx) ) // CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; } /* draw_setup */ -static void -drawFocusRect( CursesDrawCtx* dctx, DrawFocusState dfs, const XP_Rect* rect ) -{ - WINDOW* boardWin = dctx->boardWin; - if ( dfs == DFS_NONE ) { - drawRect( boardWin, rect, '|', '-' ); - } else if ( dfs == DFS_TOP ) { - drawRect( boardWin, rect, '*', '*' ); - } else if ( dfs == DFS_DIVED ) { - drawRect( boardWin, rect, '+', '+' ); - } else { - XP_ASSERT(0); - } -} - static XP_Bool -curses_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* XP_UNUSED(dict), - const XP_Rect* rect, DrawFocusState dfs ) +curses_draw_boardBegin( DrawCtx* XP_UNUSED(p_dctx), + const DictionaryCtxt* XP_UNUSED(dict), + const XP_Rect* XP_UNUSED(rect), + DrawFocusState XP_UNUSED(dfs) ) { - CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; - drawFocusRect( dctx, dfs, rect ); return XP_TRUE; } /* draw_finish */ static XP_Bool -curses_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 XP_UNUSED(owner), DrawFocusState dfs ) +curses_draw_trayBegin( DrawCtx* XP_UNUSED(p_dctx), + const XP_Rect* XP_UNUSED(rect), + XP_U16 XP_UNUSED(owner), + DrawFocusState XP_UNUSED(dfs) ) { - CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; - drawFocusRect( dctx, dfs, rect ); return XP_TRUE; } /* draw_finish */ static void curses_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect, - XP_U16 XP_UNUSED(numPlayers), DrawFocusState dfs ) + XP_U16 XP_UNUSED(numPlayers), + DrawFocusState XP_UNUSED(dfs) ) { CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; - drawFocusRect( dctx, dfs, rect ); + eraseRect( dctx, rect ); } /* curses_draw_scoreBegin */ static void @@ -229,29 +216,18 @@ curses_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, mvwprintw( dctx->boardWin, rect->top+1, rect->left, "pt:" ); mvwprintw( dctx->boardWin, rect->top+2, rect->left, "%s", buf ); - wrefresh( dctx->boardWin ); } /* curses_draw_score_pendingScore */ static void -curses_draw_boardFinished( DrawCtx* p_dctx ) +curses_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ, + const XP_Rect* rect, DrawFocusState dfs ) { CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; + if ( dfs == DFS_TOP ) { + cursesHiliteRect( dctx->boardWin, rect ); + } wrefresh( dctx->boardWin ); -} /* curses_draw_boardFinished */ - -static void -curses_draw_trayFinished( DrawCtx* p_dctx ) -{ - CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; - wrefresh( dctx->boardWin ); -} /* draw_finished */ - -static void -curses_draw_scoreFinished( DrawCtx* p_dctx ) -{ - CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; - wrefresh( dctx->boardWin ); -} /* draw_finished */ +} /* curses_draw_objFinished */ #define MY_PAIR 1 @@ -265,9 +241,6 @@ curses_draw_score_drawPlayer( DrawCtx* p_dctx, const XP_Rect* rInner, curses_draw_clearRect( p_dctx, rOuter ); - /* first blank out the whole thing! */ - mvwhline( dctx->boardWin, y, rOuter->left, ' ', rOuter->width ); - /* print the name and turn/remoteness indicator */ formatScoreText( buf, dsi ); mvwprintw( dctx->boardWin, y, rOuter->left, buf ); @@ -482,10 +455,8 @@ cursesDrawCtxtMake( WINDOW* boardWin ) SET_VTABLE_ENTRY( dctx->vtable, draw_destroyCtxt, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, curses ); - SET_VTABLE_ENTRY( dctx->vtable, draw_boardFinished, curses ); + SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, curses ); - SET_VTABLE_ENTRY( dctx->vtable, draw_trayFinished, curses ); - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreBegin, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_measureRemText, curses ); @@ -493,7 +464,6 @@ cursesDrawCtxtMake( WINDOW* boardWin ) SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, curses ); - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreFinished, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, curses ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, curses ); diff --git a/xwords4/linux/cursesmain.c b/xwords4/linux/cursesmain.c index 2e48d06f1..2461b1533 100644 --- a/xwords4/linux/cursesmain.c +++ b/xwords4/linux/cursesmain.c @@ -427,6 +427,7 @@ MenuList sharedMenuList[] = { { NULL, NULL, NULL, '\0'} }; +#ifdef KEYBOARD_NAV static XP_Bool handleLeft( CursesAppGlobals* globals ) { @@ -474,28 +475,33 @@ handleDown( CursesAppGlobals* globals ) XP_CURSOR_KEY_DOWN ); return XP_TRUE; } /* handleDown */ +#endif MenuList boardMenuList[] = { +#ifdef KEYBOARD_NAV { handleLeft, "Left", "H", 'H' }, { handleRight, "Right", "L", 'L' }, { handleUp, "Up", "J", 'J' }, { handleDown, "Down", "K", 'K' }, - +#endif { NULL, NULL, NULL, '\0'} }; MenuList scoreMenuList[] = { +#ifdef KEYBOARD_NAV { handleUp, "Up", "J", 'J' }, { handleDown, "Down", "K", 'K' }, - +#endif { NULL, NULL, NULL, '\0'} }; MenuList trayMenuList[] = { +#ifdef KEYBOARD_NAV { handleLeft, "Left", "H", 'H' }, { handleRight, "Right", "L", 'L' }, { handleDivLeft, "Div left", "{", '{' }, { handleDivRight, "Div right", "}", '}' }, +#endif { handleJuggle, "Juggle", "J", 'J' }, { handleHide, "[un]hIde", "I", 'I' }, @@ -798,6 +804,7 @@ blocking_gotEvent( CursesAppGlobals* globals, int* ch ) static void changeFocus( CursesAppGlobals* globals ) { +#ifdef KEYBOARD_NAV BoardObjectType focussed = board_getFocusOwner( globals->cGlobals.game.board ); if ( focussed == OBJ_TRAY ) { @@ -812,6 +819,7 @@ changeFocus( CursesAppGlobals* globals ) } else { XP_ASSERT(0); } +#endif } /* changeFocus */ #if 0 diff --git a/xwords4/linux/gtkdraw.c b/xwords4/linux/gtkdraw.c index 0ea3e082b..97fb5b0dc 100644 --- a/xwords4/linux/gtkdraw.c +++ b/xwords4/linux/gtkdraw.c @@ -256,7 +256,10 @@ gtk_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* XP_UNUSED(dict), } /* draw_finish */ static void -gtk_draw_boardFinished( DrawCtx* XP_UNUSED(p_dctx) ) +gtk_draw_objFinished( DrawCtx* XP_UNUSED(p_dctx), + BoardObjectType XP_UNUSED(typ), + const XP_Rect* XP_UNUSED(rect), + DrawFocusState XP_UNUSED(dfs) ) { // GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; } /* draw_finished */ @@ -731,13 +734,6 @@ gtk_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, &dctx->black, NULL ); } /* gtk_draw_score_pendingScore */ -static void -gtk_draw_scoreFinished( DrawCtx* XP_UNUSED(p_dctx) ) -{ -/* GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; */ - -} /* gtk_draw_scoreFinished */ - static void gtkFormatTimerText( XP_UCHAR* buf, XP_S16 secondsLeft ) { @@ -931,7 +927,7 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkAppGlobals* globals ) SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_invertCell, gtk ); - SET_VTABLE_ENTRY( dctx->vtable, draw_boardFinished, gtk ); + SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawTile, gtk ); @@ -946,7 +942,6 @@ gtkDrawCtxtMake( GtkWidget* drawing_area, GtkAppGlobals* globals ) SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, gtk ); - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreFinished, gtk ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, gtk ); diff --git a/xwords4/linux/gtkmain.c b/xwords4/linux/gtkmain.c index f5e55b4c0..7d64fb0ab 100644 --- a/xwords4/linux/gtkmain.c +++ b/xwords4/linux/gtkmain.c @@ -231,6 +231,7 @@ static void createOrLoadObjects( GtkAppGlobals* globals ) { XWStreamCtxt* stream = NULL; + XP_Bool opened = XP_FALSE; Connectedness serverRole = globals->cGlobals.params->serverRole; XP_Bool isServer = serverRole != SERVER_ISCLIENT; @@ -243,16 +244,17 @@ createOrLoadObjects( GtkAppGlobals* globals ) stream = streamFromFile( globals, params->fileName ); - game_makeFromStream( MEMPOOL stream, &globals->cGlobals.game, - &globals->cGlobals.params->gi, - params->dict, params->util, - (DrawCtx*)globals->draw, - &globals->cp, - linux_send, globals ); - + opened = game_makeFromStream( MEMPOOL stream, &globals->cGlobals.game, + &globals->cGlobals.params->gi, + params->dict, params->util, + (DrawCtx*)globals->draw, + &globals->cp, + linux_send, globals ); + stream_destroy( stream ); + } - } else { /* not reading from a saved file */ + if ( !opened ) { XP_U16 gameID; CommsAddrRec addr; diff --git a/xwords4/palm/l10n/xwords4_en_US.rcp.pre b/xwords4/palm/l10n/xwords4_en_US.rcp.pre index 610138915..3e30aaa73 100644 --- a/xwords4/palm/l10n/xwords4_en_US.rcp.pre +++ b/xwords4/palm/l10n/xwords4_en_US.rcp.pre @@ -581,7 +581,7 @@ BEGIN LIST "" ID XW_SAVEDGAMES_LIST_ID AT (2 15 140 60) \ USABLE ENABLED VISIBLEITEMS 1 GRAFFITISTATEINDICATOR 2 120 - FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 108 AUTO) + FIELD XW_SAVEDGAMES_NAME_FIELD AT (PREVRIGHT+10 PREVTOP 100 AUTO) EDITABLE SINGLELINE UNDERLINED MAXCHARS MAX_GAMENAME_LENGTH BUTTON "Mod." XW_SAVEDGAMES_USE_BUTTON RIGHT@154 PREVTOP 30 AUTO @@ -590,7 +590,7 @@ BEGIN BUTTON "Delete" XW_SAVEDGAMES_DELETE_BUTTON PREVRIGHT+5 PREVTOP 39 AUTO BUTTON "Open" XW_SAVEDGAMES_OPEN_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO BUTTON "Done" XW_SAVEDGAMES_DONE_BUTTON PREVRIGHT+5 PREVTOP 33 AUTO -END +END /* XW_SAVEDGAMES_DIALOG_ID */ #endif ALERT XW_ERROR_ALERT_ID diff --git a/xwords4/palm/palmdraw.c b/xwords4/palm/palmdraw.c index b20fea9a5..41930c0f6 100644 --- a/xwords4/palm/palmdraw.c +++ b/xwords4/palm/palmdraw.c @@ -53,7 +53,6 @@ static void palm_bnw_draw_score_drawPlayer( DrawCtx* p_dctx, const DrawScoreInfo* dsi ); static XP_Bool palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, XP_U16 owner, DrawFocusState dfs ); -static void palm_bnw_draw_trayFinished( DrawCtx* p_dctx ); static void palm_clr_draw_clearRect( DrawCtx* p_dctx, const XP_Rect* rectP ); static void palm_draw_drawMiniWindow( DrawCtx* p_dctx, const XP_UCHAR* text, const XP_Rect* rect, void** closureP ); @@ -158,33 +157,6 @@ drawFocusRect( PalmDrawCtx* dctx, const XP_Rect* rect ) #else # define drawFocusRect( a, b ) #endif - -static void -dfsDrawIf( PalmDrawCtx* dctx, BoardObjectType obj ) -{ - if ( dctx->topFocusObj == obj ) { - drawFocusRect( dctx, &dctx->topFocusRect ); - dctx->topFocusObj = OBJ_NONE; - } -} - -static void -dfsCopyIf( PalmDrawCtx* dctx, DrawFocusState dfs, - const XP_Rect* rect, BoardObjectType obj ) -{ - XP_LOGF( "%s(%s, %s)", __FUNCTION__, DrawFocusState_2str(dfs), - BoardObjectType_2str(obj) ); - if ( dfs == DFS_TOP ) { - dctx->topFocusObj = obj; - XP_MEMCPY( &dctx->topFocusRect, rect, sizeof(dctx->topFocusRect) ); - } else /* if ( dfs == DFS_DIVED ) */ { - dctx->topFocusObj = OBJ_NONE; - } -} - -#else -# define dfsCopyIf( dctx, dfs, rect, obj ) -# define dfsDrawIf( dctx, obj ) #endif # define BMP_WIDTH 16 @@ -297,8 +269,6 @@ palm_common_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict, checkFontOffsets( dctx, dict ); - dfsCopyIf( dctx, dfs, rect, OBJ_BOARD ); - return XP_TRUE; } /* palm_common_draw_boardBegin */ @@ -323,12 +293,27 @@ palm_clr_draw_boardBegin( DrawCtx* p_dctx, const DictionaryCtxt* dict, } /* palm_clr_draw_boardBegin */ static void -palm_clr_draw_boardFinished( DrawCtx* p_dctx ) +palm_draw_objFinished( DrawCtx* p_dctx, BoardObjectType typ, + const XP_Rect* rect, DrawFocusState dfs ) { - dfsDrawIf( (PalmDrawCtx*)p_dctx, OBJ_BOARD ); + PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; +#ifdef XWFEATURE_FIVEWAY + PalmAppGlobals* globals = dctx->globals; + if ( globals->hasFiveWay && dfs == DFS_TOP ) { + drawFocusRect( dctx, rect ); + } +#endif - WinPopDrawState(); -} /* palm_clr_draw_boardFinished */ + if ( typ == OBJ_BOARD ) { + WinPopDrawState(); + } else if ( typ == OBJ_TRAY ) { + WinSetClip( &dctx->oldTrayClip ); + WinPopDrawState(); + } else if ( typ == OBJ_SCORE ) { + WinSetClip( &dctx->oldScoreClip ); + HIGHRES_POP(dctx); + } +} /* palm_draw_objFinished */ static XP_Bool palm_clr_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect, @@ -609,28 +594,11 @@ palm_bnw_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* rect, { PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - dfsCopyIf( dctx, dfs, rect, OBJ_TRAY ); - WinGetClip( &dctx->oldTrayClip ); WinSetClip( (RectangleType*)rect ); return XP_TRUE; } /* palm_bnw_draw_trayBegin */ -static void -palm_clr_draw_trayFinished( DrawCtx* p_dctx ) -{ - palm_bnw_draw_trayFinished( p_dctx ); - WinPopDrawState(); -} /* palm_clr_draw_trayFinished */ - -static void -palm_bnw_draw_trayFinished( DrawCtx* p_dctx ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - dfsDrawIf( dctx, OBJ_TRAY ); - WinSetClip( &dctx->oldTrayClip ); -} /* palm_draw_trayFinished */ - static void smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y ) { @@ -827,8 +795,6 @@ palm_draw_scoreBegin( DrawCtx* p_dctx, const XP_Rect* rect, { PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - dfsCopyIf( dctx, dfs, rect, OBJ_SCORE ); - HIGHRES_PUSH( dctx ); WinGetClip( &dctx->oldScoreClip ); @@ -1156,16 +1122,6 @@ palm_draw_score_pendingScore( DrawCtx* p_dctx, const XP_Rect* rect, HIGHRES_POP_LOC(dctx); } /* palm_draw_score_pendingScore */ -static void -palm_draw_scoreFinished( DrawCtx* p_dctx ) -{ - PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; - dfsDrawIf( dctx, OBJ_SCORE ); - WinSetClip( &dctx->oldScoreClip ); - - HIGHRES_POP(dctx); -} /* palm_draw_scoreFinished */ - static void palmFormatTimerText( XP_UCHAR* buf, XP_S16 secondsLeft ) { @@ -1484,7 +1440,7 @@ palm_drawctxt_make( MPFORMAL GraphicsAbility able, SET_VTABLE_ENTRY( dctx->vtable, draw_drawRemText, palm ); SET_VTABLE_ENTRY( dctx->vtable, draw_measureScoreText, palm ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_pendingScore, palm ); - SET_VTABLE_ENTRY( dctx->vtable, draw_scoreFinished, palm ); + SET_VTABLE_ENTRY( dctx->vtable, draw_objFinished, palm ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawTimer, palm ); @@ -1500,11 +1456,9 @@ palm_drawctxt_make( MPFORMAL GraphicsAbility able, if ( able == COLOR ) { #ifdef COLOR_SUPPORT SET_VTABLE_ENTRY( dctx->vtable, draw_boardBegin, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_boardFinished, palm_clr ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_clr ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_clr ); SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_clr ); - SET_VTABLE_ENTRY( dctx->vtable, draw_trayFinished, palm_clr ); SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_clr ); SET_VTABLE_ENTRY( dctx->vtable, draw_drawMiniWindow, palm_clr ); @@ -1517,7 +1471,6 @@ palm_drawctxt_make( MPFORMAL GraphicsAbility able, SET_VTABLE_ENTRY( dctx->vtable, draw_drawCell, palm_common ); SET_VTABLE_ENTRY( dctx->vtable, draw_score_drawPlayer, palm_bnw ); SET_VTABLE_ENTRY( dctx->vtable, draw_trayBegin, palm_bnw ); - SET_VTABLE_ENTRY( dctx->vtable, draw_trayFinished, palm_bnw ); SET_VTABLE_ENTRY( dctx->vtable, draw_clearRect, palm_bnw ); } diff --git a/xwords4/palm/palmmain.c b/xwords4/palm/palmmain.c index 3b12b88ec..03a3434b2 100644 --- a/xwords4/palm/palmmain.c +++ b/xwords4/palm/palmmain.c @@ -59,6 +59,11 @@ #include "dictui.h" #include "LocalizedStrIncludes.h" +#ifdef XWFEATURE_FIVEWAY +# include +/* # include */ +#endif + #include "callback.h" #include "pace_man.h" /* for crash() macro */ @@ -560,9 +565,10 @@ loadCurrentGame( PalmAppGlobals* globals, XP_U16 gIndex, } if ( success ) { - game_makeFromStream( MEMPOOL recStream, game, ginfo, dict, - &globals->util, globals->draw, - &globals->gState.cp, palm_send, globals ); + success = game_makeFromStream( MEMPOOL recStream, game, ginfo, + dict, &globals->util, + globals->draw, &globals->gState.cp, + palm_send, globals ); } stream_destroy( recStream ); @@ -910,7 +916,10 @@ initHighResGlobals( PalmAppGlobals* globals ) globals->hasHiRes = ( err == errNone && vers >= 4 ); globals->oneDotFiveAvail = ( err == errNone && vers >= 5 ); + err = FtrGet( sysFtrCreator, sysFtrNumUIHardwareFlags, &vers ); XP_LOGF( "hasHiRes = %d", globals->hasHiRes ); + globals->hasFiveWay = ( (err == errNone) + && ((vers & sysFtrNumUIHardwareHas5Way) != 0) ); #ifdef FEATURE_SILK if ( globals->hasHiRes ) { @@ -2030,6 +2039,7 @@ handleChangeFocus( PalmAppGlobals* globals, const EventType* event, XP_Bool* drawP ) { XP_Bool handled = XP_FALSE; + XP_Bool redraw = XP_FALSE; XP_U16 objectID = event->data.frmObjectFocusTake.objectID; XP_ASSERT( &event->data.frmObjectFocusTake.objectID == &event->data.frmObjectFocusLost.objectID ); @@ -2037,9 +2047,20 @@ handleChangeFocus( PalmAppGlobals* globals, const EventType* event, /* XP_LOGF( "%s(%d,%s)", __FUNCTION__, objectID, */ /* (event->eType == frmObjectFocusTakeEvent? "take":"lost") ); */ - handled = ( objectID == XW_BOARD_GADGET_ID - || objectID == XW_SCOREBOARD_GADGET_ID - || objectID == XW_TRAY_GADGET_ID ); + switch ( objectID ) { + case XW_BOARD_GADGET_ID: + case XW_SCOREBOARD_GADGET_ID: + case XW_TRAY_GADGET_ID: + handled = XP_TRUE; + break; + + case XW_MAIN_DONE_BUTTON_ID: + case XW_MAIN_JUGGLE_BUTTON_ID: + case XW_MAIN_TRADE_BUTTON_ID: + case XW_MAIN_HIDE_BUTTON_ID: + redraw = XP_TRUE; + break; + } if ( handled ) { XP_Bool take = event->eType == frmObjectFocusTakeEvent; @@ -2050,6 +2071,10 @@ handleChangeFocus( PalmAppGlobals* globals, const EventType* event, FrmGetObjectIndex( globals->mainForm, objectID ) ); } } + if ( redraw ) { + drawBitmapButton( globals, XW_MAIN_HIDE_BUTTON_ID, + TRAY_BUTTONS_BMP_RES_ID, XP_FALSE ); + } return handled; } /* handleChangeFocus */ @@ -2057,11 +2082,13 @@ handleChangeFocus( PalmAppGlobals* globals, const EventType* event, static void checkSetFocus( PalmAppGlobals* globals ) { - BoardObjectType typ = board_getFocusOwner( globals->game.board ); - XP_U16 objectID = XW_BOARD_GADGET_ID + (typ - OBJ_BOARD); - XP_LOGF( "%s: FrmSetFocus(%d)", __FUNCTION__, objectID ); - FrmSetFocus( globals->mainForm, - FrmGetObjectIndex( globals->mainForm, objectID ) ); + if ( globals->hasFiveWay ) { + BoardObjectType typ = board_getFocusOwner( globals->game.board ); + XP_U16 objectID = XW_BOARD_GADGET_ID + (typ - OBJ_BOARD); + XP_LOGF( "%s: FrmSetFocus(%d)", __FUNCTION__, objectID ); + FrmSetFocus( globals->mainForm, + FrmGetObjectIndex( globals->mainForm, objectID ) ); + } } #endif @@ -2484,7 +2511,8 @@ mainViewHandleEvent( EventPtr event ) #ifdef XWFEATURE_FIVEWAY case frmObjectFocusTakeEvent: case frmObjectFocusLostEvent: - handled = handleChangeFocus( globals, event, &draw ); + handled = globals->hasFiveWay + && handleChangeFocus( globals, event, &draw ); break; #endif diff --git a/xwords4/palm/palmmain.h b/xwords4/palm/palmmain.h index 9d7d9315c..bb0fd30bc 100644 --- a/xwords4/palm/palmmain.h +++ b/xwords4/palm/palmmain.h @@ -89,11 +89,6 @@ typedef struct PalmDrawCtx { XP_LangCode fontLangCode; PalmFontHtInfo* fontHtInfo; -#ifdef XWFEATURE_FIVEWAY - BoardObjectType topFocusObj; - XP_Rect topFocusRect; -#endif - union { struct { XP_U8 reserved; /* make CW compiler happy */ @@ -299,6 +294,7 @@ struct PalmAppGlobals { XP_Bool hasHiRes; XP_Bool oneDotFiveAvail; XP_Bool useHiRes; + XP_Bool hasFiveWay; #ifdef XWFEATURE_SEARCHLIMIT XP_Bool askTrayLimits; diff --git a/xwords4/palm/xwords4defines.h b/xwords4/palm/xwords4defines.h index 00aec5b2f..4cec8a1d5 100644 --- a/xwords4/palm/xwords4defines.h +++ b/xwords4/palm/xwords4defines.h @@ -422,7 +422,7 @@ #define kFrmNavHeaderFlagsAppFocusStartState 0x00000002 /* versioning stuff */ -#define XW_PALM_VERSION_STRING "4.2a2" +#define XW_PALM_VERSION_STRING "4.2a3" #define CUR_PREFS_VERS 0x0405