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