Exemple #1
0
  public void update() {
    if (getCurrentSubMenu() != null) {
      getCurrentSubMenu().update();
    } else {
      if (Game.getGlobal().getGame().isPaused()) {
        if (Gdx.input.isKeyJustPressed(Keys.ESCAPE) || Gdx.input.isKeyJustPressed(Keys.P)) {
          Game.getGlobal().getGame().setPaused(false);
        }
      } else {
        if (Gdx.input.isKeyJustPressed(Keys.P) || Gdx.input.isKeyJustPressed(Keys.ESCAPE)) {
          Game.getGlobal().getGame().setPaused(true);
          this.setCurrentSubMenu(this.getSubMenuByName("pause"));
        }

        selectTile();
        updateDebugTooltip();
        checkSave();
        checkLoad();
        saveGame();
        loadGame();
        super.updateButtonHover();
        updateCreateCharacterButton();
      }
    }
  }
Exemple #2
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);
   }
 }
Exemple #3
0
 public void updateDebugTooltip() {
   if (Game.getGlobal().getCurrentMenu().getName().equals("game")) {
     Ent debugTooltip = Game.getGlobal().getCurrentMenu().getEntByName("debugTooltip");
     String debugText = "";
     debugText += "\nFPS: " + Gdx.graphics.getFramesPerSecond();
     debugText += "\nCamX: " + Game.getGlobal().getCamera().position.x;
     debugText += "\nCamY: " + Game.getGlobal().getCamera().position.y;
     debugText += "\nTileSize: " + Game.getGlobal().getGame().getWorld().getTileSize();
     debugText +=
         "\nWorldSize: "
             + Game.getGlobal().getGame().getWorld().getWidth()
             + ","
             + Game.getGlobal().getGame().getWorld().getHeight();
     debugText += "\nWorldZoom: " + Game.getGlobal().getCamera().zoom;
     debugTooltip.setText(debugText);
   }
 }
Exemple #4
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) {

      }
    }
  }