Since there's now a flag indicating whether to show the value of a

tile, make value unsigned.  Adjust/fix platforms.  Add cmdline flag to
linux apps for hiding values.
This commit is contained in:
ehouse 2008-12-29 03:09:35 +00:00
parent fa4adbfcea
commit 227a58d115
9 changed files with 59 additions and 43 deletions

View file

@ -171,13 +171,13 @@ typedef struct DrawCtxVTable {
/* at least 1 of these two will be null*/ /* at least 1 of these two will be null*/
const XP_UCHAR* text, const XP_UCHAR* text,
const XP_Bitmap bitmap, const XP_Bitmap bitmap,
XP_S16 val, CellFlags flags ); XP_U16 val, CellFlags flags );
#ifdef POINTER_SUPPORT #ifdef POINTER_SUPPORT
void DRAW_VTABLE_NAME(drawTileMidDrag) ( DrawCtx* dctx, const XP_Rect* rect, void DRAW_VTABLE_NAME(drawTileMidDrag) ( DrawCtx* dctx, const XP_Rect* rect,
/* at least 1 of these two will be null*/ /* at least 1 of these two will be null*/
const XP_UCHAR* text, const XP_UCHAR* text,
const XP_Bitmap bitmap, const XP_Bitmap bitmap,
XP_S16 val, XP_U16 owner, XP_U16 val, XP_U16 owner,
CellFlags flags ); CellFlags flags );
#endif #endif
void DRAW_VTABLE_NAME(drawTileBack) ( DrawCtx* dctx, const XP_Rect* rect, void DRAW_VTABLE_NAME(drawTileBack) ( DrawCtx* dctx, const XP_Rect* rect,

View file

@ -392,7 +392,7 @@ curses_stringInTile( CursesDrawCtx* dctx, const XP_Rect* rect,
static void static void
curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, XP_Bitmap XP_UNUSED(bitmap), const XP_UCHAR* textP, XP_Bitmap XP_UNUSED(bitmap),
XP_S16 val, CellFlags flags ) XP_U16 val, CellFlags flags )
{ {
char numbuf[5]; char numbuf[5];
char letterbuf[5]; char letterbuf[5];
@ -403,7 +403,7 @@ curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
if ( (flags&CELL_ISEMPTY) == 0 ) { if ( (flags&CELL_ISEMPTY) == 0 ) {
letterbuf[0] = !!textP? *textP: '_'; /* BLANK or bitmap */ letterbuf[0] = !!textP? *textP: '_'; /* BLANK or bitmap */
letterbuf[1] = '\0'; letterbuf[1] = '\0';
if ( val >= 0 ) { if ( (flags&CELL_VALHIDDEN) == 0 ) {
sprintf( numbuf, "%.2d", val ); sprintf( numbuf, "%.2d", val );
if ( numbuf[0] == '0' ) { if ( numbuf[0] == '0' ) {
numbuf[0] = ' '; numbuf[0] = ' ';

View file

@ -1349,6 +1349,7 @@ cursesmain( XP_Bool isServer, LaunchParams* params )
g_globals.cp.showBoardArrow = XP_TRUE; g_globals.cp.showBoardArrow = XP_TRUE;
g_globals.cp.showRobotScores = params->showRobotScores; g_globals.cp.showRobotScores = params->showRobotScores;
g_globals.cp.hideTileValues = params->hideValues;
dict = params->dict; dict = params->dict;

View file

@ -534,7 +534,7 @@ gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
static void static void
gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP, gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
XP_Bitmap bitmap, XP_S16 val, CellFlags flags, XP_Bitmap bitmap, XP_U16 val, CellFlags flags,
XP_Bool clearBack ) XP_Bool clearBack )
{ {
XP_UCHAR numbuf[3]; XP_UCHAR numbuf[3];
@ -542,25 +542,28 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx; GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Rect insetR = *rect; XP_Rect insetR = *rect;
XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0; XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0;
XP_Bool valHidden = (flags & CELL_VALHIDDEN) != 0;
XP_Bool notEmpty = (flags & CELL_ISEMPTY) == 0;
if ( clearBack ) { if ( clearBack ) {
gtkEraseRect( dctx, &insetR ); gtkEraseRect( dctx, &insetR );
} }
if ( isCursor || (val >= 0) ) { if ( isCursor || notEmpty ) {
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner]; GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
XP_Rect formatRect = insetR; XP_Rect formatRect = insetR;
gtkInsetRect( &insetR, 1 ); gtkInsetRect( &insetR, 1 );
if ( clearBack ) { if ( clearBack ) {
gtkFillRect( dctx, &insetR, isCursor? &dctx->cursor:&dctx->tileBack ); gtkFillRect( dctx, &insetR,
isCursor ? &dctx->cursor : &dctx->tileBack );
} }
if ( val >= 0 ) {
formatRect.left += 3; formatRect.left += 3;
formatRect.width -= 6; formatRect.width -= 6;
if ( notEmpty ) {
if ( !!textP ) { if ( !!textP ) {
if ( *textP != LETTER_NONE ) { /* blank */ if ( *textP != LETTER_NONE ) { /* blank */
draw_string_at( dctx, NULL, textP, formatRect.height>>1, draw_string_at( dctx, NULL, textP, formatRect.height>>1,
@ -572,12 +575,15 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
drawBitmapFromLBS( dctx, bitmap, &insetR ); drawBitmapFromLBS( dctx, bitmap, &insetR );
} }
if ( !valHidden ) {
sprintf( numbuf, "%d", val ); sprintf( numbuf, "%d", val );
len = strlen( numbuf ); len = strlen( numbuf );
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2, draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
&formatRect, XP_GTK_JUST_BOTTOMRIGHT, &formatRect, XP_GTK_JUST_BOTTOMRIGHT,
foreground, NULL ); foreground, NULL );
}
}
/* frame the tile */ /* frame the tile */
gdk_gc_set_foreground( dctx->drawGC, &dctx->black ); gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
@ -595,12 +601,11 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
insetR.width, insetR.height); insetR.width, insetR.height);
} }
} }
}
} /* gtkDrawTileImpl */ } /* gtkDrawTileImpl */
static void static void
gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP, gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
XP_Bitmap bitmap, XP_S16 val, CellFlags flags ) XP_Bitmap bitmap, XP_U16 val, CellFlags flags )
{ {
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, flags, XP_TRUE ); gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, flags, XP_TRUE );
} }
@ -609,7 +614,7 @@ gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
static void static void
gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect, gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, XP_Bitmap bitmap, const XP_UCHAR* textP, XP_Bitmap bitmap,
XP_S16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); gtk_draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val, gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val,

