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

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


    if (map == null) {
      map = new CMap();
    }

    // build map
    final Map m = new Map(map.getWidth(), map.getHeight());
    m.setFilename(path);
    m.setProject(p);
    m.setMid(0);

    TileSet tileset = buildTileset(info.getTileset(), p);
    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

    for (int z = 0, n = map.getLayer(); z < n; z++) {
      final TileLayer l = (TileLayer) m.addLayer();
      l.setName(z == 0 ? "Base" : z == 1 ? "Objects" : Integer.toString(z));
      // set tiles
      for (int x = 0, u = m.getWidth(); x < u; x++) {
        for (int y = 0, v = m.getHeight(); y < v; y++) {
          if (map.get(x, y, z) >= 0) {
            l.setTileAt(x, y, tileset.getTile(map.get(x, y, z)));
          }
        }
      }
View Full Code Here


   * @return a new Map, loaded from the specified file by a plugin
   * @throws Exception
   * @see MapReader#readMap(String)
   */
  public static Map load2Map(Project p, int id) throws Exception {
    Map ret = null;
    try {
      MapReader mr = null;
      // if (file.endsWith(".tmx") || file.endsWith(".tmx.gz")) {
      // // Override, so people can't overtake our format
      // mr = new XMLMapTransformer();
      // } else {
      // mr = (MapReader) pluginLoader.getReaderFor(p, id);
      // }

      if (mr != null) {
        ret = mr.readMap(p, id);
        ret.setProject(p);
        ret.setMid(id);
        ret.setFilename(RGSS1Load.getMapFile(p, id));
      } else {
        throw new Exception("Unsupported map format");
      }
    } catch (final Throwable t) {
      YEx.error("Can not load map " + id + " from project " + p, t);
View Full Code Here

      @Override
      public void work(HashMap<String, Object> objects) {

        File file = (File) objects.get("file");
        Map map = (Map) objects.get("map");

        // check all types
        for (MapWriter m : plugs) {
          if (objects.containsKey("saved")) {
            break;
View Full Code Here

  public Map readMap(String filename) throws Exception {
    return readMap(new FileInputStream(filename));
  }

  public Map readMap(InputStream in) throws Exception {
    Map ret = null;
    chunks = new LinkedList<Chunk>();
    blocks = new Vector<BlkStr>();
    byte[] hdr = new byte[4];

    in.read(hdr);
View Full Code Here

    }
    return null;
  }

  private Map readMPHDChunk(InputStream in) throws IOException {
    Map ret = null;
    TileSet set = new TileSet();
    int major, minor;
    major = in.read();
    minor = in.read();
    in.skip(2); // skip lsb and reserved bytes - always msb
    ret = new Map(Util.readShort(in), Util.readShort(in));
    Properties retProps = ret.getProperties();
    ret.setOrientation(Map.MDO_ORTHO); // be sure to set the orientation!
    retProps.setProperty("(s)fmap reader", "Don't modify properties marked (s) unless you really know what you're doing.");
    retProps.setProperty("version", "" + major + "." + minor);
    in.skip(4); // reserved
    twidth = Util.readShort(in);
    theight = Util.readShort(in);
    ret.setTileWidth(twidth);
    ret.setTileHeight(theight);
    set.setName("Static tiles");
    ret.addTileset(set);
    int depth = Util.readShort(in);
    if (depth < 16) {
      throw new IOException("Tile bitdepths less than 16 are not supported!");
    }
    retProps.setProperty("(s)depth", String.valueOf(depth));
    in.skip(2);
    int numBlocks = Util.readShort(in);
    int numBlocksGfx = Util.readShort(in);
    Chunk c = findChunk("BKDT");
    if (c == null) {
      throw new IOException("No BKDT block found!");
    }
    MapLayer ml = new TileLayer(ret, ret.getWidth(), ret.getHeight());
    ml.setName("bg");
    ret.addLayer(ml);
    for (int i = 1; i < 7; i++) {
      // TODO: I believe this should be ObjectGroup
      ml = new ObjectGroup(ret, 0, 0);
      ml.setName("ObjectLayer " + i);
      ret.addLayer(ml);
    }
    ml = new TileLayer(ret, ret.getWidth(), ret.getHeight());
    ml.setName("fg 1");
    ret.addLayer(ml);
    ml = new TileLayer(ret, ret.getWidth(), ret.getHeight());
    ml.setName("fg 2");
    ret.addLayer(ml);
    ml = new TileLayer(ret, ret.getWidth(), ret.getHeight());
    ml.setName("fg 3");
    ret.addLayer(ml);

    readBKDTChunk(ret, c.getInputStream(), numBlocks);

    c = findChunk("BGFX");
    if (c != null) {
      readBGFXChunk(ret, c.getInputStream(), numBlocksGfx);
    } else {
      throw new IOException("No BGFX chunk found!");
    }

    Log.ger.debug(ret.toString());
    return ret;
  }
View Full Code Here

    // Get the map dimensions and create the map
    int mapWidth = getAttribute(mapNode, "width", 0);
    int mapHeight = getAttribute(mapNode, "height", 0);

    if (mapWidth > 0 && mapHeight > 0) {
      map = new Map(mapWidth, mapHeight);
    } else {
      // Maybe this map is still using the dimensions element
      NodeList l = doc.getElementsByTagName("dimensions");
      for (int i = 0; (item = l.item(i)) != null; i++) {
        if (item.getParentNode() == mapNode) {
          mapWidth = getAttribute(item, "width", 0);
          mapHeight = getAttribute(item, "height", 0);

          if (mapWidth > 0 && mapHeight > 0) {
            map = new Map(mapWidth, mapHeight);
          }
        }
      }
    }
View Full Code Here

    // Wrap with GZIP decoder for .tmx.gz files
    if (filename.getName().endsWith(".gz")) {
      is = new GZIPInputStream(is);
    }

    Map unmarshalledMap = unmarshal(is);
    unmarshalledMap.setFilename(filename);

    map = null;

    return unmarshalledMap;
  }
View Full Code Here

  }

  public Map readMap(InputStream in) throws Exception {
    xmlPath = makeUrl(".");

    Map unmarshalledMap = unmarshal(in);

    // unmarshalledMap.setFilename(xmlFile)
    //
    return unmarshalledMap;
  }
View Full Code Here

  }

  @Override
  protected void doPerformAction() {
    MapLayer currentLayer = editor.getCurrentLayer();
    Map currentMap = editor.getCurrentMap();

    if (currentLayer != null) {
      try {
        MapLayer clone = (MapLayer) currentLayer.clone();
        String newName = Resources.getString("action.layer.duplicate.newlayer.name");
        clone.setName(MessageFormat.format(newName, new Object[] { clone.getName() }));
        currentMap.addLayer(clone);
        editor.setCurrentLayer(currentMap.getTotalLayers() - 1);
      } catch (CloneNotSupportedException ex) {
        ex.printStackTrace();
      }
    }
  }
View Full Code Here

    putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control S"));
  }

  @Override
  public void actionPerformed(ActionEvent e) {
    Map currentMap = editor.getCurrentMap();
    File filePath = new File(currentMap.getFilename());

    // todo: Fix the case where the plugin cannot be determined by the
    // todo: current filename. This can happen when the user has used
    // todo: "Save As" to save the file using a non-standard extension.
    if (filePath != null) {
View Full Code Here

TOP

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

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.