Package tiled.core

Examples of tiled.core.Map


     * extension. (filename.ext)
     *
     * @param filename Image filename to save map render to.
     */
    private void saveMapImage(String filename) {
        final Map currentMap = editor.getCurrentMap();
        final MapView myView = MapView.createViewforMap(currentMap);
        myView.setMode(MapView.PF_NOSPECIAL, true);

        // Take grid and zoom level from the current map view
        final MapView mapView = editor.getMapView();
View Full Code Here


                orientation = Map.MDO_HEX;
            } else if (mapTypeString.equals(SHIFTED_MAPTYPE)) {
                orientation = Map.MDO_SHIFTED;
            }

            newMap = new Map(w, h);
            newMap.addLayer();
            newMap.setTileWidth(twidth);
            newMap.setTileHeight(theight);
            newMap.setOrientation(orientation);
View Full Code Here

     * Wraps {@link #doPerformAction} in order to capture the layer vector
     * before and after the action is performed.
     */
    public final void actionPerformed(ActionEvent e) {
        // Capture the layers before the operation is executed.
        Map map = editor.getCurrentMap();
        Vector layersBefore = new Vector(map.getLayerVector());

        doPerformAction();

        // Capture the layers after the operation is executed and create the
        // layer state edit instance.
        Vector layersAfter = new Vector(map.getLayerVector());
        MapLayerStateEdit mapLayerStateEdit =
                new MapLayerStateEdit(map, layersBefore, layersAfter,
                                      e.getActionCommand());
        editor.getUndoSupport().postEdit(mapLayerStateEdit);
    }
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 loadMap(String file) throws Exception {
        Map ret = null;
        try {
            MapReader mr;
            if (file.endsWith(".tmx") || file.endsWith(".tmx.gz")) {
                // Override, so people can't overtake our format
                mr = new XMLMapTransformer();
            } else {
                mr = (MapReader)pluginLoader.getReaderFor(file);
            }

            if (mr != null) {
              PluginLogger logger = new PluginLogger();
                mr.setLogger(logger);
                ret = mr.readMap(file);
                ret.setFilename(file);
                reportPluginMessages(logger);
            } else {
                throw new Exception("Unsupported map format");
            }
        } catch (IOException e) {
View Full Code Here

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

            if (mr != null) {
                PluginLogger logger = new PluginLogger();
//                mr.setLogger(logger);
                ret = mr.readMap(file);
                ret.setFilename(file);
                reportPluginMessages(logger);
            } else {
                throw new Exception("Unsupported map format");
            }
        } catch (IOException e) {
View Full Code Here

  }
 
    @Override
    public void run() {
       // Capture the layers before the operation is executed.
        Map map = editor.getMap();
        Vector<MapLayer> layersBefore = new Vector<MapLayer>(map.getLayerVector());
        int oldIdx = editor.getCurrentLayerIndex();
        doPerformAction();
        int newIdx = editor.getCurrentLayerIndex();
        // Capture the layers after the operation is executed and create the
        // layer state edit instance.
        Vector<MapLayer> layersAfter = new Vector<MapLayer>(map.getLayerVector());
        String text = getText();
        if (action != null )
          text = action.getText();
        MapLayerStateEdit mapLayerStateEdit = 
                new MapLayerStateEdit(editor, layersBefore, layersAfter,
View Full Code Here

//              Resources.getString("action.layer.duplicate.tooltip"), Resources.getImageDescriptor("gimp-duplicate-16.png"));
//    }

    protected void doPerformAction() {
        MapLayer currentLayer = editor.getCurrentLayer();
        Map currentMap = editor.getMap();

        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("shift PAGE_UP"));
//    }

    protected void doPerformAction() {
        Map map = editor.getMap();
        int layerIndex = editor.getCurrentLayerIndex();
        int totalLayers = map.getTotalLayers();

        if (layerIndex < totalLayers - 1) {
            map.swapLayerUp(layerIndex);
            editor.setCurrentLayer(layerIndex + 1);
        }
    }
View Full Code Here

//              editor,
//              Resources.getString("action.layer.mergeall.name"), Resources.getString("action.layer.mergeall.tooltip"));
//    }

    protected void doPerformAction() {
        Map map = editor.getMap();

        boolean result = MessageDialog.open(MessageDialog.QUESTION_WITH_CANCEL,editor.getEditorSite().getShell(),"Merge Tiles?",
            "Do you wish to merge tile images, and create a new tile set?",SWT.NONE);
//        int ret = JOptionPane.showConfirmDialog(null,
//                "Do you wish to merge tile images, and create a new tile set?",
//                "Merge Tiles?", JOptionPane.YES_NO_CANCEL_OPTION);

        if (result) {
            TileMergeHelper tmh = new TileMergeHelper(map);
            int len = map.getTotalLayers();
            //TODO: Add a dialog option: "Yes, visible only"
            TileLayer newLayer = tmh.merge(0, len, true);
            map.removeAllLayers();
            map.addLayer(newLayer);
            newLayer.setName("Merged Layer");
            map.addTileset(tmh.getSet());
            editor.setCurrentLayer(0);
        }
        else /*if (ret == JOptionPane.NO_OPTION)*/ {
            while (map.getTotalLayers() > 1) {
                map.mergeLayerDown(editor.getCurrentLayerIndex());
            }
            editor.setCurrentLayer(0);
        }
       
    }
View Full Code Here

*/
public class DeleteLayerAction extends AbstractLayerAction
{

    protected void doPerformAction() {
        Map map = editor.getMap();
        int layerIndex = editor.getCurrentLayerIndex();
        int totalLayers = map.getTotalLayers();

        if (layerIndex >= 0) {
            map.removeLayer(layerIndex);

            // If the topmost layer was selected, the layer index is invalid
            // after removing that layer. The right thing to do is to reset it
            // to the new topmost layer.
            if (layerIndex == totalLayers - 1) {
View Full Code Here

TOP

Related Classes of 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.