mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
change signature of util_playerScoreHeld(): pass player num rather
than formatted text. Client code can use new model_getPlayersLastScore() or whatever else it wants to build text to show the user.
This commit is contained in:
parent
b6a4621617
commit
2d2f3e23fd
7 changed files with 36 additions and 38 deletions
|
@ -399,12 +399,10 @@ and_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
|||
}
|
||||
|
||||
static void
|
||||
and_util_playerScoreHeld( XW_UtilCtxt* uc, const XP_UCHAR* txt )
|
||||
and_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||
{
|
||||
UTIL_CBK_HEADER( "playerScoreHeld", "(Ljava/lang/String;)V" );
|
||||
jstring jmsg = (*env)->NewStringUTF( env, txt );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, jmsg );
|
||||
(*env)->DeleteLocalRef( env, jmsg );
|
||||
UTIL_CBK_HEADER( "playerScoreHeld", "(I)V" );
|
||||
(*env)->CallVoidMethod( env, util->jutil, mid, player );
|
||||
UTIL_CBK_TAIL();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -930,8 +930,13 @@ public class BoardActivity extends XWActivity
|
|||
}
|
||||
|
||||
@Override
|
||||
public void playerScoreHeld( final String text )
|
||||
public void playerScoreHeld( int player )
|
||||
{
|
||||
String expl = XwJNI.model_getPlayersLastScore( m_jniGamePtr,
|
||||
player );
|
||||
String name = m_gi.players[player].name;
|
||||
final String text = expl.length() > 0 ?
|
||||
String.format( "%s\n%s", name, expl ) : name;
|
||||
post( new Runnable() {
|
||||
public void run() {
|
||||
Toast.makeText( BoardActivity.this, text,
|
||||
|
@ -1072,9 +1077,6 @@ public class BoardActivity extends XWActivity
|
|||
case UtilCtxt.ERR_NO_PEEK_ROBOT_TILES:
|
||||
resid = R.string.str_no_peek_robot_tiles;
|
||||
break;
|
||||
case UtilCtxt.ERR_CANT_TRADE_MID_MOVE:
|
||||
resid = R.string.str_cant_trade_mid_move;
|
||||
break;
|
||||
case UtilCtxt.ERR_NO_EMPTY_TRADE:
|
||||
resid = R.string.str_no_empty_trade;
|
||||
break;
|
||||
|
|
|
@ -48,7 +48,7 @@ public interface UtilCtxt {
|
|||
void setIsServer( boolean isServer );
|
||||
|
||||
void bonusSquareHeld( int bonus );
|
||||
void playerScoreHeld( String text );
|
||||
void playerScoreHeld( int player );
|
||||
|
||||
static final int STRD_ROBOT_TRADED = 1;
|
||||
static final int STR_ROBOT_MOVED = 2;
|
||||
|
@ -70,10 +70,8 @@ public interface UtilCtxt {
|
|||
static final int STRD_TRADED = 18;
|
||||
static final int STR_LOSTTURN = 19;
|
||||
static final int STR_COMMIT_CONFIRM = 20;
|
||||
static final int STR_LOCAL_NAME = 21;
|
||||
static final int STR_NONLOCAL_NAME = 22;
|
||||
static final int STR_BONUS_ALL = 23;
|
||||
static final int STRD_TURN_SCORE = 24;
|
||||
static final int STR_BONUS_ALL = 21;
|
||||
static final int STRD_TURN_SCORE = 22;
|
||||
String getUserString( int stringCode );
|
||||
|
||||
static final int QUERY_COMMIT_TURN = 0;
|
||||
|
@ -97,11 +95,10 @@ public interface UtilCtxt {
|
|||
static final int ERR_REG_UNEXPECTED_USER = 10;
|
||||
static final int ERR_REG_SERVER_SANS_REMOTE = 11;
|
||||
static final int STR_NEED_BT_HOST_ADDR = 12;
|
||||
static final int ERR_CANT_TRADE_MID_MOVE = 13;
|
||||
static final int ERR_NO_EMPTY_TRADE = 14;
|
||||
static final int ERR_CANT_UNDO_TILEASSIGN = 15;
|
||||
static final int ERR_CANT_HINT_WHILE_DISABLED = 16;
|
||||
static final int ERR_RELAY_BASE = 17;
|
||||
static final int ERR_NO_EMPTY_TRADE = 13;
|
||||
static final int ERR_CANT_UNDO_TILEASSIGN = 14;
|
||||
static final int ERR_CANT_HINT_WHILE_DISABLED = 15;
|
||||
static final int ERR_RELAY_BASE = 16;
|
||||
void userError( int id );
|
||||
|
||||
void notifyGameOver();
|
||||
|
|
|
@ -87,7 +87,7 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
{
|
||||
}
|
||||
|
||||
public void playerScoreHeld( String text )
|
||||
public void playerScoreHeld( int player )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -155,12 +155,6 @@ public class UtilCtxtImpl implements UtilCtxt {
|
|||
case UtilCtxt.STR_COMMIT_CONFIRM:
|
||||
id = R.string.str_commit_confirm;
|
||||
break;
|
||||
case UtilCtxt.STR_LOCAL_NAME:
|
||||
id = R.string.str_local_name;
|
||||
break;
|
||||
case UtilCtxt.STR_NONLOCAL_NAME:
|
||||
id = R.string.str_nonlocal_name;
|
||||
break;
|
||||
case UtilCtxt.STR_BONUS_ALL:
|
||||
id = R.string.str_bonus_all;
|
||||
break;
|
||||
|
|
|
@ -945,7 +945,9 @@ timerFiredForPen( BoardCtxt* board )
|
|||
{
|
||||
XP_Bool draw = XP_FALSE;
|
||||
const XP_UCHAR* text = (XP_UCHAR*)NULL;
|
||||
#ifdef XWFEATURE_MINIWIN
|
||||
XP_UCHAR buf[80];
|
||||
#endif
|
||||
|
||||
if ( board->penDownObject == OBJ_BOARD ) {
|
||||
if ( !dragDropInProgress( board ) || !dragDropHasMoved( board ) ) {
|
||||
|
@ -974,7 +976,6 @@ timerFiredForPen( BoardCtxt* board )
|
|||
board->penTimerFired = XP_TRUE;
|
||||
}
|
||||
} else if ( board->penDownObject == OBJ_SCORE ) {
|
||||
LocalPlayer* lp;
|
||||
XP_S16 scoreIndex = figureScoreRectTapped( board, board->penDownX,
|
||||
board->penDownY );
|
||||
/* I've seen this assert fire on simulator. No log is kept so I can't
|
||||
|
@ -982,11 +983,11 @@ timerFiredForPen( BoardCtxt* board )
|
|||
/* XP_ASSERT( player >= 0 ); */
|
||||
if ( scoreIndex > CURSOR_LOC_REM ) {
|
||||
XP_U16 player = scoreIndex - 1;
|
||||
#ifdef XWFEATURE_MINIWIN
|
||||
const XP_UCHAR* format;
|
||||
XP_UCHAR scoreExpl[48];
|
||||
XP_U16 explLen;
|
||||
|
||||
lp = &board->gi->players[player];
|
||||
LocalPlayer* lp = &board->gi->players[player];
|
||||
format = util_getUserString( board->util, lp->isLocal?
|
||||
STR_LOCAL_NAME: STR_NONLOCAL_NAME );
|
||||
XP_SNPRINTF( buf, sizeof(buf), format, emptyStringIfNull(lp->name) );
|
||||
|
@ -998,10 +999,9 @@ timerFiredForPen( BoardCtxt* board )
|
|||
XP_ASSERT( XP_STRLEN(buf) + explLen < sizeof(buf) );
|
||||
XP_STRCAT( buf, scoreExpl );
|
||||
}
|
||||
#ifdef XWFEATURE_MINIWIN
|
||||
text = buf;
|
||||
#else
|
||||
util_playerScoreHeld( board->util, buf );
|
||||
util_playerScoreHeld( board->util, player );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ typedef enum {
|
|||
ERR_REG_SERVER_SANS_REMOTE,
|
||||
STR_NEED_BT_HOST_ADDR,
|
||||
#endif
|
||||
ERR_CANT_TRADE_MID_MOVE,
|
||||
ERR_NO_EMPTY_TRADE,
|
||||
/* ERR_CANT_ENGINE_MID_MOVE, */
|
||||
/* ERR_NOT_YOUR_TURN_TO_TRADE, */
|
||||
|
@ -160,7 +159,7 @@ typedef struct UtilVtable {
|
|||
|
||||
#ifndef XWFEATURE_MINIWIN
|
||||
void (*m_util_bonusSquareHeld)( XW_UtilCtxt* uc, XWBonusType bonus );
|
||||
void (*m_util_playerScoreHeld)( XW_UtilCtxt* uc, const XP_UCHAR* txt );
|
||||
void (*m_util_playerScoreHeld)( XW_UtilCtxt* uc, XP_U16 player );
|
||||
#endif
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
|
@ -266,8 +265,8 @@ struct XW_UtilCtxt {
|
|||
#ifndef XWFEATURE_MINIWIN
|
||||
# define util_bonusSquareHeld( uc, b ) \
|
||||
(uc)->vtable->m_util_bonusSquareHeld( (uc), (b) )
|
||||
# define util_playerScoreHeld( uc, txt ) \
|
||||
(uc)->vtable->m_util_playerScoreHeld( (uc), (txt) )
|
||||
# define util_playerScoreHeld( uc, player ) \
|
||||
(uc)->vtable->m_util_playerScoreHeld( (uc), (player) )
|
||||
#endif
|
||||
|
||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||
|
|
|
@ -1703,11 +1703,19 @@ gtk_util_bonusSquareHeld( XW_UtilCtxt* uc, XWBonusType bonus )
|
|||
}
|
||||
|
||||
static void
|
||||
gtk_util_playerScoreHeld( XW_UtilCtxt* uc, const XP_UCHAR* txt )
|
||||
gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||
{
|
||||
LOG_FUNC();
|
||||
XP_USE( uc );
|
||||
XP_USE( txt );
|
||||
|
||||
GtkAppGlobals* globals = (GtkAppGlobals*)uc->closure;
|
||||
|
||||
XP_UCHAR scoreExpl[48];
|
||||
XP_U16 explLen = sizeof(scoreExpl);
|
||||
|
||||
if ( model_getPlayersLastScore( globals->cGlobals.game.model,
|
||||
player, scoreExpl, &explLen ) ) {
|
||||
XP_LOGF( "got: %s", scoreExpl );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue