DroidFish: Added game numbers to the game list when loading/saving from PGN files and when loading from a Scid database.

This commit is contained in:
Peter Osterlund 2012-12-28 11:23:39 +00:00
parent dedb66beca
commit ee494c50f6
2 changed files with 14 additions and 2 deletions

View File

@ -52,7 +52,11 @@ public class LoadScid extends ListActivity {
String summary = "";
int gameId = -1;
public String toString() {
return summary;
StringBuilder sb = new StringBuilder(128);
sb.append(gameId+1);
sb.append(". ");
sb.append(summary);
return sb.toString();
}
}

View File

@ -145,6 +145,7 @@ public class PGNFile {
}
private final static class HeaderInfo {
int gameNo;
String event = "";
String site = "";
String date = "";
@ -152,9 +153,15 @@ public class PGNFile {
String white = "";
String black = "";
String result = "";
HeaderInfo(int gameNo) {
this.gameNo = gameNo;
}
public String toString() {
StringBuilder info = new StringBuilder(128);
info.append(gameNo);
info.append(". ");
info.append(white);
info.append(" - ");
info.append(black);
@ -201,6 +208,7 @@ public class PGNFile {
HeaderInfo hi = null;
boolean inHeader = false;
long filePos = 0;
int gameNo = 1;
while (true) {
filePos = f.getFilePointer();
String line = f.readLine();
@ -238,7 +246,7 @@ public class PGNFile {
gi = new GameInfo();
gi.startPos = filePos;
gi.endPos = -1;
hi = new HeaderInfo();
hi = new HeaderInfo(gameNo++);
}
if (line.startsWith("[Event ")) {
if (len >= 10) {