mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-29 08:34:37 +01:00
show new client-formatted turn summary in notification; remove old
common-formatting code.
This commit is contained in:
parent
2d08848715
commit
88248131da
19 changed files with 542 additions and 606 deletions
File diff suppressed because it is too large
Load diff
|
@ -19,17 +19,13 @@
|
||||||
# define STR_PHONY_REJECTED 13
|
# define STR_PHONY_REJECTED 13
|
||||||
# define STRD_CUMULATIVE_SCORE 14
|
# define STRD_CUMULATIVE_SCORE 14
|
||||||
# define STRS_NEW_TILES 15
|
# define STRS_NEW_TILES 15
|
||||||
# define STR_PASSED 16
|
# define STR_COMMIT_CONFIRM 16
|
||||||
# define STRSD_SUMMARYSCORED 17
|
# define STR_BONUS_ALL 17
|
||||||
# define STRD_TRADED 18
|
# define STRD_TURN_SCORE 18
|
||||||
# define STR_LOSTTURN 19
|
# define STRD_REMAINS_HEADER 19
|
||||||
# define STR_COMMIT_CONFIRM 20
|
# define STRD_REMAINS_EXPL 20
|
||||||
# define STR_BONUS_ALL 21
|
# define STR_RESIGNED 21
|
||||||
# define STRD_TURN_SCORE 22
|
# define STR_WINNER 22
|
||||||
# define STRD_REMAINS_HEADER 23
|
|
||||||
# define STRD_REMAINS_EXPL 24
|
|
||||||
# define STR_RESIGNED 25
|
|
||||||
# define STR_WINNER 26
|
|
||||||
|
|
||||||
# define N_AND_USER_STRINGS 26
|
# define N_AND_USER_STRINGS 22
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -202,16 +202,6 @@ setJGI( JNIEnv* env, jobject jgi, const CurGameInfo* gi )
|
||||||
}
|
}
|
||||||
} /* setJGI */
|
} /* setJGI */
|
||||||
|
|
||||||
static void
|
|
||||||
setLMI( JNIEnv* env, jobject jlmi, const LastMoveInfo* lmi )
|
|
||||||
{
|
|
||||||
setInt( env, jlmi, "score", lmi->score );
|
|
||||||
setInt( env, jlmi, "nTiles", lmi->nTiles );
|
|
||||||
setInt( env, jlmi, "moveType", lmi->moveType );
|
|
||||||
setString( env, jlmi, "name", lmi->name );
|
|
||||||
setString( env, jlmi, "word", lmi->word );
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef COMMON_LAYOUT
|
#ifdef COMMON_LAYOUT
|
||||||
static const SetInfo bd_ints[] = {
|
static const SetInfo bd_ints[] = {
|
||||||
ARR_MEMBER( BoardDims, left )
|
ARR_MEMBER( BoardDims, left )
|
||||||
|
@ -1143,24 +1133,24 @@ Java_org_eehouse_android_xw4_jni_XwJNI_model_1getNumTilesInTray
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_eehouse_android_xw4_jni_XwJNI_model_1getPlayersLastScore
|
Java_org_eehouse_android_xw4_jni_XwJNI_model_1getPlayersLastScore
|
||||||
( JNIEnv* env, jclass C, jint gamePtr, jint player, jobject jlmi )
|
( JNIEnv* env, jclass C, jint gamePtr, jint player, jobject jlmi )
|
||||||
{
|
{
|
||||||
jstring result = NULL;
|
|
||||||
XWJNI_START();
|
XWJNI_START();
|
||||||
XP_ASSERT( !!state->game.model );
|
XP_ASSERT( !!state->game.model );
|
||||||
XP_UCHAR buf[64] = {0};
|
|
||||||
XP_U16 buflen = sizeof(buf);
|
|
||||||
LastMoveInfo lmi;
|
LastMoveInfo lmi;
|
||||||
if ( !model_getPlayersLastScore( state->game.model, player, &lmi,
|
XP_Bool valid = model_getPlayersLastScore( state->game.model,
|
||||||
buf, &buflen ) ) {
|
player, &lmi );
|
||||||
buf[0] = '\0';
|
setBool( env, jlmi, "isValid", valid );
|
||||||
|
if ( valid ) {
|
||||||
|
setInt( env, jlmi, "score", lmi.score );
|
||||||
|
setInt( env, jlmi, "nTiles", lmi.nTiles );
|
||||||
|
setInt( env, jlmi, "moveType", lmi.moveType );
|
||||||
|
setString( env, jlmi, "name", lmi.name );
|
||||||
|
setString( env, jlmi, "word", lmi.word );
|
||||||
}
|
}
|
||||||
setLMI( env, jlmi, &lmi );
|
|
||||||
result = (*env)->NewStringUTF( env, buf );
|
|
||||||
XWJNI_END();
|
XWJNI_END();
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
JNIEXPORT jstring JNICALL
|
JNIEXPORT jstring JNICALL
|
||||||
|
|
|
@ -709,20 +709,6 @@
|
||||||
phonies is set to lose turn when word used not in wordlist
|
phonies is set to lose turn when word used not in wordlist
|
||||||
-->
|
-->
|
||||||
<string name="str_phony_rejected">Illegal word in move; turn lost!</string>
|
<string name="str_phony_rejected">Illegal word in move; turn lost!</string>
|
||||||
<!-- Used in formatting exchange move summaries: passed means the
|
|
||||||
user skipped his turn, or made a move involving 0 tiles for 0
|
|
||||||
points -->
|
|
||||||
<string name="str_passed">Passed</string>
|
|
||||||
<!-- formats tiles and score together, and probably doesn't need
|
|
||||||
translation unless the colon ':' needs to be replaced -->
|
|
||||||
<string name="strsd_summaryscored_fmt">%1$s:%2$d</string>
|
|
||||||
<!-- Used in formatting reports of trades (exchanges of tiles).
|
|
||||||
Number of tiles traded is substituted for %1$d-->
|
|
||||||
<string name="strd_traded_fmt">Exchanged %1$d tiles</string>
|
|
||||||
<!-- Used in formatting history and move reports; means user
|
|
||||||
skipped a turn because of an attempted illegal move/play of a
|
|
||||||
phony -->
|
|
||||||
<string name="str_lostturn">Lost turn</string>
|
|
||||||
<!-- Beginning of the message presented to a user when asking him
|
<!-- Beginning of the message presented to a user when asking him
|
||||||
to confirm committing the current turn-->
|
to confirm committing the current turn-->
|
||||||
<string name="str_commit_confirm">Commit the current move?\n</string>
|
<string name="str_commit_confirm">Commit the current move?\n</string>
|
||||||
|
@ -2281,4 +2267,9 @@
|
||||||
<!-- Used when prev player's name can't be looked up -->
|
<!-- Used when prev player's name can't be looked up -->
|
||||||
<string name="prev_player">Your opponent</string>
|
<string name="prev_player">Your opponent</string>
|
||||||
|
|
||||||
|
<!-- formatting for last move summary in notifications -->
|
||||||
|
<string name="lmi_pass_fmt">%1$s passed</string>
|
||||||
|
<string name="lmi_move_fmt">%1$s played %2$s for %3$d points</string>
|
||||||
|
<string name="lmi_trade_fmt">%1$s traded %2$d tiles</string>
|
||||||
|
<string name="lmi_phony_fmt">%1$s lost a turn</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -602,20 +602,6 @@
|
||||||
phonies is set to lose turn when word used not in wordlist
|
phonies is set to lose turn when word used not in wordlist
|
||||||
-->
|
-->
|
||||||
<string name="str_phony_rejected">Lagelli drow ni evom; nrut !tsol</string>
|
<string name="str_phony_rejected">Lagelli drow ni evom; nrut !tsol</string>
|
||||||
<!-- Used in formatting exchange move summaries: passed means the
|
|
||||||
user skipped his turn, or made a move involving 0 tiles for 0
|
|
||||||
points -->
|
|
||||||
<string name="str_passed">Dessap</string>
|
|
||||||
<!-- formats tiles and score together, and probably doesn't need
|
|
||||||
translation unless the colon ':' needs to be replaced -->
|
|
||||||
<string name="strsd_summaryscored_fmt">%1$s:%2$d</string>
|
|
||||||
<!-- Used in formatting reports of trades (exchanges of tiles).
|
|
||||||
Number of tiles traded is substituted for %1$d-->
|
|
||||||
<string name="strd_traded_fmt">Degnahcxe %1$d selit</string>
|
|
||||||
<!-- Used in formatting history and move reports; means user
|
|
||||||
skipped a turn because of an attempted illegal move/play of a
|
|
||||||
phony -->
|
|
||||||
<string name="str_lostturn">Tsol nrut</string>
|
|
||||||
<!-- Beginning of the message presented to a user when asking him
|
<!-- Beginning of the message presented to a user when asking him
|
||||||
to confirm committing the current turn-->
|
to confirm committing the current turn-->
|
||||||
<string name="str_commit_confirm">Timmoc eht tnerruc ?evom\n</string>
|
<string name="str_commit_confirm">Timmoc eht tnerruc ?evom\n</string>
|
||||||
|
@ -1951,4 +1937,9 @@
|
||||||
<string name="nag_warn_last_fmt">Tsal gninraw: %1$s</string>
|
<string name="nag_warn_last_fmt">Tsal gninraw: %1$s</string>
|
||||||
<!-- Used when prev player's name can't be looked up -->
|
<!-- Used when prev player's name can't be looked up -->
|
||||||
<string name="prev_player">Ruoy tnenoppo</string>
|
<string name="prev_player">Ruoy tnenoppo</string>
|
||||||
|
<!-- formatting for last move summary in notifications -->
|
||||||
|
<string name="lmi_pass_fmt">%1$s dessap</string>
|
||||||
|
<string name="lmi_move_fmt">%1$s deyalp %2$s rof %3$d stniop</string>
|
||||||
|
<string name="lmi_trade_fmt">%1$s dedart %2$d selit</string>
|
||||||
|
<string name="lmi_phony_fmt">%1$s tsol a nrut</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -602,20 +602,6 @@
|
||||||
phonies is set to lose turn when word used not in wordlist
|
phonies is set to lose turn when word used not in wordlist
|
||||||
-->
|
-->
|
||||||
<string name="str_phony_rejected">ILLEGAL WORD IN MOVE; TURN LOST!</string>
|
<string name="str_phony_rejected">ILLEGAL WORD IN MOVE; TURN LOST!</string>
|
||||||
<!-- Used in formatting exchange move summaries: passed means the
|
|
||||||
user skipped his turn, or made a move involving 0 tiles for 0
|
|
||||||
points -->
|
|
||||||
<string name="str_passed">PASSED</string>
|
|
||||||
<!-- formats tiles and score together, and probably doesn't need
|
|
||||||
translation unless the colon ':' needs to be replaced -->
|
|
||||||
<string name="strsd_summaryscored_fmt">%1$s:%2$d</string>
|
|
||||||
<!-- Used in formatting reports of trades (exchanges of tiles).
|
|
||||||
Number of tiles traded is substituted for %1$d-->
|
|
||||||
<string name="strd_traded_fmt">EXCHANGED %1$d TILES</string>
|
|
||||||
<!-- Used in formatting history and move reports; means user
|
|
||||||
skipped a turn because of an attempted illegal move/play of a
|
|
||||||
phony -->
|
|
||||||
<string name="str_lostturn">LOST TURN</string>
|
|
||||||
<!-- Beginning of the message presented to a user when asking him
|
<!-- Beginning of the message presented to a user when asking him
|
||||||
to confirm committing the current turn-->
|
to confirm committing the current turn-->
|
||||||
<string name="str_commit_confirm">COMMIT THE CURRENT MOVE?\n</string>
|
<string name="str_commit_confirm">COMMIT THE CURRENT MOVE?\n</string>
|
||||||
|
@ -1951,4 +1937,9 @@
|
||||||
<string name="nag_warn_last_fmt">LAST WARNING: %1$s</string>
|
<string name="nag_warn_last_fmt">LAST WARNING: %1$s</string>
|
||||||
<!-- Used when prev player's name can't be looked up -->
|
<!-- Used when prev player's name can't be looked up -->
|
||||||
<string name="prev_player">YOUR OPPONENT</string>
|
<string name="prev_player">YOUR OPPONENT</string>
|
||||||
|
<!-- formatting for last move summary in notifications -->
|
||||||
|
<string name="lmi_pass_fmt">%1$s PASSED</string>
|
||||||
|
<string name="lmi_move_fmt">%1$s PLAYED %2$s FOR %3$d POINTS</string>
|
||||||
|
<string name="lmi_trade_fmt">%1$s TRADED %2$d TILES</string>
|
||||||
|
<string name="lmi_phony_fmt">%1$s LOST A TURN</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
|
@ -1416,14 +1416,12 @@ public class BoardDelegate extends DelegateBase
|
||||||
public void playerScoreHeld( int player )
|
public void playerScoreHeld( int player )
|
||||||
{
|
{
|
||||||
LastMoveInfo lmi = new LastMoveInfo();
|
LastMoveInfo lmi = new LastMoveInfo();
|
||||||
String expl = XwJNI.model_getPlayersLastScore( m_jniGamePtr,
|
XwJNI.model_getPlayersLastScore( m_jniGamePtr, player, lmi );
|
||||||
player, lmi );
|
String expl = lmi.format( m_activity );
|
||||||
expl = lmi.format( m_activity );
|
if ( null == expl || 0 == expl.length() ) {
|
||||||
if ( expl.length() == 0 ) {
|
|
||||||
expl = getString( R.string.no_moves_made );
|
expl = getString( R.string.no_moves_made );
|
||||||
}
|
}
|
||||||
String name = m_gi.players[player].name;
|
final String text = expl;
|
||||||
final String text = String.format( "%s\n%s", name, expl );
|
|
||||||
post( new Runnable() {
|
post( new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
showToast( text );
|
showToast( text );
|
||||||
|
|
|
@ -799,7 +799,7 @@ public class GameUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( null != lmi ) {
|
if ( null != lmi ) {
|
||||||
XwJNI.model_getPlayersLastScore( gamePtr, 0, lmi );
|
XwJNI.model_getPlayersLastScore( gamePtr, -1, lmi );
|
||||||
}
|
}
|
||||||
|
|
||||||
saveGame( context, gamePtr, gi, lock, false );
|
saveGame( context, gamePtr, gi, lock, false );
|
||||||
|
|
|
@ -21,7 +21,19 @@ package org.eehouse.android.xw4.jni;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import org.eehouse.android.xw4.R;
|
||||||
|
import org.eehouse.android.xw4.DbgUtils;
|
||||||
|
import org.eehouse.android.xw4.loc.LocUtils;
|
||||||
|
|
||||||
public class LastMoveInfo {
|
public class LastMoveInfo {
|
||||||
|
|
||||||
|
// Keep in sync with StackMoveType in movestak.h
|
||||||
|
private static final int ASSIGN_TYPE = 0;
|
||||||
|
private static final int MOVE_TYPE = 1;
|
||||||
|
private static final int TRADE_TYPE = 2;
|
||||||
|
private static final int PHONY_TYPE = 3;
|
||||||
|
|
||||||
|
public boolean isValid;
|
||||||
public String name;
|
public String name;
|
||||||
public int moveType;
|
public int moveType;
|
||||||
public int score;
|
public int score;
|
||||||
|
@ -30,6 +42,31 @@ public class LastMoveInfo {
|
||||||
|
|
||||||
public String format( Context context )
|
public String format( Context context )
|
||||||
{
|
{
|
||||||
return String.format( "%s did move type %d", name, moveType );
|
String result = null;
|
||||||
|
if ( isValid ) {
|
||||||
|
switch( moveType ) {
|
||||||
|
case ASSIGN_TYPE:
|
||||||
|
break;
|
||||||
|
case MOVE_TYPE:
|
||||||
|
if ( 0 == nTiles ) {
|
||||||
|
result = LocUtils.getString( context, R.string.lmi_pass_fmt,
|
||||||
|
name );
|
||||||
|
} else {
|
||||||
|
result = LocUtils.getString( context, R.string.lmi_move_fmt,
|
||||||
|
name, word, score );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TRADE_TYPE:
|
||||||
|
result = LocUtils.getString( context, R.string.lmi_trade_fmt,
|
||||||
|
name, nTiles );
|
||||||
|
break;
|
||||||
|
case PHONY_TYPE:
|
||||||
|
result = LocUtils.getString( context, R.string.lmi_phony_fmt,
|
||||||
|
name );
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DbgUtils.logf( "LastMoveInfo.format() => %s", result );
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,17 +87,13 @@ public interface UtilCtxt {
|
||||||
static final int STR_PHONY_REJECTED = 13;
|
static final int STR_PHONY_REJECTED = 13;
|
||||||
static final int STRD_CUMULATIVE_SCORE = 14;
|
static final int STRD_CUMULATIVE_SCORE = 14;
|
||||||
static final int STRS_NEW_TILES = 15;
|
static final int STRS_NEW_TILES = 15;
|
||||||
static final int STR_PASSED = 16;
|
static final int STR_COMMIT_CONFIRM = 16;
|
||||||
static final int STRSD_SUMMARYSCORED = 17;
|
static final int STR_BONUS_ALL = 17;
|
||||||
static final int STRD_TRADED = 18;
|
static final int STRD_TURN_SCORE = 18;
|
||||||
static final int STR_LOSTTURN = 19;
|
static final int STRD_REMAINS_HEADER = 19;
|
||||||
static final int STR_COMMIT_CONFIRM = 20;
|
static final int STRD_REMAINS_EXPL = 20;
|
||||||
static final int STR_BONUS_ALL = 21;
|
static final int STR_RESIGNED = 21;
|
||||||
static final int STRD_TURN_SCORE = 22;
|
static final int STR_WINNER = 22;
|
||||||
static final int STRD_REMAINS_HEADER = 23;
|
|
||||||
static final int STRD_REMAINS_EXPL = 24;
|
|
||||||
static final int STR_RESIGNED = 25;
|
|
||||||
static final int STR_WINNER = 26;
|
|
||||||
|
|
||||||
String getUserString( int stringCode );
|
String getUserString( int stringCode );
|
||||||
|
|
||||||
|
|
|
@ -189,18 +189,6 @@ public class UtilCtxtImpl implements UtilCtxt {
|
||||||
case UtilCtxt.STRS_NEW_TILES:
|
case UtilCtxt.STRS_NEW_TILES:
|
||||||
id = R.string.strs_new_tiles_fmt;
|
id = R.string.strs_new_tiles_fmt;
|
||||||
break;
|
break;
|
||||||
case UtilCtxt.STR_PASSED:
|
|
||||||
id = R.string.str_passed;
|
|
||||||
break;
|
|
||||||
case UtilCtxt.STRSD_SUMMARYSCORED:
|
|
||||||
id = R.string.strsd_summaryscored_fmt;
|
|
||||||
break;
|
|
||||||
case UtilCtxt.STRD_TRADED:
|
|
||||||
id = R.string.strd_traded_fmt;
|
|
||||||
break;
|
|
||||||
case UtilCtxt.STR_LOSTTURN:
|
|
||||||
id = R.string.str_lostturn;
|
|
||||||
break;
|
|
||||||
case UtilCtxt.STR_COMMIT_CONFIRM:
|
case UtilCtxt.STR_COMMIT_CONFIRM:
|
||||||
id = R.string.str_commit_confirm;
|
id = R.string.str_commit_confirm;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -270,9 +270,9 @@ public class XwJNI {
|
||||||
boolean gameOver );
|
boolean gameOver );
|
||||||
public static native int model_getNMoves( int gamePtr );
|
public static native int model_getNMoves( int gamePtr );
|
||||||
public static native int model_getNumTilesInTray( int gamePtr, int player );
|
public static native int model_getNumTilesInTray( int gamePtr, int player );
|
||||||
public static native String model_getPlayersLastScore( int gamePtr,
|
public static native void model_getPlayersLastScore( int gamePtr,
|
||||||
int player,
|
int player,
|
||||||
LastMoveInfo lmi );
|
LastMoveInfo lmi );
|
||||||
// Server
|
// Server
|
||||||
public static native void server_reset( int gamePtr );
|
public static native void server_reset( int gamePtr );
|
||||||
public static native void server_handleUndo( int gamePtr );
|
public static native void server_handleUndo( int gamePtr );
|
||||||
|
|
|
@ -29,8 +29,7 @@
|
||||||
|
|
||||||
|
|
||||||
typedef XP_Bool (*LastScoreCallback)( void* closure, XP_S16 player,
|
typedef XP_Bool (*LastScoreCallback)( void* closure, XP_S16 player,
|
||||||
LastMoveInfo* lmi,
|
LastMoveInfo* lmi );
|
||||||
XP_UCHAR* expl, XP_U16* explLen );
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
CELL_NONE = 0x00
|
CELL_NONE = 0x00
|
||||||
|
|
|
@ -2189,15 +2189,10 @@ getFirstWord( const XP_UCHAR* word, XP_Bool XP_UNUSED(isLegal),
|
||||||
|
|
||||||
static void
|
static void
|
||||||
scoreLastMove( ModelCtxt* model, MoveInfo* moveInfo, XP_U16 howMany,
|
scoreLastMove( ModelCtxt* model, MoveInfo* moveInfo, XP_U16 howMany,
|
||||||
LastMoveInfo* lmi, XP_UCHAR* buf, XP_U16* bufLen )
|
LastMoveInfo* lmi )
|
||||||
{
|
{
|
||||||
lmi->nTiles = moveInfo->nTiles;
|
lmi->nTiles = moveInfo->nTiles;
|
||||||
if ( moveInfo->nTiles == 0 ) {
|
if ( 0 < moveInfo->nTiles ) {
|
||||||
const XP_UCHAR* str = util_getUserString( model->vol.util, STR_PASSED );
|
|
||||||
XP_U16 len = XP_STRLEN( str );
|
|
||||||
*bufLen = len;
|
|
||||||
XP_STRNCPY( buf, str, len + 1 );
|
|
||||||
} else {
|
|
||||||
XP_U16 score;
|
XP_U16 score;
|
||||||
const XP_UCHAR* format;
|
const XP_UCHAR* format;
|
||||||
WordNotifierInfo notifyInfo;
|
WordNotifierInfo notifyInfo;
|
||||||
|
@ -2222,8 +2217,6 @@ scoreLastMove( ModelCtxt* model, MoveInfo* moveInfo, XP_U16 howMany,
|
||||||
|
|
||||||
model_destroy( tmpModel );
|
model_destroy( tmpModel );
|
||||||
|
|
||||||
format = util_getUserString( model->vol.util, STRSD_SUMMARYSCORED );
|
|
||||||
*bufLen = XP_SNPRINTF( buf, *bufLen, format, data.word, score );
|
|
||||||
lmi->score = score;
|
lmi->score = score;
|
||||||
XP_SNPRINTF( lmi->word, VSIZE(lmi->word), "%s", data.word );
|
XP_SNPRINTF( lmi->word, VSIZE(lmi->word), "%s", data.word );
|
||||||
}
|
}
|
||||||
|
@ -2375,10 +2368,10 @@ model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
XP_Bool
|
XP_Bool
|
||||||
model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
model_getPlayersLastScore( ModelCtxt* model, XP_S16 player, LastMoveInfo* lmi )
|
||||||
LastMoveInfo* lmi,
|
|
||||||
XP_UCHAR* expl, XP_U16* explLen )
|
|
||||||
{
|
{
|
||||||
|
XP_LOGF( "%s(player=%d)", __func__, player );
|
||||||
|
|
||||||
StackCtxt* stack = model->vol.stack;
|
StackCtxt* stack = model->vol.stack;
|
||||||
XP_S16 nEntries, which;
|
XP_S16 nEntries, which;
|
||||||
StackEntry entry;
|
StackEntry entry;
|
||||||
|
@ -2386,39 +2379,36 @@ model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
||||||
XP_MEMSET( lmi, 0, sizeof(*lmi) );
|
XP_MEMSET( lmi, 0, sizeof(*lmi) );
|
||||||
|
|
||||||
XP_ASSERT( !!stack );
|
XP_ASSERT( !!stack );
|
||||||
XP_ASSERT( player >= 0 );
|
|
||||||
|
|
||||||
nEntries = stack_getNEntries( stack );
|
nEntries = stack_getNEntries( stack );
|
||||||
|
|
||||||
for ( which = nEntries; which >= 0; ) {
|
for ( which = nEntries; which >= 0; ) {
|
||||||
if ( stack_getNthEntry( stack, --which, &entry ) ) {
|
if ( stack_getNthEntry( stack, --which, &entry ) ) {
|
||||||
if ( entry.playerNum == player ) {
|
if ( -1 == player || entry.playerNum == player ) {
|
||||||
found = XP_TRUE;
|
found = XP_TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( found ) { /* success? */
|
if ( found ) { /* success? */
|
||||||
const XP_UCHAR* format;
|
XP_ASSERT( -1 == player || player == entry.playerNum );
|
||||||
XP_U16 nTiles;
|
|
||||||
lmi->name = model->vol.gi->players[player].name;
|
XP_LOGF( "%s: found move %d", __func__, which );
|
||||||
|
lmi->name = model->vol.gi->players[entry.playerNum].name;
|
||||||
lmi->moveType = entry.moveType;
|
lmi->moveType = entry.moveType;
|
||||||
|
|
||||||
switch ( entry.moveType ) {
|
switch ( entry.moveType ) {
|
||||||
case MOVE_TYPE:
|
case MOVE_TYPE:
|
||||||
scoreLastMove( model, &entry.u.move.moveInfo,
|
scoreLastMove( model, &entry.u.move.moveInfo, nEntries - which,
|
||||||
nEntries - which, lmi, expl, explLen );
|
lmi );
|
||||||
|
lmi->nTiles = entry.u.move.moveInfo.nTiles;
|
||||||
break;
|
break;
|
||||||
case TRADE_TYPE:
|
case TRADE_TYPE:
|
||||||
nTiles = entry.u.trade.oldTiles.nTiles;
|
|
||||||
lmi->nTiles = entry.u.trade.oldTiles.nTiles;
|
lmi->nTiles = entry.u.trade.oldTiles.nTiles;
|
||||||
format = util_getUserString( model->vol.util, STRD_TRADED );
|
|
||||||
*explLen = XP_SNPRINTF( expl, *explLen, format, nTiles );
|
|
||||||
break;
|
break;
|
||||||
case PHONY_TYPE:
|
case PHONY_TYPE:
|
||||||
format = util_getUserString( model->vol.util, STR_LOSTTURN );
|
|
||||||
*explLen = XP_STRLEN( format );
|
|
||||||
XP_STRCAT( expl, format );
|
|
||||||
break;
|
break;
|
||||||
case ASSIGN_TYPE:
|
case ASSIGN_TYPE:
|
||||||
found = XP_FALSE;
|
found = XP_FALSE;
|
||||||
|
@ -2426,6 +2416,7 @@ model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LOG_RETURNF( "%d", found );
|
||||||
return found;
|
return found;
|
||||||
} /* model_getPlayersLastScore */
|
} /* model_getPlayersLastScore */
|
||||||
|
|
||||||
|
|
|
@ -272,8 +272,7 @@ XP_Bool getCurrentMoveScoreIfLegal( ModelCtxt* model, XP_S16 turn,
|
||||||
XP_S16 model_getPlayerScore( ModelCtxt* model, XP_S16 player );
|
XP_S16 model_getPlayerScore( ModelCtxt* model, XP_S16 player );
|
||||||
|
|
||||||
XP_Bool model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
XP_Bool model_getPlayersLastScore( ModelCtxt* model, XP_S16 player,
|
||||||
LastMoveInfo* info,
|
LastMoveInfo* info );
|
||||||
XP_UCHAR* expl, XP_U16* explLen );
|
|
||||||
#ifdef XWFEATURE_BOARDWORDS
|
#ifdef XWFEATURE_BOARDWORDS
|
||||||
void model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
void model_listWordsThrough( ModelCtxt* model, XP_U16 col, XP_U16 row,
|
||||||
XWStreamCtxt* stream );
|
XWStreamCtxt* stream );
|
||||||
|
|
|
@ -29,13 +29,10 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static XP_Bool
|
static XP_Bool
|
||||||
board_ScoreCallback( void* closure, XP_S16 player,
|
board_ScoreCallback( void* closure, XP_S16 player, LastMoveInfo* lmi )
|
||||||
LastMoveInfo* lmi,
|
|
||||||
XP_UCHAR* expl, XP_U16* explLen)
|
|
||||||
{
|
{
|
||||||
ModelCtxt* model = (ModelCtxt*)closure;
|
ModelCtxt* model = (ModelCtxt*)closure;
|
||||||
return model_getPlayersLastScore( model, player,
|
return model_getPlayersLastScore( model, player, lmi );
|
||||||
lmi, expl, explLen );
|
|
||||||
} /* board_ScoreCallback */
|
} /* board_ScoreCallback */
|
||||||
|
|
||||||
#ifdef XWFEATURE_SCOREONEPASS
|
#ifdef XWFEATURE_SCOREONEPASS
|
||||||
|
|
|
@ -45,11 +45,6 @@ enum {
|
||||||
STR_ROBOT_MOVED,
|
STR_ROBOT_MOVED,
|
||||||
STRS_REMOTE_MOVED,
|
STRS_REMOTE_MOVED,
|
||||||
|
|
||||||
STR_PASSED,
|
|
||||||
STRSD_SUMMARYSCORED,
|
|
||||||
STRD_TRADED,
|
|
||||||
STR_LOSTTURN,
|
|
||||||
|
|
||||||
STR_LOCALPLAYERS,
|
STR_LOCALPLAYERS,
|
||||||
STR_TOTALPLAYERS,
|
STR_TOTALPLAYERS,
|
||||||
STR_REMOTE,
|
STR_REMOTE,
|
||||||
|
|
|
@ -2015,14 +2015,12 @@ gtk_util_playerScoreHeld( XW_UtilCtxt* uc, XP_U16 player )
|
||||||
|
|
||||||
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
GtkGameGlobals* globals = (GtkGameGlobals*)uc->closure;
|
||||||
|
|
||||||
XP_UCHAR scoreExpl[128] = {0};
|
|
||||||
XP_U16 explLen = sizeof(scoreExpl);
|
|
||||||
|
|
||||||
LastMoveInfo lmi;
|
LastMoveInfo lmi;
|
||||||
if ( model_getPlayersLastScore( globals->cGlobals.game.model,
|
if ( model_getPlayersLastScore( globals->cGlobals.game.model,
|
||||||
player, &lmi, scoreExpl, &explLen ) ) {
|
player, &lmi ) ) {
|
||||||
formatLMI( &lmi, scoreExpl, VSIZE(scoreExpl) );
|
XP_UCHAR buf[128];
|
||||||
(void)gtkask( globals->window, scoreExpl, GTK_BUTTONS_OK, NULL );
|
formatLMI( &lmi, buf, VSIZE(buf) );
|
||||||
|
(void)gtkask( globals->window, buf, GTK_BUTTONS_OK, NULL );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -314,15 +314,6 @@ linux_util_getUserString( XW_UtilCtxt* XP_UNUSED(uc), XP_U16 code )
|
||||||
case STRS_REMOTE_MOVED:
|
case STRS_REMOTE_MOVED:
|
||||||
return (XP_UCHAR*)"Remote player \"%s\" moved:\n";
|
return (XP_UCHAR*)"Remote player \"%s\" moved:\n";
|
||||||
|
|
||||||
case STR_PASSED:
|
|
||||||
return (XP_UCHAR*)"Passed";
|
|
||||||
case STRSD_SUMMARYSCORED:
|
|
||||||
return (XP_UCHAR*)"%s:%d";
|
|
||||||
case STRD_TRADED:
|
|
||||||
return (XP_UCHAR*)"Traded %d";
|
|
||||||
case STR_LOSTTURN:
|
|
||||||
return (XP_UCHAR*)"Lost turn";
|
|
||||||
|
|
||||||
#ifndef XWFEATURE_STANDALONE_ONLY
|
#ifndef XWFEATURE_STANDALONE_ONLY
|
||||||
case STR_LOCALPLAYERS:
|
case STR_LOCALPLAYERS:
|
||||||
return (XP_UCHAR*)"Local players";
|
return (XP_UCHAR*)"Local players";
|
||||||
|
|
Loading…
Add table
Reference in a new issue