Files
gSprite-engine/LoadAndSave.pde
Victor Giers 42484711d6 initial commit
2017-06-20 17:25:12 +02:00

48 lines
1.2 KiB
Plaintext

void loadSaveFile() {
File xiz10ciList = new File(dataPath("save.gse"));
if (xiz10ciList.exists()) {
String[] saveData = loadStrings("save.gse");
int entries = int((saveData.length)/7);
for (int i = 0; i < entries; i++) {
int id = int(saveData[i*7]);
String idlePath = saveData[i*7+1];
String actionPath = saveData[i*7+2];
int x_position = int(saveData[i*7+3]);
int y_position = int(saveData[i*7+4]);
float w = float(saveData[i*7+5]);
float h = float(saveData[i*7+6]);
marker[activeMarkers] = new Marker(id, idlePath, actionPath, x_position, y_position, w, h);
activeMarkers++;
}
}
}
FileWriter output = null;
void save_gse() {
File saveFile = new File(saveFilePath);
if (saveFile.exists()) {
saveFile.delete();
};
try {
output = new FileWriter(saveFilePath, true);
for (int i = 0; i < activeMarkers; i++) {
marker[i].saveToFile();
if (!(i == activeMarkers - 1)) {
}
}
}
catch (IOException e) {
println("It Broke");
e.printStackTrace();
}
finally {
if (output != null) {
try {
output.close();
}
catch (IOException e) {
println("Error while closing the writer");
}
}
}
}