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

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


    startTable("tilesets");
    int firstgid = 1;
    Iterator<TileSet> itr = map.getTilesets().iterator();
    while (itr.hasNext()) {
      TileSet tileset = itr.next();
      tileset.setFirstGid(firstgid);
      writeTilesetReference(tileset);
      firstgid += tileset.getMaxTileId() + 1;
    }
    endTable();

    startTable("layers");
    Iterator<MapLayer> ml = map.getLayers();
View Full Code Here


    OutputStream out = chunk.getOutputStream();
    String ver = map.getProperties().getProperty("version");
    if (ver == null || ver.length() < 3) {
      ver = "0.3"; // default the value
    }
    TileSet set = map.getTilesets().get(0);

    // FIXME
    // out.write(Integer.parseInt(ver.substring(0,ver.indexOf('.')-1)));
    // out.write(Integer.parseInt(ver.substring(ver.indexOf('.')+1)));
    out.write(0);
    out.write(3);
    out.write(1);
    out.write(0); // LSB, reserved
    Util.writeShort(map.getWidth(), out);
    Util.writeShort(map.getHeight(), out);
    out.write(0);
    out.write(0);
    out.write(0);
    out.write(0); // reserved
    Util.writeShort(map.getTileWidth(), out);
    Util.writeShort(map.getTileHeight(), out);
    Util.writeShort(16, out); // tile bitdepth
    Util.writeShort(32, out); // blkstr bytewidth
    Util.writeShort(findAllBlocks(map).size(), out);
    Util.writeShort(set.getMaxTileId(), out);

    chunks.add(chunk);
  }
View Full Code Here

    @Override
    public void tilesetRemoved(MapChangedEvent e, int index) {
      JScrollPane scroll = (JScrollPane) getComponentAt(index);
      TilePalettePanel panel = (TilePalettePanel) scroll.getViewport().getView();
      TileSet set = panel.getTileset();
      panel.removeTileSelectionListener(TabbedTilesetsPane.this);
      set.removeTilesetChangeListener(listener);
      tilePanels.remove(set);
      removeTabAt(index);
    }
View Full Code Here

    @Override
    public void tilesetChanged(TilesetChangedEvent event) {}

    @Override
    public void nameChanged(TilesetChangedEvent event, String oldName, String newName) {
      TileSet set = event.getTileset();
      int index = map.getTilesets().indexOf(set);

      setTitleAt(index, newName);
    }
View Full Code Here

    final Map m = new Map(RubyHelper.toInt(o, "@width"), RubyHelper.toInt(o, "@height"));
    m.setFilename(RGSS1Load.getMapFile(project, id));
    m.setProject(project);
    m.setMid(id);

    TileSet autotiles = buildAutoTileset(RubyHelper.toInt(o, "@tileset_id"));
    m.addTileset(autotiles);

    TileSet tileset = buildTileset(RubyHelper.toInt(o, "@tileset_id"));
    m.addTileset(tileset);
    m.setTileHeight(32);
    m.setTileWidth(32);
    // tileset.

    // def [](x,y=0,z=0)
    // @data[x+y*@xsize+z*@xsize*@ysize]

    // build layers
    // load map data
    IRubyObject[] data = ((RubyArray) ((RubyObject) o.getInstanceVariable("@data")).getInstanceVariable("@data")).toJavaArray();
    final String[] names = { "Down", "Middle", "Up" };
    int z = 0;

    for (final String a : names) {
      final TileLayer l = (TileLayer) m.addLayer();
      l.setName(a);
      // set tiles
      for (int x = 0, u = m.getWidth(); x < u; x++) {
        for (int y = 0, v = m.getHeight(); y < v; y++) {

          int tid = Integer.valueOf(data[x + y * u + z * u * v].toString());
          // get id
          if (tid < 384) {
            l.setTileAt(x, y, autotiles.getTile(tid));
          } else {
            // t.setId(((Long) data[x + y * u + z * u * v]);
            l.setTileAt(x, y, tileset.getTile(tid - 384));
          }
        }
      }
      z++;
    }
