32 lines
760 B
Plaintext
32 lines
760 B
Plaintext
// DONE File loading and Saving
|
|
// TODO Math for best_game_time
|
|
|
|
class Files {
|
|
|
|
boolean checkSaveFile(String filepath) {
|
|
return new File(dataPath(filepath)).exists();
|
|
}
|
|
|
|
void loadJson(String jsonfile) {
|
|
if (!checkSaveFile(jsonfile)) {
|
|
JSONArray values = loadJSONArray(jsonfile);
|
|
|
|
stats_menu.best_game_time = values.getInt(0);
|
|
stats_menu.trees_sawed = values.getInt(1);
|
|
stats_menu.game_time = values.getInt(2);
|
|
|
|
}
|
|
}
|
|
|
|
JSONArray json;
|
|
void savetofile(String filename) {
|
|
json = new JSONArray();
|
|
|
|
json.setInt(0, stats_menu.best_game_time);
|
|
json.setInt(1, stats_menu.trees_sawed);
|
|
json.setInt(2, millis() + stats_menu.game_time);
|
|
saveJSONArray(json,"./saves/" + filename + ".json");
|
|
}
|
|
|
|
}
|