View file

@ -1844,6 +1844,7 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
#endif #endif
globals.cp.showBoardArrow = XP_TRUE; globals.cp.showBoardArrow = XP_TRUE;
globals.cp.hideTileValues = params->hideValues;
globals.cp.showRobotScores = params->showRobotScores; globals.cp.showRobotScores = params->showRobotScores;
setupGtkUtilCallbacks( &globals, params->util ); setupGtkUtilCallbacks( &globals, params->util );

View file

@ -195,6 +195,7 @@ usage( char* appName, char* msg )
"\t [-n name]* # same-process player (no network used)\n" "\t [-n name]* # same-process player (no network used)\n"
"\t [-w pwd]* # passwd for matching local player\n" "\t [-w pwd]* # passwd for matching local player\n"
"\t [-v] # put scoreboard in vertical mode\n" "\t [-v] # put scoreboard in vertical mode\n"
"\t [-V] # hide values in tray\n"
"\t [-m] # make the robot duMb (smart is default)\n" "\t [-m] # make the robot duMb (smart is default)\n"
"\t [-l] # disallow hints\n" "\t [-l] # disallow hints\n"
"\t [-c] # explain robot scores after each move\n" "\t [-c] # explain robot scores after each move\n"
@ -725,7 +726,7 @@ main( int argc, char** argv )
#if defined PLATFORM_GTK #if defined PLATFORM_GTK
"h:I" "h:I"
#endif #endif
"kKf:ln:Nsd:e:r:b:q:w:Sit:Umvc" "kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcV"
#ifdef XWFEATURE_SMS #ifdef XWFEATURE_SMS
"M:" "M:"
#endif #endif
@ -864,6 +865,9 @@ main( int argc, char** argv )
btaddr = optarg; btaddr = optarg;
break; break;
#endif #endif
case 'V':
mainParams.hideValues = XP_TRUE;
break;
case 'v': case 'v':
mainParams.verticalScore = XP_TRUE; mainParams.verticalScore = XP_TRUE;
break; break;

