Package de.yaams.extensions.basemap.tiled.core

Examples of de.yaams.extensions.basemap.tiled.core.Tile


    // create data
    for (int z = 0, n = map.getLayerVector().size() > 3 ? 3 : map.getLayerVector().size(); z < n; z++) {
      TileLayer layer = (TileLayer) map.getLayer(z);
      for (int x = 0, l = layer.getWidth(); x < l; x++) {
        for (int y = 0, m = layer.getHeight(); y < m; y++) {
          Tile t = layer.getTileAt(x, y);

          // is set?
          if (t == null) {
            d[z][x][y] = 0;
            continue;
          }

          // check tileset
          if (t.getTileSet().getName().equals("AutoTiles")) {
            d[z][x][y] = t.getId();

          } else {

            d[z][x][y] = t.getId() + 384;
          }
        }

      }
    }
View Full Code Here


    ArrayList<BufferedImage> images = RGSS1Load.loadAutotilesAsImage(project, Integer.valueOf(id));

    // add all
    for (int i = 0, l = images.size(); i < l; i++) {
      Tile t = new Tile();
      t.setId(i);
      if (images.get(i) != null) {
        t.setImage(images.get(i));
      }
      t.setTileSet(tileset);
      tileset.addTile(t);
    }

    tileset.setName("AutoTiles");
View Full Code Here

    ArrayList<BufferedImage> images = RGSS1Load.loadTilesetAsImage(project, Integer.valueOf(id));

    // add all
    for (int i = 0, l = images.size(); i < l; i++) {
      Tile t = new Tile();
      t.setId(i);
      if (images.get(i) != null) {
        t.setImage(images.get(i));
      }
      t.setTileSet(tileset);
      tileset.addTile(t);
    }

    tileset.setName(o.getInstanceVariable("@name").toString());
View Full Code Here

      @Override
      public void mousePressed(MouseEvent e) {
        origin = getTileCoordinates(e.getX(), e.getY());
        setSelection(new Rectangle(origin.x, origin.y, 0, 0));
        scrollTileToVisible(origin);
        Tile clickedTile = getTileAt(origin.x, origin.y);
        if (clickedTile != null) {
          fireTileSelectionEvent(clickedTile);
        }
      }
View Full Code Here

  private int checkSetUsage(TileSet set) {
    int used = 0;
    Iterator<?> tileIterator = set.iterator();

    while (tileIterator.hasNext()) {
      Tile tile = (Tile) tileIterator.next();
      Iterator<?> itr = map.getLayers();

      while (itr.hasNext()) {
        MapLayer ml = (MapLayer) itr.next();
View Full Code Here

    for (TileSet set : map.getTilesets()) {
      b.addItem(set);

      final Iterator<?> tileIterator = set.iterator();
      while (tileIterator.hasNext()) {
        Tile tile = (Tile) tileIterator.next();
        b.addItem(tile);
      }
    }
  }
View Full Code Here

  @Override
  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

    Tile tile = (Tile) value;

    if (tile != null) {
      Image scaledImage = tile.getScaledImage(zoom);
      if (scaledImage != null) {
        setIcon(new ImageIcon(scaledImage));
      }
      setText(TILE + " " + tile.getId());
    } else {
      setIcon(null);
      setText(NOTILE);
    }
View Full Code Here

    // Let the default list cell renderer do most of the work
    super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);

    // Attempt to set an appropriate icon
    if (value instanceof Tile && index >= 0) {
      Tile tile = (Tile) value;
      if (!isSelected || zoom == 1) {
        // Use cached ImageIcon instance
        if (tileImages.containsKey(index)) {
          setIcon(tileImages.get(index));
        } else {
          Icon icon = new ImageIcon(tile.getScaledImage(zoom));
          setIcon(icon);
          tileImages.put(index, icon);
        }
      } else {
        // Selected entry always uses unscaled image
        setIcon(new ImageIcon(tile.getImage()));
      }
    } else if (value instanceof TileSet) {
      setIcon(setIcon);
    }
View Full Code Here

    if (tileset != null && tileset.size() > 0) {
      listData = new Vector<Tile>();
      Iterator<?> tileIterator = tileset.iterator();

      while (tileIterator.hasNext()) {
        Tile tile = (Tile) tileIterator.next();
        listData.add(tile);
      }

      tileList.setListData(listData);
    }
View Full Code Here

    if (source == deleteTileButton) {
      int answer = JOptionPane.showConfirmDialog(this, Resources.getString("action.tile.delete.confirm.message"),
          Resources.getString("action.tile.delete.confirm.title"), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
      if (answer == JOptionPane.YES_OPTION) {
        Tile tile = (Tile) tileList.getSelectedValue();
        if (tile != null) {
          tileset.removeTile(tile.getId());
        }
        queryTiles();
      }
    } else if (source == changeImageButton) {
      changeImage();
    } else if (source == addImagesButton) {
      addImages();
    } else if (source == duplicateTileButton) {
      Tile newTile = new Tile(currentTile);
      tileset.addNewTile(newTile);
      queryTiles();
      // Select the last (cloned) tile
      tileList.setSelectedIndex(tileset.size() - 1);
      tileList.ensureIndexIsVisible(tileset.size() - 1);
      // } else if (source == animationButton) {
      // AnimationDialog ad = new AnimationDialog(this,
      // ((AnimatedTile)currentTile).getSprite());
      // ad.setVisible(true);
    }
    /*
     * else if (source == setImagesCheck) { if (setImagesCheck.isSelected())
     * { tileset.enablesetImages(); updateEnabledState(); } else { int
     * answer = JOptionPane.YES_OPTION; if
     * (!tileset.safeToDisablesetImages()) { answer =
     * JOptionPane.showConfirmDialog( this,
     * "This tileset uses features that require the " +
     * "use of shared images.  Disable the use of shared " + "images?",
     * "Are you sure?", JOptionPane.YES_NO_OPTION,
     * JOptionPane.QUESTION_MESSAGE); } if (answer ==
     * JOptionPane.YES_OPTION) { tileset.disablesetImages();
     * updateEnabledState(); } else { setImagesCheck.setSelected(true); } }
     * }
     */
    else if (source == createTileButton) {
      Object[] imgs = imageList.getSelectedValues();
      if (imgs.length == 0)
        return;

      for (Object img : imgs) {
        Tile newTile = new Tile(tileset);
        newTile.setImage(tileset.getIdByImage((Image) img));
        tileset.addNewTile(newTile);
      }

      queryTiles();
      // Select the last (cloned) tile
View Full Code Here

TOP

Related Classes of de.yaams.extensions.basemap.tiled.core.Tile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.