Esempio n. 1
0
  /** Saves the current resource. */
  public void save() {

    try {
      tileset.save();
    } catch (QuestEditorException ex) {
      GuiTools.errorDialog("Could not save the tileset: " + ex.getMessage());
    }
  }
Esempio n. 2
0
  /** Closes this editor without confirmation. */
  @Override
  public void close() {
    tileset.deleteObservers();

    // Notify the children views.
    tilePatternsView.setTileset(null);
    tilesetImageView.setTileset(null);
  }
Esempio n. 3
0
  /**
   * This function is called when the user wants to close the current tileset. If the tileset is not
   * saved, we propose to save it.
   *
   * @return false if the user cancelled
   */
  public boolean checkCurrentFileSaved() {
    boolean result = true;

    if (tileset != null && !tileset.isSaved()) {
      int answer =
          JOptionPane.showConfirmDialog(
              this,
              "The tileset has been modified. Do you want to save it?",
              "Save the modifications",
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.WARNING_MESSAGE);
      if (answer == JOptionPane.YES_OPTION) {
        save();
      } else if (answer == JOptionPane.CANCEL_OPTION) {
        result = false;
      }
    }

    return result;
  }
Esempio n. 4
0
 /**
  * Give the name of the resource opened in the editor
  *
  * @return the name of the map
  */
 public String getTitle() {
   return tileset == null ? "" : "Tileset " + tileset.getName();
 }