From 35e4c21f17f572980b66924020f3780ea40b35fd Mon Sep 17 00:00:00 2001 From: Andy2 Date: Sun, 2 Oct 2011 16:42:10 -0700 Subject: [PATCH] add util_informMove to jni. Use it, but not to advantage yet. --- xwords4/android/XWords4/jni/utilwrapper.c | 14 ++++++++++++++ .../src/org/eehouse/android/xw4/BoardActivity.java | 11 ++++++++--- .../src/org/eehouse/android/xw4/jni/UtilCtxt.java | 5 +++-- .../org/eehouse/android/xw4/jni/UtilCtxtImpl.java | 5 +++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/xwords4/android/XWords4/jni/utilwrapper.c b/xwords4/android/XWords4/jni/utilwrapper.c index 396e78122..047f71928 100644 --- a/xwords4/android/XWords4/jni/utilwrapper.c +++ b/xwords4/android/XWords4/jni/utilwrapper.c @@ -215,6 +215,19 @@ and_util_turnChanged(XW_UtilCtxt* uc) } #endif +static void +and_util_informMove( XW_UtilCtxt* uc, XWStreamCtxt* expl, + XWStreamCtxt* words, XP_U16 wordCount ) +{ + UTIL_CBK_HEADER( "informMove", "(Ljava/lang/String;Ljava/lang/String;I)V" ); + jstring jexpl = streamToJString( MPPARM(util->util.mpool) env, expl ); + jstring jwords = streamToJString( MPPARM(util->util.mpool) env, words ); + (*env)->CallVoidMethod( env, util->jutil, mid, jexpl, jwords, wordCount ); + (*env)->DeleteLocalRef( env, jexpl ); + (*env)->DeleteLocalRef( env, jwords ); + UTIL_CBK_TAIL(); +} + static void and_util_notifyGameOver( XW_UtilCtxt* uc ) { @@ -476,6 +489,7 @@ makeUtil( MPFORMAL JNIEnv** envp, jobject jutil, CurGameInfo* gi, #ifdef XWFEATURE_TURNCHANGENOTIFY SET_PROC( turnChanged); #endif + SET_PROC(informMove); SET_PROC(notifyGameOver); SET_PROC(hiliteCell); SET_PROC(engineProgressCallback); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java index d09189f0c..76b4a45cd 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/BoardActivity.java @@ -1128,12 +1128,10 @@ public class BoardActivity extends XWActivity // if the player after this one is also a robot and we // don't block then a second dialog will replace this one. // So block. Yuck. - case UtilCtxt.QUERY_ROBOT_MOVE: case UtilCtxt.QUERY_ROBOT_TRADE: m_dlgBytes = query; m_dlgTitle = R.string.info_title; - waitBlockingDialog( QUERY_ROBOT_MOVE == id ? - DLG_SCORES_BLK : QUERY_INFORM_BLK, 0 ); + waitBlockingDialog( QUERY_INFORM_BLK, 0 ); result = true; break; @@ -1211,6 +1209,13 @@ public class BoardActivity extends XWActivity } } // userError + public void informMove( String expl, String words, int wordCount ) + { + m_dlgBytes = expl; + m_dlgTitle = R.string.info_title; + waitBlockingDialog( DLG_SCORES_BLK, 0 ); + } + public void notifyGameOver() { m_jniThread.handle( JNIThread.JNICmd.CMD_POST_OVER ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java index b890bb5a7..630622c30 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxt.java @@ -76,8 +76,7 @@ public interface UtilCtxt { static final int QUERY_COMMIT_TURN = 0; static final int QUERY_COMMIT_TRADE = 1; - static final int QUERY_ROBOT_MOVE = 2; - static final int QUERY_ROBOT_TRADE = 3; + static final int QUERY_ROBOT_TRADE = 2; boolean userQuery( int id, String query ); @@ -101,6 +100,8 @@ public interface UtilCtxt { static final int ERR_RELAY_BASE = 16; void userError( int id ); + void informMove( String expl, String words, int wordCount ); + void notifyGameOver(); // Don't need this unless we have a scroll thumb to indicate position //void yOffsetChange( int maxOffset, int oldOffset, int newOffset ); diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java index 3654e082f..ad950d522 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/jni/UtilCtxtImpl.java @@ -185,6 +185,11 @@ public class UtilCtxtImpl implements UtilCtxt { subclassOverride( "userError" ); } + public void informMove( String expl, String words, int wordCount ) + { + subclassOverride( "informMove" ); + } + // Probably want to cache the fact that the game over notification // showed up and then display it next time game's opened. public void notifyGameOver()