View Full Code Here

   * @throws IOException
   */
  protected TileSet buildAutoTileset(int id) throws IOException {

    // build tileset
    TileSet tileset = new TileSet();

    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");

    return tileset;
  }
View Full Code Here

  protected TileSet buildTileset(int id) throws IOException {
    // load tileset
    RubyObject o = RGSS1Helper.get(project, Type.TILESET).get(id).getObject();

    // build tileset
    TileSet tileset = new TileSet();

    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());

    return tileset;
  }
View Full Code Here

  @Override
  public Object getValueAt(int row, int col) {
    Vector<?> tilesets = map.getTilesets();
    if (row >= 0 && row < tilesets.size()) {
      TileSet tileset = (TileSet) tilesets.get(row);
      if (col == 0) {
        return tileset.getName();
      } else {
        String ret = tileset.getSource();

        if (ret == null) {
          ret = EMBEDDED;
        }
View Full Code Here

    if (col != 0)
      return;

    Vector<?> tilesets = map.getTilesets();
    if (row >= 0 && row < tilesets.size()) {
      TileSet tileset = (TileSet) tilesets.get(row);
      if (col == 0) {
        tileset.setName(value.toString());
      }
      fireTableCellUpdated(row, col);
    }
  }
View Full Code Here

  @Override
  public void actionPerformed(ActionEvent event) {
    String command = event.getActionCommand();
    int selectedRow = tilesetTable.getSelectedRow();
    Vector<?> tilesets = map.getTilesets();
    TileSet set = null;
    try {
      set = (TileSet) tilesets.get(selectedRow);
    } catch (IndexOutOfBoundsException e) {
    }

    if (command.equals(CLOSE_BUTTON)) {
      dispose();
    } else if (command.equals(EDIT_BUTTON)) {
      if (map != null && selectedRow >= 0) {
        TileDialog tileDialog = new TileDialog(this, set, map);
        tileDialog.setVisible(true);
      }
    } else if (command.equals(REMOVE_BUTTON)) {
      if (checkSetUsage(set) > 0) {
        int ret = JOptionPane.showConfirmDialog(this, Resources.getString("action.tileset.remove.in-use.message"),
            Resources.getString("action.tileset.remove.in-use.title"), JOptionPane.YES_NO_OPTION);
        if (ret != JOptionPane.YES_OPTION) {
          return;
        }
      }
      try {
        map.removeTileset(set);
        updateTilesetTable();
      } catch (LayerLockedException e) {
        JOptionPane.showMessageDialog(this, Resources.getString("action.tileset.remove.error.layer-locked.message"),
            Resources.getString("action.tileset.remove.error.title"), JOptionPane.ERROR_MESSAGE);
      }
    } else if (command.equals(SAVE_AS_BUTTON)) {
      JFileChooser ch = new ConfirmingFileChooser(map.getFilename());
      MapHelper.addExtension(ch);

      int ret = ch.showSaveDialog(this);
      if (ret == JFileChooser.APPROVE_OPTION) {
        String filename = ch.getSelectedFile().getAbsolutePath();
        try {
          MapHelper.saveTileset(set, filename);
          set.setSource(filename);
          embedButton.setEnabled(true);
          saveButton.setEnabled(true);
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    } else if (command.equals(SAVE_BUTTON)) {
      try {
        MapHelper.saveTileset(set, set.getSource());
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else if (command.equals(EMBED_BUTTON)) {
      set.setSource(null);
      embedButton.setEnabled(false);
      saveButton.setEnabled(false);
    } else if (command.equals(MOVE_UP_BUTTON)) {
      if (selectedRow > 0) {
        int newRow = selectedRow - 1;
View Full Code Here

TOP

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

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.