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*/
const XP_UCHAR* text,
const XP_Bitmap bitmap,
XP_S16 val, CellFlags flags );
XP_U16 val, CellFlags flags );
#ifdef POINTER_SUPPORT
void DRAW_VTABLE_NAME(drawTileMidDrag) ( DrawCtx* dctx, const XP_Rect* rect,
/* at least 1 of these two will be null*/
const XP_UCHAR* text,
const XP_Bitmap bitmap,
XP_S16 val, XP_U16 owner,
XP_U16 val, XP_U16 owner,
CellFlags flags );
#endif
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
curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* textP, XP_Bitmap XP_UNUSED(bitmap),
XP_S16 val, CellFlags flags )
XP_U16 val, CellFlags flags )
{
char numbuf[5];
char letterbuf[5];
@ -403,7 +403,7 @@ curses_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
if ( (flags&CELL_ISEMPTY) == 0 ) {
letterbuf[0] = !!textP? *textP: '_'; /* BLANK or bitmap */
letterbuf[1] = '\0';
if ( val >= 0 ) {
if ( (flags&CELL_VALHIDDEN) == 0 ) {
sprintf( numbuf, "%.2d", val );
if ( numbuf[0] == '0' ) {
numbuf[0] = ' ';

View file

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

View file

@ -534,7 +534,7 @@ gtk_draw_trayBegin( DrawCtx* p_dctx, const XP_Rect* XP_UNUSED(rect),
static void
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_UCHAR numbuf[3];
@ -542,25 +542,28 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
GtkDrawCtx* dctx = (GtkDrawCtx*)p_dctx;
XP_Rect insetR = *rect;
XP_Bool isCursor = (flags & CELL_ISCURSOR) != 0;
XP_Bool valHidden = (flags & CELL_VALHIDDEN) != 0;
XP_Bool notEmpty = (flags & CELL_ISEMPTY) == 0;
if ( clearBack ) {
gtkEraseRect( dctx, &insetR );
}
if ( isCursor || (val >= 0) ) {
if ( isCursor || notEmpty ) {
GdkColor* foreground = &dctx->playerColors[dctx->trayOwner];
XP_Rect formatRect = insetR;
gtkInsetRect( &insetR, 1 );
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.width -= 6;
formatRect.left += 3;
formatRect.width -= 6;
if ( notEmpty ) {
if ( !!textP ) {
if ( *textP != LETTER_NONE ) { /* blank */
draw_string_at( dctx, NULL, textP, formatRect.height>>1,
@ -572,35 +575,37 @@ gtkDrawTileImpl( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
drawBitmapFromLBS( dctx, bitmap, &insetR );
}
sprintf( numbuf, "%d", val );
len = strlen( numbuf );
if ( !valHidden ) {
sprintf( numbuf, "%d", val );
len = strlen( numbuf );
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
&formatRect, XP_GTK_JUST_BOTTOMRIGHT,
foreground, NULL );
/* frame the tile */
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
draw_string_at( dctx, NULL, numbuf, formatRect.height>>2,
&formatRect, XP_GTK_JUST_BOTTOMRIGHT,
foreground, NULL );
}
}
/* frame the tile */
gdk_gc_set_foreground( dctx->drawGC, &dctx->black );
gdk_draw_rectangle( DRAW_WHAT(dctx),
dctx->drawGC,
FALSE,
insetR.left, insetR.top, insetR.width,
insetR.height );
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
gtkInsetRect( &insetR, 1 );
gdk_draw_rectangle( DRAW_WHAT(dctx),
dctx->drawGC,
FALSE,
insetR.left, insetR.top, insetR.width,
insetR.height );
if ( (flags & CELL_HIGHLIGHT) != 0 ) {
gtkInsetRect( &insetR, 1 );
gdk_draw_rectangle( DRAW_WHAT(dctx),
dctx->drawGC,
FALSE, insetR.left, insetR.top,
insetR.width, insetR.height);
}
FALSE, insetR.left, insetR.top,
insetR.width, insetR.height);
}
}
} /* gtkDrawTileImpl */
static void
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 );
}
@ -609,7 +614,7 @@ gtk_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect, const XP_UCHAR* textP,
static void
gtk_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
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 );
gtkDrawTileImpl( p_dctx, rect, textP, bitmap, val,

View file

@ -1844,6 +1844,7 @@ gtkmain( LaunchParams* params, int argc, char *argv[] )
#endif
globals.cp.showBoardArrow = XP_TRUE;
globals.cp.hideTileValues = params->hideValues;
globals.cp.showRobotScores = params->showRobotScores;
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 [-w pwd]* # passwd for matching local player\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 [-l] # disallow hints\n"
"\t [-c] # explain robot scores after each move\n"
@ -725,7 +726,7 @@ main( int argc, char** argv )
#if defined PLATFORM_GTK
"h:I"
#endif
"kKf:ln:Nsd:e:r:b:q:w:Sit:Umvc"
"kKf:ln:Nsd:e:r:b:q:w:Sit:UmvcV"
#ifdef XWFEATURE_SMS
"M:"
#endif
@ -864,6 +865,9 @@ main( int argc, char** argv )
btaddr = optarg;
break;
#endif
case 'V':
mainParams.hideValues = XP_TRUE;
break;
case 'v':
mainParams.verticalScore = XP_TRUE;
break;

View file

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

View file

@ -677,7 +677,7 @@ smallBoldStringAt( const char* str, XP_U16 len, XP_S16 x, XP_U16 y )
static void
palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
const XP_UCHAR* letters, XP_Bitmap bitmap,
XP_S16 val, CellFlags flags )
XP_U16 val, CellFlags flags )
{
PalmDrawCtx* dctx = (PalmDrawCtx*)p_dctx;
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
honor the winOverlay flag and erase. Better to erase the value
than the letter. */
if ( val >= 0 ) {
if ( (flags & CELL_VALHIDDEN) == 0 ) {
(void)StrPrintF( valBuf, "%d", val );
len = XP_STRLEN((const char*)valBuf);
@ -769,7 +769,7 @@ palm_draw_drawTile( DrawCtx* p_dctx, const XP_Rect* rect,
static void
palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
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. */
draw_trayBegin( p_dctx, rect, owner, DFS_NONE );
@ -781,8 +781,8 @@ palm_draw_drawTileMidDrag( DrawCtx* p_dctx, const XP_Rect* rect,
static void
palm_draw_drawTileBack( DrawCtx* p_dctx, const XP_Rect* rect, CellFlags flags )
{
palm_draw_drawTile( p_dctx, rect, (unsigned char*)"?", (XP_Bitmap)NULL,
-1, flags & CELL_ISCURSOR );
palm_draw_drawTile( p_dctx, rect, "?", (XP_Bitmap)NULL,
0, (flags & CELL_ISCURSOR) | CELL_VALHIDDEN );
} /* palm_draw_drawTileBack */
static void

View file

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