display three states of relay connectedness in games list items:

configured, connected but waiting for players, and game-in-play.
This commit is contained in:
Andy2 2011-08-22 07:03:46 -07:00
parent 1ee0dfdd6d
commit d7a515ca97
2 changed files with 27 additions and 3 deletions

View file

@ -365,7 +365,11 @@
check off-device players.</string>
<string name="forced_consistent">Modified first player.</string>
<string name="summary_fmt_relay">Connecting via Relay, room \"%s\"</string>
<string name="summary_relay_conff">Configured for room
\"%s\"</string>
<string name="summary_relay_waitf">Waiting for players in room
\"%s\"</string>
<string name="summary_relay_connf">Game in play in room \"%s\"</string>
<string name="gameOver">Game over</string>
<string name="movesf">%d moves played</string>

View file

@ -118,10 +118,18 @@ public class GameSummary {
{
String result = null;
if ( isRelayGame() ) {
Assert.assertTrue( CommsAddrRec.CommsConnType.COMMS_CONN_RELAY
== conType );
String fmt = m_context.getString( R.string.summary_fmt_relay );
result = String.format( fmt, roomName );
int fmtID;
if ( null == relayID || 0 == relayID.length() ) {
fmtID = R.string.summary_relay_conff;
} else if ( anyMissing() ) {
fmtID = R.string.summary_relay_waitf;
} else {
fmtID = R.string.summary_relay_connf;
}
result = String.format( m_context.getString(fmtID), roomName );
}
return result;
}
@ -144,6 +152,18 @@ public class GameSummary {
return result;
}
private boolean anyMissing()
{
boolean missing = false;
for ( int ii = 0; ii < nPlayers; ++ii ) {
if ( !isLocal(ii) && (0 != ((1 << ii) & missingPlayers) ) ) {
missing = true;
break;
}
}
return missing;
}
public int giflags() {
int result;
if ( null == m_gi ) {