DroidFish: Show current time control in the extended title bar.

This commit is contained in:
Peter Osterlund
2013-04-14 08:04:13 +00:00
parent ba7d8f61eb
commit 8ef8fbe3cd
4 changed files with 18 additions and 7 deletions

View File

@@ -137,7 +137,6 @@ public class DroidFish extends Activity implements GUIInterface {
// FIXME!!! Computer clock should stop if phone turned off (computer stops thinking if unplugged) // FIXME!!! Computer clock should stop if phone turned off (computer stops thinking if unplugged)
// FIXME!!! Add support for all time controls defined by the PGN standard // FIXME!!! Add support for all time controls defined by the PGN standard
// FIXME!!! How to handle hour-glass time control? // FIXME!!! How to handle hour-glass time control?
// FIXME!!! What should happen if you change time controls in the middle of a game?
// FIXME!!! Online play on FICS // FIXME!!! Online play on FICS
// FIXME!!! Add chess960 support // FIXME!!! Add chess960 support
@@ -152,7 +151,7 @@ public class DroidFish extends Activity implements GUIInterface {
// FIXME!!! Better behavior if engine is terminated. How exactly? // FIXME!!! Better behavior if engine is terminated. How exactly?
// FIXME!!! Handle PGN non-file intents with more than one game. // FIXME!!! Handle PGN non-file intents with more than one game.
// FIXME!!! File load/save of FEN data // FIXME!!! Save position to fen/epd file
// FIXME!!! Strength setting for external engines // FIXME!!! Strength setting for external engines
// FIXME!!! Selection dialog for going into variation // FIXME!!! Selection dialog for going into variation
@@ -894,7 +893,7 @@ public class DroidFish extends Activity implements GUIInterface {
int movesPerSession = getIntSetting("movesPerSession", 60); int movesPerSession = getIntSetting("movesPerSession", 60);
int timeIncrement = getIntSetting("timeIncrement", 0); int timeIncrement = getIntSetting("timeIncrement", 0);
ctrl.setTimeLimit(timeControl, movesPerSession, timeIncrement); ctrl.setTimeLimit(timeControl, movesPerSession, timeIncrement);
setSummaryTitle(); updateTimeControlTitle();
boardGestures = settings.getBoolean("boardGestures", true); boardGestures = settings.getBoolean("boardGestures", true);
scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2")); scrollSensitivity = Float.parseFloat(settings.getString("scrollSensitivity", "2"));
@@ -1087,7 +1086,7 @@ public class DroidFish extends Activity implements GUIInterface {
} }
/** Update center field in second header line. */ /** Update center field in second header line. */
private final void setSummaryTitle() { public final void updateTimeControlTitle() {
int[] tmpInfo = ctrl.getTimeLimit(); int[] tmpInfo = ctrl.getTimeLimit();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int tc = tmpInfo[0]; int tc = tmpInfo[0];

View File

@@ -83,6 +83,9 @@ public interface GUIInterface {
/** Update title with the material difference. */ /** Update title with the material difference. */
public void updateMaterialDifferenceTitle(Util.MaterialDiff diff); public void updateMaterialDifferenceTitle(Util.MaterialDiff diff);
/** Update title with time control information. */
public void updateTimeControlTitle();
/** Report a move made that is a candidate for GUI animation. */ /** Report a move made that is a candidate for GUI animation. */
public void setAnimMove(Position sourcePos, Move move, boolean forward); public void setAnimMove(Position sourcePos, Move move, boolean forward);

View File

@@ -112,10 +112,10 @@ public class DroidChessController {
game.timeController.setTimeControl(timeControl, movesPerSession, timeIncrement); game.timeController.setTimeControl(timeControl, movesPerSession, timeIncrement);
} }
/** /** @return Array containing time control, moves per session and time increment. */
* @return Array containing time control, moves per session and time increment.
*/
public final int[] getTimeLimit() { public final int[] getTimeLimit() {
if (game != null)
return game.timeController.getTimeLimit(game.currPos().whiteMove);
int[] ret = new int[3]; int[] ret = new int[3];
ret[0] = timeControl; ret[0] = timeControl;
ret[1] = movesPerSession; ret[1] = movesPerSession;
@@ -1036,6 +1036,7 @@ public class DroidChessController {
updateRemainingTime(); updateRemainingTime();
updateMaterialDiffList(); updateMaterialDiffList();
gui.updateTimeControlTitle();
} }
public final void updateMaterialDiffList() { public final void updateMaterialDiffList() {

View File

@@ -157,6 +157,14 @@ public class TimeControl {
return getCurrentTC(whiteMove).second; return getCurrentTC(whiteMove).second;
} }
/** @return Array containing time control, moves per session and time increment. */
public int[] getTimeLimit(boolean whiteMove) {
ArrayList<TimeControlField> tc = whiteMove ? tcW : tcB;
int tcIdx = getCurrentTC(whiteMove).first;
TimeControlField t = tc.get(tcIdx);
return new int[]{(int)t.timeControl, t.movesPerSession, (int)t.increment};
}
/** Return the current active time control index and number of moves to next time control. */ /** Return the current active time control index and number of moves to next time control. */
private Pair<Integer,Integer> getCurrentTC(boolean whiteMove) { private Pair<Integer,Integer> getCurrentTC(boolean whiteMove) {
ArrayList<TimeControlField> tc = whiteMove ? tcW : tcB; ArrayList<TimeControlField> tc = whiteMove ? tcW : tcB;