Added facility to save and read DetailedInfo (DataRecorder data) in XML format using XStream.

This commit is contained in:
Woody Folsom
2012-03-16 15:54:45 -04:00
parent 0ac74b3297
commit 47520126ff
5 changed files with 62 additions and 13 deletions

View File

@@ -2,6 +2,7 @@ package dk.itu.mario.scene;
import java.awt.GraphicsConfiguration;
import java.io.DataInputStream;
import java.io.File;
import java.io.IOException;
import dk.itu.mario.MarioInterface.GamePlay;
@@ -48,8 +49,18 @@ public class LevelSceneCustom extends LevelScene {
currentLevel = (Level) clg.generateLevel(gp);
String detailedInfo = FileHandler.readFile("DetailedInfo.txt");
//TODO parse DetailedInfo
System.out.println("DetailedInfo: " + detailedInfo);
File xmlInfoFile = new File("DetailedInfo.xml");
if (xmlInfoFile.exists()) {
try {
DataRecorder dataRecorder = DataRecorder.fromXML(xmlInfoFile);
System.out.println("DetailedInfo (from xml file): " + detailedInfo);
} catch (IOException ioe) {
ioe.printStackTrace();
}
} else {
System.out.println("DetailedInfo (from txt file): " + detailedInfo);
}
try {
level = currentLevel.clone();
@@ -57,7 +68,7 @@ public class LevelSceneCustom extends LevelScene {
e.printStackTrace();
}
//TODO change this
// TODO change this
// level is always overground
Art.startMusic(2);