View file

@ -57,6 +57,7 @@ typedef struct LaunchParams {
XP_Bool printHistory; XP_Bool printHistory;
XP_Bool undoWhenDone; XP_Bool undoWhenDone;
XP_Bool verticalScore; XP_Bool verticalScore;
XP_Bool hideValues;
// XP_Bool mainParams; // XP_Bool mainParams;
XP_Bool skipWarnings; XP_Bool skipWarnings;
XP_Bool showRobotScores; XP_Bool showRobotScores;

View file

@ -677,7 +677,7 @@ smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y )
static void static void
palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, XP_Bitmap bitmap,
XP_S16 val, CellFlags flags ) XP_U16 val, CellFlags flags )
{ {
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx; PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
char valBuf[3]; char valBuf[3];
@ -716,7 +716,7 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
/* Draw the number before the letter. Some PalmOS version don't /* Draw the number before the letter. Some PalmOS version don't
honor the winOverlay flag and erase. Better to erase the value honor the winOverlay flag and erase. Better to erase the value
than the letter. */ than the letter. */
if ( val >= 0 ) { if ( (flags & CELL_VALHIDDEN) == 0 ) {
(void)StrPrintF( valBuf, "%d", val ); (void)StrPrintF( valBuf, "%d", val );
len = XP_STRLEN((const char*)valBuf); len = XP_STRLEN((const char*)valBuf);
@ -769,7 +769,7 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
static void static void
palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect, palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap, const XP_UCHAR* letters, XP_Bitmap bitmap,
XP_S16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
/* let trayBegin code take care of pushing color env changes. */ /* let trayBegin code take care of pushing color env changes. */
draw_trayBegin( p_dctx, rect, owner, DFS_NONE ); draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
@ -781,8 +781,8 @@ palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
static void static void
palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags ) palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags )
{ {
palm_draw_drawTile( p_dctx, rect, (unsigned char*)"?", (XP_Bitmap)NULL, palm_draw_drawTile( p_dctx, rect, "?", (XP_Bitmap)NULL,
-1, flags & CELL_ISCURSOR ); 0, (flags & CELL_ISCURSOR) | CELL_VALHIDDEN );
} /* palm_draw_drawTileBack */ } /* palm_draw_drawTileBack */
static void static void

View file

@ -59,6 +59,7 @@ typedef enum { NO_FOCUS, SINGLE_FOCUS, TOP_FOCUS } CeFocusLevel;
typedef enum { typedef enum {
RFONTS_TRAY RFONTS_TRAY
,RFONTS_TRAYNOVAL
,RFONTS_TRAYVAL ,RFONTS_TRAYVAL
,RFONTS_CELL ,RFONTS_CELL
,RFONTS_REM ,RFONTS_REM
@ -127,6 +128,7 @@ RFI2Str( RFIndex rfi )
# define CASE_STR(c) case c: str = #c; break # define CASE_STR(c) case c: str = #c; break
switch( rfi ) { switch( rfi ) {
CASE_STR( RFONTS_TRAY ); CASE_STR( RFONTS_TRAY );
CASE_STR( RFONTS_TRAYNOVAL );
CASE_STR( RFONTS_TRAYVAL ); CASE_STR( RFONTS_TRAYVAL );
CASE_STR( RFONTS_CELL ); CASE_STR( RFONTS_CELL );
CASE_STR( RFONTS_REM ); CASE_STR( RFONTS_REM );
@ -277,6 +279,7 @@ makeTestBuf( CEDrawCtx* dctx, XP_UCHAR* buf, XP_U16 bufLen, RFIndex index )
{ {
switch( index ) { switch( index ) {
case RFONTS_TRAY: case RFONTS_TRAY:
case RFONTS_TRAYNOVAL:
case RFONTS_CELL: { case RFONTS_CELL: {
Tile tile; Tile tile;
Tile blank = (Tile)-1; Tile blank = (Tile)-1;
@ -948,7 +951,7 @@ DRAW_FUNC_NAME(trayBegin)( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
static void static void
drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect, drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
const XP_UCHAR* letters, XP_S16 val, CellFlags flags ) const XP_UCHAR* letters, XP_U16 val, CellFlags flags )
{ {
CEDrawCtx* dctx = (CEDrawCtx*)p_dctx; CEDrawCtx* dctx = (CEDrawCtx*)p_dctx;
CEAppGlobals* globals = dctx->globals; CEAppGlobals* globals = dctx->globals;
@ -1013,7 +1016,8 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
} }
if ( !!letters ) { if ( !!letters ) {
fce = ceGetSizedFont( dctx, charHt, 0, RFONTS_TRAY ); fce = ceGetSizedFont( dctx, charHt, 0,
valHidden ? RFONTS_TRAYNOVAL:RFONTS_TRAY );
HFONT oldFont = SelectObject( hdc, fce->setFont ); HFONT oldFont = SelectObject( hdc, fce->setFont );
MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1, MultiByteToWideChar( CP_ACP, MB_PRECOMPOSED, letters, -1,
widebuf, VSIZE(widebuf) ); widebuf, VSIZE(widebuf) );
@ -1025,7 +1029,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
SelectObject( hdc, oldFont ); SelectObject( hdc, oldFont );
} }
if ( val >= 0 && !valHidden ) { if ( !valHidden ) {
fce = ceGetSizedFont( dctx, valHt, 0, RFONTS_TRAYVAL ); fce = ceGetSizedFont( dctx, valHt, 0, RFONTS_TRAYVAL );
HFONT oldFont = SelectObject( hdc, fce->setFont ); HFONT oldFont = SelectObject( hdc, fce->setFont );
swprintf( widebuf, L"%d", val ); swprintf( widebuf, L"%d", val );
@ -1043,7 +1047,7 @@ drawDrawTileGuts( DrawCtx* p_dctx, const XP_Rect* xprect,
DLSTATIC void DLSTATIC void
DRAW_FUNC_NAME(drawTile)( DrawCtx* p_dctx, const XP_Rect* xprect, DRAW_FUNC_NAME(drawTile)( DrawCtx* p_dctx, const XP_Rect* xprect,
const XP_UCHAR* letters, XP_Bitmap XP_UNUSED(bitmap), const XP_UCHAR* letters, XP_Bitmap XP_UNUSED(bitmap),
XP_S16 val, CellFlags flags ) XP_U16 val, CellFlags flags )
{ {
drawDrawTileGuts( p_dctx, xprect, letters, val, flags ); drawDrawTileGuts( p_dctx, xprect, letters, val, flags );
} /* ce_draw_drawTile */ } /* ce_draw_drawTile */
@ -1053,7 +1057,7 @@ DLSTATIC void
DRAW_FUNC_NAME(drawTileMidDrag)( DrawCtx* p_dctx, const XP_Rect* xprect, DRAW_FUNC_NAME(drawTileMidDrag)( DrawCtx* p_dctx, const XP_Rect* xprect,
const XP_UCHAR* letters, const XP_UCHAR* letters,
XP_Bitmap XP_UNUSED(bitmap), XP_Bitmap XP_UNUSED(bitmap),
XP_S16 val, XP_U16 owner, CellFlags flags ) XP_U16 val, XP_U16 owner, CellFlags flags )
{ {
draw_trayBegin( p_dctx, xprect, owner, DFS_NONE ); draw_trayBegin( p_dctx, xprect, owner, DFS_NONE );
drawDrawTileGuts( p_dctx, xprect, letters, val, flags ); drawDrawTileGuts( p_dctx, xprect, letters, val, flags );
@ -1064,7 +1068,7 @@ DLSTATIC void
DRAW_FUNC_NAME(drawTileBack)( DrawCtx* p_dctx, const XP_Rect* xprect, DRAW_FUNC_NAME(drawTileBack)( DrawCtx* p_dctx, const XP_Rect* xprect,
CellFlags flags ) CellFlags flags )
{ {
drawDrawTileGuts( p_dctx, xprect, "?", -1, flags ); drawDrawTileGuts( p_dctx, xprect, "?", 0, flags | CELL_VALHIDDEN );
} /* ce_draw_drawTileBack */ } /* ce_draw_drawTileBack */
DLSTATIC void DLSTATIC void