コード例 #1
0
  /** Loads the icons for the tile patterns list. */
  private void loadIcons() {

    tilePatternIcons.clear();

    for (TilePattern tilePattern : tileset.getTilePatterns()) {
      tilePatternIcons.add(new TilePatternIcon(tilePattern, tileset));
    }
  }
コード例 #2
0
  /** Closes this editor without confirmation. */
  @Override
  public void close() {
    tileset.deleteObservers();

    // Notify the children views.
    tilePatternsView.setTileset(null);
    tilesetImageView.setTileset(null);
  }
コード例 #3
0
  /** Saves the current resource. */
  public void save() {

    try {
      tileset.save();
    } catch (QuestEditorException ex) {
      GuiTools.errorDialog("Could not save the tileset: " + ex.getMessage());
    }
  }
コード例 #4
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;
  }
コード例 #5
0
  /**
   * Sets the tileset observed.
   *
   * @param tileset the current tileset, or null if there is no tileset
   */
  public void setTileset(Tileset tileset) {

    if (tileset != this.tileset) {

      if (this.tileset != null) {
        this.tileset.deleteObserver(tilePatternsListModel);
      }

      this.tileset = tileset;
      tilesetPropertiesView.setTileset(tileset);
      tilePatternView.setTileset(tileset);

      if (tileset != null) {
        tileset.addObserver(tilePatternsListModel);

        loadIcons();
        tilePatternsListModel.update(tileset, null);
      } else {
        repaint();
      }
    }
  }
コード例 #6
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();
 }