mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-02-01 19:57:11 +01:00
pass dict with bt invite and otherwise catch up with how invites work.
Can now invite and play a game.
This commit is contained in:
parent
5fb2d9c82a
commit
be28630109
4 changed files with 27 additions and 15 deletions
|
@ -73,6 +73,7 @@ public class BTService extends XWService {
|
||||||
private static final String GAMEID_STR = "GMI";
|
private static final String GAMEID_STR = "GMI";
|
||||||
|
|
||||||
private static final String LANG_STR = "LNG";
|
private static final String LANG_STR = "LNG";
|
||||||
|
private static final String DICT_STR = "DCT";
|
||||||
private static final String NTO_STR = "TOT";
|
private static final String NTO_STR = "TOT";
|
||||||
private static final String NHE_STR = "HER";
|
private static final String NHE_STR = "HER";
|
||||||
|
|
||||||
|
@ -102,16 +103,17 @@ public class BTService extends XWService {
|
||||||
String m_gameName;
|
String m_gameName;
|
||||||
int m_gameID;
|
int m_gameID;
|
||||||
int m_lang;
|
int m_lang;
|
||||||
|
String m_dict;
|
||||||
int m_nPlayersT;
|
int m_nPlayersT;
|
||||||
int m_nPlayersH;
|
int m_nPlayersH;
|
||||||
|
|
||||||
public BTQueueElem( BTCmd cmd ) { m_cmd = cmd; m_failCount = 0; }
|
public BTQueueElem( BTCmd cmd ) { m_cmd = cmd; m_failCount = 0; }
|
||||||
public BTQueueElem( BTCmd cmd, String targetName, String targetAddr,
|
public BTQueueElem( BTCmd cmd, String targetName, String targetAddr,
|
||||||
int gameID, String gameName, int lang,
|
int gameID, String gameName, int lang,
|
||||||
int nPlayersT, int nPlayersH ) {
|
String dict, int nPlayersT, int nPlayersH ) {
|
||||||
this( cmd, null, targetName, targetAddr, gameID );
|
this( cmd, null, targetName, targetAddr, gameID );
|
||||||
m_lang = lang; m_nPlayersT = nPlayersT; m_nPlayersH = nPlayersH;
|
m_lang = lang; m_dict = dict; m_nPlayersT = nPlayersT;
|
||||||
m_gameName = gameName;
|
m_nPlayersH = nPlayersH; m_gameName = gameName;
|
||||||
}
|
}
|
||||||
public BTQueueElem( BTCmd cmd, byte[] buf, String targetName,
|
public BTQueueElem( BTCmd cmd, byte[] buf, String targetName,
|
||||||
String targetAddr, int gameID ) {
|
String targetAddr, int gameID ) {
|
||||||
|
@ -166,7 +168,7 @@ public class BTService extends XWService {
|
||||||
|
|
||||||
public static void inviteRemote( Context context, String hostName,
|
public static void inviteRemote( Context context, String hostName,
|
||||||
int gameID, String initialName,
|
int gameID, String initialName,
|
||||||
int lang, int nPlayersT,
|
int lang, String dict, int nPlayersT,
|
||||||
int nPlayersH )
|
int nPlayersH )
|
||||||
{
|
{
|
||||||
Intent intent = getIntentTo( context, INVITE );
|
Intent intent = getIntentTo( context, INVITE );
|
||||||
|
@ -175,6 +177,7 @@ public class BTService extends XWService {
|
||||||
Assert.assertNotNull( initialName );
|
Assert.assertNotNull( initialName );
|
||||||
intent.putExtra( GAMENAME_STR, initialName );
|
intent.putExtra( GAMENAME_STR, initialName );
|
||||||
intent.putExtra( LANG_STR, lang );
|
intent.putExtra( LANG_STR, lang );
|
||||||
|
intent.putExtra( DICT_STR, dict );
|
||||||
intent.putExtra( NTO_STR, nPlayersT );
|
intent.putExtra( NTO_STR, nPlayersT );
|
||||||
intent.putExtra( NHE_STR, nPlayersH );
|
intent.putExtra( NHE_STR, nPlayersH );
|
||||||
|
|
||||||
|
@ -258,11 +261,12 @@ public class BTService extends XWService {
|
||||||
String gameName = intent.getStringExtra( GAMENAME_STR );
|
String gameName = intent.getStringExtra( GAMENAME_STR );
|
||||||
String addr = addrFor( target );
|
String addr = addrFor( target );
|
||||||
int lang = intent.getIntExtra( LANG_STR, -1 );
|
int lang = intent.getIntExtra( LANG_STR, -1 );
|
||||||
|
String dict = intent.getStringExtra( DICT_STR );
|
||||||
int nPlayersT = intent.getIntExtra( NTO_STR, -1 );
|
int nPlayersT = intent.getIntExtra( NTO_STR, -1 );
|
||||||
int nPlayersH = intent.getIntExtra( NHE_STR, -1 );
|
int nPlayersH = intent.getIntExtra( NHE_STR, -1 );
|
||||||
m_sender.add( new BTQueueElem( BTCmd.INVITE, target, addr,
|
m_sender.add( new BTQueueElem( BTCmd.INVITE, target, addr,
|
||||||
gameID, gameName, lang,
|
gameID, gameName, lang,
|
||||||
nPlayersT, nPlayersH ) );
|
dict, nPlayersT, nPlayersH ) );
|
||||||
break;
|
break;
|
||||||
case SEND:
|
case SEND:
|
||||||
byte[] buf = intent.getByteArrayExtra( MSG_STR );
|
byte[] buf = intent.getByteArrayExtra( MSG_STR );
|
||||||
|
@ -404,6 +408,7 @@ public class BTService extends XWService {
|
||||||
int gameID = is.readInt();
|
int gameID = is.readInt();
|
||||||
String gameName = is.readUTF();
|
String gameName = is.readUTF();
|
||||||
int lang = is.readInt();
|
int lang = is.readInt();
|
||||||
|
String dict = is.readUTF();
|
||||||
int nPlayersT = is.readInt();
|
int nPlayersT = is.readInt();
|
||||||
int nPlayersH = is.readInt();
|
int nPlayersH = is.readInt();
|
||||||
|
|
||||||
|
@ -415,7 +420,8 @@ public class BTService extends XWService {
|
||||||
String sender = host.getName();
|
String sender = host.getName();
|
||||||
CommsAddrRec addr = new CommsAddrRec( sender, host.getAddress() );
|
CommsAddrRec addr = new CommsAddrRec( sender, host.getAddress() );
|
||||||
long rowid = GameUtils.makeNewBTGame( context, gameID, addr,
|
long rowid = GameUtils.makeNewBTGame( context, gameID, addr,
|
||||||
lang, nPlayersT, nPlayersH );
|
lang, dict, nPlayersT,
|
||||||
|
nPlayersH );
|
||||||
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
if ( DBUtils.ROWID_NOTFOUND == rowid ) {
|
||||||
result = BTCmd.INVITE_FAILED;
|
result = BTCmd.INVITE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
|
@ -680,6 +686,7 @@ public class BTService extends XWService {
|
||||||
outStream.writeInt( elem.m_gameID );
|
outStream.writeInt( elem.m_gameID );
|
||||||
outStream.writeUTF( elem.m_gameName );
|
outStream.writeUTF( elem.m_gameName );
|
||||||
outStream.writeInt( elem.m_lang );
|
outStream.writeInt( elem.m_lang );
|
||||||
|
outStream.writeUTF( elem.m_dict );
|
||||||
outStream.writeInt( elem.m_nPlayersT );
|
outStream.writeInt( elem.m_nPlayersT );
|
||||||
outStream.writeInt( elem.m_nPlayersH );
|
outStream.writeInt( elem.m_nPlayersH );
|
||||||
outStream.flush();
|
outStream.flush();
|
||||||
|
|
|
@ -2161,7 +2161,8 @@ public class BoardActivity extends XWActivity
|
||||||
case COMMS_CONN_BT:
|
case COMMS_CONN_BT:
|
||||||
BTService.inviteRemote( this, dev, m_gi.gameID,
|
BTService.inviteRemote( this, dev, m_gi.gameID,
|
||||||
gameName, m_gi.dictLang,
|
gameName, m_gi.dictLang,
|
||||||
m_gi.nPlayers, 1 );
|
m_gi.dictName, m_gi.nPlayers,
|
||||||
|
1 );
|
||||||
break;
|
break;
|
||||||
case COMMS_CONN_SMS:
|
case COMMS_CONN_SMS:
|
||||||
SMSService.inviteRemote( this, dev, m_gi.gameID,
|
SMSService.inviteRemote( this, dev, m_gi.gameID,
|
||||||
|
|
|
@ -479,24 +479,28 @@ public class GameUtils {
|
||||||
|
|
||||||
public static long makeNewBTGame( Context context, int gameID,
|
public static long makeNewBTGame( Context context, int gameID,
|
||||||
CommsAddrRec addr, int lang,
|
CommsAddrRec addr, int lang,
|
||||||
int nPlayersT, int nPlayersH )
|
String dict, int nPlayersT,
|
||||||
|
int nPlayersH )
|
||||||
{
|
{
|
||||||
return makeNewBTGame( context, DBUtils.GROUPID_UNSPEC, gameID, addr,
|
return makeNewBTGame( context, DBUtils.GROUPID_UNSPEC, gameID, addr,
|
||||||
lang, nPlayersT, nPlayersH );
|
lang, dict, nPlayersT, nPlayersH );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeNewBTGame( Context context, long groupID,
|
public static long makeNewBTGame( Context context, long groupID,
|
||||||
int gameID, CommsAddrRec addr, int lang,
|
int gameID, CommsAddrRec addr, int lang,
|
||||||
int nPlayersT, int nPlayersH )
|
String dict, int nPlayersT, int nPlayersH )
|
||||||
{
|
{
|
||||||
long rowid = -1;
|
long rowid = -1;
|
||||||
int[] langa = { lang };
|
int[] langa = { lang };
|
||||||
|
String[] dicta = { dict };
|
||||||
boolean isHost = null == addr;
|
boolean isHost = null == addr;
|
||||||
if ( isHost ) {
|
if ( isHost ) {
|
||||||
addr = new CommsAddrRec( null, null );
|
addr = new CommsAddrRec( null, null );
|
||||||
}
|
}
|
||||||
return makeNewMultiGame( context, groupID, addr, langa, null,
|
String inviteID = GameUtils.formatGameID( gameID );
|
||||||
nPlayersT, nPlayersH, null, gameID, isHost );
|
return makeNewMultiGame( context, groupID, addr, langa, dicta,
|
||||||
|
nPlayersT, nPlayersH, inviteID, gameID,
|
||||||
|
isHost );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static long makeNewSMSGame( Context context, int gameID,
|
public static long makeNewSMSGame( Context context, int gameID,
|
||||||
|
|
|
@ -230,7 +230,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
if ( m_nameForBT ) {
|
if ( m_nameForBT ) {
|
||||||
BTService.inviteRemote( thiz, m_remoteDev,
|
BTService.inviteRemote( thiz, m_remoteDev,
|
||||||
m_gameID, m_gameName,
|
m_gameID, m_gameName,
|
||||||
m_lang, 2, 1 );
|
m_lang, m_dict, 2, 1 );
|
||||||
startProgress( R.string.invite_progress );
|
startProgress( R.string.invite_progress );
|
||||||
} else {
|
} else {
|
||||||
SMSService.inviteRemote( thiz, m_remoteDev,
|
SMSService.inviteRemote( thiz, m_remoteDev,
|
||||||
|
@ -294,7 +294,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
long rowid =
|
long rowid =
|
||||||
GameUtils.makeNewBTGame( NewGameActivity.this,
|
GameUtils.makeNewBTGame( NewGameActivity.this,
|
||||||
m_groupID, gameID, null,
|
m_groupID, gameID, null,
|
||||||
m_lang, 2, 1 );
|
m_lang, m_dict, 2, 1 );
|
||||||
DBUtils.setName( NewGameActivity.this,
|
DBUtils.setName( NewGameActivity.this,
|
||||||
rowid, m_gameName );
|
rowid, m_gameName );
|
||||||
GameUtils.launchGame( NewGameActivity.this,
|
GameUtils.launchGame( NewGameActivity.this,
|
||||||
|
@ -365,7 +365,7 @@ public class NewGameActivity extends XWActivity {
|
||||||
if ( !useDefaults ) {
|
if ( !useDefaults ) {
|
||||||
m_newRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
|
m_newRowID = GameUtils.makeNewBTGame( NewGameActivity.this,
|
||||||
m_groupID, gameID, null,
|
m_groupID, gameID, null,
|
||||||
m_lang, 2, 1 );
|
m_lang, m_dict, 2, 1 );
|
||||||
Intent intent = new Intent( this, GameConfig.class );
|
Intent intent = new Intent( this, GameConfig.class );
|
||||||
intent.setAction( Intent.ACTION_EDIT );
|
intent.setAction( Intent.ACTION_EDIT );
|
||||||
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );
|
intent.putExtra( GameUtils.INTENT_KEY_ROWID, m_newRowID );
|
||||||
|
|
Loading…
Add table
Reference in a new issue