improve text in remaining tiles dialog, and always show the tiles for

all trays rather than excluding those in current player's tray.
This commit is contained in:
Eric House 2012-07-09 21:44:29 -07:00
parent f1c5ebeb31
commit bd70a1dd7d
7 changed files with 58 additions and 12 deletions

View file

@ -26,6 +26,8 @@
# define STR_COMMIT_CONFIRM 20
# define STR_BONUS_ALL 21
# define STRD_TURN_SCORE 22
# define STRD_REMAINS_HEADER 23
# define STRD_REMAINS_EXPL 24
# define N_AND_USER_STRINGS 22
# define N_AND_USER_STRINGS 24
#endif

View file

@ -769,6 +769,13 @@
one turn is substituted for %d.-->
<string name="strd_turn_score">Score for turn: %d\n</string>
<!-- First line in the remaining tiles dialog (reached by tapping
the number at left end of the scoreboard) -->
<string name="strd_remains_header">%d tiles left in pool.</string>
<!-- Intro to the paragraph lisiting all of the tiles remaining -->
<string name="strd_remains_expl">%d tiles left in pool and all
tray[s]:\n</string>
<!-- text of dialog shown when the menu item board_menu_undo_last
is chosen. -->
<string name="confirm_undo_last">Are you sure you want to undo the

View file

@ -82,6 +82,9 @@ public interface UtilCtxt {
static final int STR_COMMIT_CONFIRM = 20;
static final int STR_BONUS_ALL = 21;
static final int STRD_TURN_SCORE = 22;
static final int STRD_REMAINS_HEADER = 23;
static final int STRD_REMAINS_EXPL = 24;
String getUserString( int stringCode );
static final int QUERY_COMMIT_TURN = 0;

View file

@ -175,6 +175,13 @@ public class UtilCtxtImpl implements UtilCtxt {
case UtilCtxt.STRD_TURN_SCORE:
id = R.string.strd_turn_score;
break;
case UtilCtxt.STRD_REMAINS_HEADER:
id = R.string.strd_remains_header;
break;
case UtilCtxt.STRD_REMAINS_EXPL:
id = R.string.strd_remains_expl;
break;
default:
DbgUtils.logf( "no such stringCode: %d", stringCode );
}

View file

@ -2788,45 +2788,65 @@ server_formatDictCounts( ServerCtxt* server, XWStreamCtxt* stream,
*/
void
server_formatRemainingTiles( ServerCtxt* server, XWStreamCtxt* stream,
XP_S16 player )
XP_S16 XP_UNUSED(player) )
{
PoolContext* pool = server->pool;
if ( !!pool ) {
DictionaryCtxt* dict;
XP_UCHAR buf[48];
DictionaryCtxt* dict = model_getDictionary( server->vol.model );
Tile tile;
XP_U16 nChars;
XP_U16 nChars = dict_numTileFaces( dict );
XP_U16 offset;
XP_U16 counts[MAX_UNIQUE_TILES+1]; /* 1 for the blank */
XP_U16 nLeft = pool_getNTilesLeft( pool );
XP_UCHAR cntsBuf[512];
XP_ASSERT( !!server->vol.model );
const XP_UCHAR* fmt = util_getUserString( server->vol.util,
STRD_REMAINS_HEADER );
XP_SNPRINTF( buf, sizeof(buf), fmt, nLeft );
stream_catString( stream, buf );
stream_catString( stream, "\n\n" );
XP_MEMSET( counts, 0, sizeof(counts) );
model_countAllTrayTiles( server->vol.model, counts, player );
model_countAllTrayTiles( server->vol.model, counts, -1 );
dict = model_getDictionary( server->vol.model );
nChars = dict_numTileFaces( dict );
for ( tile = 0; ; ) {
for ( cntsBuf[0] = '\0', offset = 0, tile = 0;
offset < sizeof(cntsBuf); ) {
XP_U16 count = pool_getNTilesLeftFor( pool, tile ) + counts[tile];
XP_Bool hasCount = count > 0;
nLeft += counts[tile];
if ( hasCount ) {
const XP_UCHAR* face = dict_getTileString( dict, tile );
for ( ; ; ) {
stream_catString( stream, face );
offset += XP_SNPRINTF( &cntsBuf[offset],
sizeof(cntsBuf) - offset, "%s",
face );
if ( --count == 0 ) {
break;
}
stream_catString( stream, "." );
offset += XP_SNPRINTF( &cntsBuf[offset],
sizeof(cntsBuf) - offset, "." );
}
}
if ( ++tile >= nChars ) {
break;
} else if ( hasCount ) {
stream_catString( stream, (void*)" " );
offset += XP_SNPRINTF( &cntsBuf[offset],
sizeof(cntsBuf) - offset, " " );
}
XP_ASSERT( offset < sizeof(cntsBuf) );
}
fmt = util_getUserString( server->vol.util, STRD_REMAINS_EXPL );
XP_SNPRINTF( buf, sizeof(buf), fmt, nLeft );
stream_catString( stream, buf );
stream_catString( stream, cntsBuf );
}
} /* server_formatRemainingTiles */

View file

@ -55,6 +55,8 @@ enum {
STR_REMOTE,
STRS_VALUES_HEADER,
STRD_REMAINS_HEADER,
STRD_REMAINS_EXPL,
STR_LAST
};

View file

@ -331,6 +331,11 @@ linux_util_getUserString( XW_UtilCtxt* XP_UNUSED(uc), XP_U16 code )
case STRS_VALUES_HEADER:
return (XP_UCHAR*)"%s counts/values:\n";
case STRD_REMAINS_HEADER:
return (XP_UCHAR*)"%d tiles left in pool.";
case STRD_REMAINS_EXPL:
return (XP_UCHAR*)"%d tiles left in pool and all tray[s]:\n";
default:
return (XP_UCHAR*)"unknown code to linux_util_getUserString";
}