From b618c99fa8cde6964a6cceb489d3ba70ef646dfa Mon Sep 17 00:00:00 2001 From: Eric House Date: Fri, 24 Apr 2020 22:21:02 -0700 Subject: [PATCH] just print the upper-case versions of tile faces --- xwords4/android/jni/xwjni.c | 2 +- xwords4/common/server.c | 6 +++--- xwords4/common/server.h | 2 +- xwords4/linux/cursesboard.c | 2 +- xwords4/linux/gtkboard.c | 18 ++++++++++++++++-- 5 files changed, 22 insertions(+), 8 deletions(-) diff --git a/xwords4/android/jni/xwjni.c b/xwords4/android/jni/xwjni.c index c5f743690..1ad798cfc 100644 --- a/xwords4/android/jni/xwjni.c +++ b/xwords4/android/jni/xwjni.c @@ -1653,7 +1653,7 @@ Java_org_eehouse_android_xw4_jni_XwJNI_server_1formatDictCounts jstring result; XWJNI_START_GLOBALS(); XWStreamCtxt* stream = and_empty_stream( MPPARM(mpool) globals ); - server_formatDictCounts( state->game.server, stream, nCols ); + server_formatDictCounts( state->game.server, stream, nCols, XP_FALSE ); result = streamToJString( env, stream ); stream_destroy( stream ); XWJNI_END(); diff --git a/xwords4/common/server.c b/xwords4/common/server.c index 32da190b2..568985d7b 100644 --- a/xwords4/common/server.c +++ b/xwords4/common/server.c @@ -4177,7 +4177,7 @@ server_receiveMessage( ServerCtxt* server, XWStreamCtxt* incoming ) void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, - XP_U16 nCols ) + XP_U16 nCols, XP_Bool allFaces ) { DictionaryCtxt* dict; Tile tile; @@ -4206,14 +4206,14 @@ server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, const XP_UCHAR* face = NULL; XP_UCHAR faces[48] = {0}; XP_U16 len = 0; - for ( ; ; ) { + do { face = dict_getNextTileString( dict, tile, face ); if ( !face ) { break; } const XP_UCHAR* fmt = len == 0? "%s" : ",%s"; len += XP_SNPRINTF( faces + len, sizeof(faces) - len, fmt, face ); - } + } while ( allFaces ); value = dict_getTileValue( dict, tile ); XP_SNPRINTF( buf, sizeof(buf), (XP_UCHAR*)"%s: %d/%d", diff --git a/xwords4/common/server.h b/xwords4/common/server.h index af608746c..f1b500c49 100644 --- a/xwords4/common/server.h +++ b/xwords4/common/server.h @@ -122,7 +122,7 @@ void server_sendChat( ServerCtxt* server, const XP_UCHAR* msg, XP_S16 from ); #endif void server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream, - XP_U16 nCols ); + XP_U16 nCols, XP_Bool allFaces ); void server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream, XP_S16 player ); diff --git a/xwords4/linux/cursesboard.c b/xwords4/linux/cursesboard.c index 491a3de9e..0d1aac1fe 100644 --- a/xwords4/linux/cursesboard.c +++ b/xwords4/linux/cursesboard.c @@ -1474,7 +1474,7 @@ handleShowVals( void* closure, int XP_UNUSED(key) ) XWStreamCtxt* stream = mem_stream_make_raw( MPPARM(cGlobals->util->mpool) cGlobals->params->vtMgr ); - server_formatDictCounts( bGlobals->cGlobals.game.server, stream, 5 ); + server_formatDictCounts( bGlobals->cGlobals.game.server, stream, 5, XP_FALSE ); const XP_U8* data = stream_getPtr( stream ); XP_U16 len = stream_getSize( stream ); XP_UCHAR buf[len + 1]; diff --git a/xwords4/linux/gtkboard.c b/xwords4/linux/gtkboard.c index d73de1b31..6f94009f3 100644 --- a/xwords4/linux/gtkboard.c +++ b/xwords4/linux/gtkboard.c @@ -734,7 +734,7 @@ makeAddSubmenu( GtkWidget* menubar, gchar* label ) } /* makeAddSubmenu */ static void -tile_values( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals ) +tile_values_impl( GtkGameGlobals* globals, bool full ) { CommonGlobals* cGlobals = &globals->cGlobals; if ( !!cGlobals->game.server ) { @@ -744,13 +744,25 @@ tile_values( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals ) globals, CHANNEL_NONE, catOnClose ); - server_formatDictCounts( cGlobals->game.server, stream, 5 ); + server_formatDictCounts( cGlobals->game.server, stream, 5, full ); stream_putU8( stream, '\n' ); stream_destroy( stream ); } } /* tile_values */ +static void +tile_values( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals ) +{ + tile_values_impl( globals, false ); +} + +static void +tile_values_full( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals ) +{ + tile_values_impl( globals, true ); +} + static void game_history( GtkWidget* XP_UNUSED(widget), GtkGameGlobals* globals ) { @@ -1037,6 +1049,8 @@ makeMenus( GtkGameGlobals* globals ) fileMenu = makeAddSubmenu( menubar, "File" ); (void)createAddItem( fileMenu, "Tile values", (GCallback)tile_values, globals ); + (void)createAddItem( fileMenu, "Tile values full", + (GCallback)tile_values_full, globals ); (void)createAddItem( fileMenu, "Game history", (GCallback)game_history, globals ); #ifdef TEXT_MODEL