private int setupD;
private int rounds;
private int roundD;
+ private int gameIx;
private long endT = 0; // NTP seconds for game end (if >= startT)
public void fromMqttConfigMessage(String st) {
default:
try {
Scanner s = new Scanner(tm);
- this.startT = s.nextLong();
+ this.startT = s.nextLong();
this.setupD = s.nextInt();
this.rounds = s.nextInt();
this.roundD = s.nextInt();
this.flagsTotal = s.nextInt();
+ this.gameIx = s.nextInt();
this.configured = true;
} catch (NoSuchElementException e) {
this.configured = false;
public boolean isConfigured(){
return configured;
}
+ public int getGameIx() { return gameIx; }
public long getStartT() { return startT; }
public long getFirstRoundStartT() { return startT + setupD; }
public int getRounds() { return rounds; }
// TODO nwf is bad at UI design; someone who isn't him should improve this
class CtFwSDisplayLocal implements CtFwSGameState.Observer {
final private Activity mAct;
- final private Handler mHandler;
+ public String gameStateLabelText;
- CtFwSDisplayLocal(Activity a, Handler h) {
+ CtFwSDisplayLocal(Activity a) {
mAct = a;
- mHandler = h;
+ gameStateLabelText = mAct.getResources().getString(R.string.header_gamestate0);
}
private Runnable mProber;
+
@Override
public void onCtFwSConfigure(final CtFwSGameState gs) {
+ int gameix = gs.getGameIx();
+ gameStateLabelText =
+ (gs.isConfigured() && gameix != 0)
+ ?
+ String.format(
+ mAct.getResources()
+ .getString(R.string.header_gamestateN),
+ gameix)
+ : mAct.getResources().getString(R.string.header_gamestate0);
+
+
+ final TextView gstv = (TextView) mAct.findViewById(R.id.header_gamestate);
+ gstv.post(new Runnable() {
+ @Override
+ public void run() {
+ gstv.setText(gameStateLabelText);
+ }
+ });
}
@Override
} else {
tv_jb.setText(
String.format(mAct.getResources().getString(R.string.ctfws_jailbreak),
- now.round, gs.getRounds() - 1));
+ now.round, gs.getRounds() - 1));
}
}
});
@Override
public void run() {
pb_jb.setIndeterminate(false);
- pb_jb.setMax((int)(now.roundEnd - now.roundStart));
+ pb_jb.setMax((int) (now.roundEnd - now.roundStart));
pb_jb.setProgress(0);
}
});
ch_jb.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer c) {
- pb_jb.setProgress((int)(now.roundEnd - System.currentTimeMillis()/1000));
+ pb_jb.setProgress((int) (now.roundEnd - System.currentTimeMillis() / 1000));
}
});
ch_jb.start();
}
});
}
- if (now.round > 0){
+ if (now.round > 0) {
final ProgressBar pb_gp = (ProgressBar) (mAct.findViewById(R.id.pb_gameProgress));
pb_gp.post(new Runnable() {
@Override
ch_gp.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer c) {
- pb_gp.setProgress((int)(System.currentTimeMillis()/1000
+ pb_gp.setProgress((int) (System.currentTimeMillis() / 1000
- gs.getFirstRoundStartT()));
}
});
public void run() {
ch.stop();
ch.setVisibility(View.INVISIBLE);
- }});
+ }
+ });
}
{
final ProgressBar pb = (ProgressBar) (mAct.findViewById(R.id.pb_jailbreak));
}
}
- final TextView msgs = (TextView)(mAct.findViewById(R.id.tv_flags));
+ final TextView msgs = (TextView) (mAct.findViewById(R.id.tv_flags));
msgs.post(new Runnable() {
@Override
public void run() {
@Override
public void onCtFwSMessage(CtFwSGameState gs, List<CtFwSGameState.Msg> msgs) {
- final TextView msgstv = (TextView)(mAct.findViewById(R.id.msgs));
+ final TextView msgstv = (TextView) (mAct.findViewById(R.id.msgs));
int s = msgs.size();
if (s == 0) {
});
}
}
-}
+}
\ No newline at end of file
mTvSU = (TextView) findViewById(R.id.tv_mqtt_server_uri);
mTvSS = (TextView) findViewById(R.id.tv_mqtt_state);
- mCdl = new CtFwSDisplayLocal(this, new Handler());
+ mCdl = new CtFwSDisplayLocal(this);
}
private ServiceConnection ctfwssc = new ServiceConnection() {
tv.setText("DO NOT TAP ON GLASS");
tv.postDelayed(new Runnable() {
public void run() {
- tv.setText(R.string.header_gamestate);
+ if (mCdl != null) {
+ tv.setText(mCdl.gameStateLabelText);
+ } else {
+ tv.setText(R.string.header_gamestate0);
+ }
egg = false;
}
}, 3000);