Пример #1
0
 public void checkSave() {
   if (saving
       && saveGameName != null
       && saveGameName.getText() != null
       && saveGameName.getText() != "") {
     saving = false;
     String gameName = saveGameName.getText();
     saveGameName = null;
     String xmlOutput = Game.getGlobal().getGame().getWorld().save(gameName);
     FileHandle saveFile = Gdx.files.external("DND/saveData/" + gameName + ".xml");
     if (xmlOutput == null) xmlOutput = "";
     saveFile.writeString(xmlOutput, false);
   }
 }
Пример #2
0
  public void checkLoad() {
    if (loading
        && loadGameName != null
        && loadGameName.getText() != null
        && loadGameName.getText() != "") {
      loading = false;
      String gameName = loadGameName.getText();
      loadGameName = null;
      FileHandle loadFile = Gdx.files.external("DND/saveData/" + gameName + ".xml");
      try {
        String xmlData = loadFile.readString();
        xmlData = xmlData.replace("\n", "");
        xmlData = xmlData.replace("\r", "");
        Game.getGlobal().getGame().getWorld().load(gameName, xmlData);
      } catch (Exception ex) {

      }
    }
  }