Fix so compiles curses-only, and so curses cell can be 2x1 (for square board)

This commit is contained in:
ehouse 2007-06-01 02:08:04 +00:00
parent f12bf79101
commit edfdda6fd2
5 changed files with 25 additions and 18 deletions

View file

@ -509,7 +509,7 @@ invalSelTradeWindow( BoardCtxt* board )
board->trayVisState == TRAY_REVEALED ); board->trayVisState == TRAY_REVEALED );
} /* invalSelTradeWindow */ } /* invalSelTradeWindow */
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
static void static void
hideMiniWindow( BoardCtxt* board, XP_Bool destroy, MiniWindowType winType ) hideMiniWindow( BoardCtxt* board, XP_Bool destroy, MiniWindowType winType )
{ {
@ -1910,7 +1910,7 @@ invalCell( BoardCtxt* board, XP_U16 col, XP_U16 row )
board->needsDrawing = XP_TRUE; board->needsDrawing = XP_TRUE;
} /* invalCell */ } /* invalCell */
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
static XP_Bool static XP_Bool
pointOnSomething( BoardCtxt* board, XP_U16 x, XP_U16 y, BoardObjectType* wp ) pointOnSomething( BoardCtxt* board, XP_U16 x, XP_U16 y, BoardObjectType* wp )
{ {
@ -1928,9 +1928,7 @@ pointOnSomething( BoardCtxt* board, XP_U16 x, XP_U16 y, BoardObjectType* wp )
return result; return result;
} /* pointOnSomething */ } /* pointOnSomething */
#endif
#if defined POINTER_SUPPORT || defined KEYBOARD_NAV
/* Move the given tile to the board. If it's a blank, we need to ask the user /* Move the given tile to the board. If it's a blank, we need to ask the user
* what to call it first. * what to call it first.
*/ */
@ -2007,7 +2005,7 @@ board_beginTrade( BoardCtxt* board )
return result; return result;
} /* board_beginTrade */ } /* board_beginTrade */
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
static XP_Bool static XP_Bool
ptOnTradeWindow( BoardCtxt* board, XP_U16 x, XP_U16 y ) ptOnTradeWindow( BoardCtxt* board, XP_U16 x, XP_U16 y )
{ {
@ -2542,7 +2540,7 @@ exitTradeMode( BoardCtxt* board )
return XP_TRUE; return XP_TRUE;
} /* exitTradeMode */ } /* exitTradeMode */
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
XP_Bool XP_Bool
board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y ) board_handlePenUp( BoardCtxt* board, XP_U16 x, XP_U16 y )
{ {
@ -2835,7 +2833,9 @@ board_handleKey( BoardCtxt* board, XP_Key key, XP_Bool* handled )
draw = board_handleKeyDown( board, key, &handled1 ); draw = board_handleKeyDown( board, key, &handled1 );
draw = board_handleKeyUp( board, key, &handled2 ) || draw; draw = board_handleKeyUp( board, key, &handled2 ) || draw;
*handled = handled1 || handled2; if ( !!handled ) {
*handled = handled1 || handled2;
}
return draw; return draw;
} /* board_handleKey */ } /* board_handleKey */

View file

@ -256,7 +256,7 @@ figureScorePlayerTapped( BoardCtxt* board, XP_U16 x, XP_U16 y )
/* If the pen also went down on the scoreboard, make the selected player the /* If the pen also went down on the scoreboard, make the selected player the
* one closest to the mouse up loc. * one closest to the mouse up loc.
*/ */
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
XP_Bool XP_Bool
handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y ) handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y )
{ {

View file

@ -26,7 +26,7 @@ void drawScoreBoard( BoardCtxt* board );
XP_S16 figureScorePlayerTapped( BoardCtxt* board, XP_U16 x, XP_U16 y ); XP_S16 figureScorePlayerTapped( BoardCtxt* board, XP_U16 x, XP_U16 y );
void drawTimer( BoardCtxt* board ); void drawTimer( BoardCtxt* board );
#ifdef POINTER_SUPPORT #if defined POINTER_SUPPORT || defined KEYBOARD_NAV
XP_Bool handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y ); XP_Bool handlePenUpScore( BoardCtxt* board, XP_U16 x, XP_U16 y );
#endif #endif

View file

@ -257,11 +257,13 @@ curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
CellFlags flags ) CellFlags flags )
{ {
CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx; CursesDrawCtx* dctx = (CursesDrawCtx*)p_dctx;
XP_UCHAR loc[4]; XP_UCHAR loc[4] = { ' ', ' ', ' ', '\0' };
XP_ASSERT( XP_STRLEN(letter) < sizeof(loc) ); XP_ASSERT( XP_STRLEN(letter) < sizeof(loc) );
XP_STRNCPY( loc, letter, sizeof(loc) ); XP_ASSERT( rect->width < sizeof(loc) );
XP_ASSERT( rect->height == 1 );
XP_MEMCPY( loc, letter, strlen(letter) );
if ( loc[0] == LETTER_NONE ) { if ( letter[0] == LETTER_NONE ) {
switch ( bonus ) { switch ( bonus ) {
case BONUS_DOUBLE_LETTER: case BONUS_DOUBLE_LETTER:
loc[0] = '+'; break; loc[0] = '+'; break;
@ -280,8 +282,8 @@ curses_draw_drawCell( DrawCtx* p_dctx, const XP_Rect* rect,
wstandout( dctx->boardWin ); wstandout( dctx->boardWin );
} }
mvwaddnstr( dctx->boardWin, rect->top, rect->left, loc, mvwaddnstr( dctx->boardWin, rect->top, rect->left,
strlen(loc) ); loc, rect->width );
if ( (flags&CELL_HIGHLIGHT) != 0 ) { if ( (flags&CELL_HIGHLIGHT) != 0 ) {
wstandend( dctx->boardWin ); wstandend( dctx->boardWin );

View file

@ -1008,6 +1008,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
int piperesult; int piperesult;
DictionaryCtxt* dict; DictionaryCtxt* dict;
XP_U16 gameID; XP_U16 gameID;
XP_U16 colWidth, scoreLeft;
memset( &globals, 0, sizeof(globals) ); memset( &globals, 0, sizeof(globals) );
@ -1078,11 +1079,15 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
model_setDictionary( globals.cGlobals.game.model, params->dict ); model_setDictionary( globals.cGlobals.game.model, params->dict );
board_setPos( globals.cGlobals.game.board, 1, 1, XP_FALSE ); board_setPos( globals.cGlobals.game.board, 1, 1, XP_FALSE );
board_setScale( globals.cGlobals.game.board, 1, 1 ); colWidth = 2;
board_setScoreboardLoc( globals.cGlobals.game.board, 20, 1, 50, board_setScale( globals.cGlobals.game.board, colWidth, 1 );
5, /*4 players + rem*/ XP_FALSE ); scoreLeft = (colWidth * MAX_COLS) + 3;
board_setScoreboardLoc( globals.cGlobals.game.board,
scoreLeft, 1,
45, 5, /*4 players + rem*/ XP_FALSE );
board_setTrayLoc( globals.cGlobals.game.board, 25, 8, (3*MAX_TRAY_TILES)+1, board_setTrayLoc( globals.cGlobals.game.board,
scoreLeft, 8, (3*MAX_TRAY_TILES)+1,
4, 1 ); 4, 1 );
/* no divider -- yet */ /* no divider -- yet */
/* board_setTrayVisible( globals.board, XP_TRUE, XP_FALSE ); */ /* board_setTrayVisible( globals.board, XP_TRUE, XP_FALSE ); */