Search in sources :

Example 1 with Blueprint

use of de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint in project litiengine by gurkenlabs.

the class MapComponent method cut.

public void cut() {
    this.copiedBlueprint = new Blueprint("", true, this.getSelectedMapObjects().toArray(new MapObject[this.getSelectedMapObjects().size()]));
    UndoManager.instance().beginOperation();
    try {
        for (MapObject mapObject : this.getSelectedMapObjects()) {
            this.delete(mapObject);
            UndoManager.instance().mapObjectDeleted(mapObject);
        }
    } finally {
        UndoManager.instance().endOperation();
    }
}
Also used : Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 2 with Blueprint

use of de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint in project litiengine by gurkenlabs.

the class MapComponent method defineBlueprint.

public void defineBlueprint() {
    if (this.getFocusedMapObject() == null) {
        return;
    }
    Object name = JOptionPane.showInputDialog(Game.getScreenManager().getRenderComponent(), Resources.get("input_prompt_name"), Resources.get("input_prompt_name_title"), JOptionPane.PLAIN_MESSAGE, null, null, this.getFocusedMapObject().getName());
    if (name == null) {
        return;
    }
    Blueprint blueprint = new Blueprint(name.toString(), this.getSelectedMapObjects().toArray(new MapObject[this.getSelectedMapObjects().size()]));
    EditorScreen.instance().getGameFile().getBluePrints().add(blueprint);
    Program.getAssetTree().forceUpdate();
}
Also used : Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) IMapObject(de.gurkenlabs.litiengine.environment.tilemap.IMapObject)

Example 3 with Blueprint

use of de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint in project litiengine by gurkenlabs.

the class AssetPanelItem method addEntity.

private boolean addEntity() {
    // TODO: experimental code... this needs to be refactored with issue #66
    if (this.getOrigin() instanceof SpriteSheetInfo) {
        SpriteSheetInfo info = (SpriteSheetInfo) this.getOrigin();
        String propName = PropPanel.getNameBySpriteName(info.getName());
        if (propName == null) {
            return false;
        }
        MapObject mo = new MapObject();
        mo.setType(MapObjectType.PROP.name());
        mo.setX((int) Game.getCamera().getFocus().getX() - info.getWidth() / 2);
        mo.setY((int) Game.getCamera().getFocus().getY() - info.getHeight() / 2);
        mo.setWidth((int) info.getWidth());
        mo.setHeight((int) info.getHeight());
        mo.setId(Game.getEnvironment().getNextMapId());
        mo.setName("");
        mo.setCustomProperty(MapObjectProperty.COLLISIONBOX_WIDTH, (info.getWidth() * 0.4) + "");
        mo.setCustomProperty(MapObjectProperty.COLLISIONBOX_HEIGHT, (info.getHeight() * 0.4) + "");
        mo.setCustomProperty(MapObjectProperty.COLLISION, "true");
        mo.setCustomProperty(MapObjectProperty.PROP_INDESTRUCTIBLE, "false");
        mo.setCustomProperty(MapObjectProperty.PROP_ADDSHADOW, "true");
        mo.setCustomProperty(MapObjectProperty.SPRITESHEETNAME, propName);
        EditorScreen.instance().getMapComponent().add(mo);
        return true;
    } else if (this.getOrigin() instanceof EmitterData) {
        MapObject newEmitter = (MapObject) EmitterMapObjectLoader.createMapObject((EmitterData) this.getOrigin());
        newEmitter.setX((int) (Game.getCamera().getFocus().getX() - newEmitter.getWidth()));
        newEmitter.setY((int) (Game.getCamera().getFocus().getY() - newEmitter.getHeight()));
        newEmitter.setId(Game.getEnvironment().getNextMapId());
        EditorScreen.instance().getMapComponent().add(newEmitter);
    } else if (this.getOrigin() instanceof Blueprint) {
        Blueprint blueprint = (Blueprint) this.getOrigin();
        UndoManager.instance().beginOperation();
        try {
            List<MapObject> newObjects = blueprint.build((int) Game.getCamera().getFocus().getX() - blueprint.getWidth() / 2, (int) Game.getCamera().getFocus().getY() - blueprint.getHeight() / 2);
            for (MapObject newMapObject : newObjects) {
                EditorScreen.instance().getMapComponent().add(newMapObject);
            }
            // gets added
            for (MapObject newMapObject : newObjects) {
                EditorScreen.instance().getMapComponent().setSelection(newMapObject, false);
            }
        } finally {
            UndoManager.instance().endOperation();
        }
    }
    return false;
}
Also used : SpriteSheetInfo(de.gurkenlabs.litiengine.SpriteSheetInfo) Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) MapObject(de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject) EmitterData(de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)

Example 4 with Blueprint

use of de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint in project litiengine by gurkenlabs.

the class AssetPanelItem method deleteAsset.

private void deleteAsset() {
    if (getOrigin() instanceof SpriteSheetInfo) {
        SpriteSheetInfo info = (SpriteSheetInfo) getOrigin();
        int n = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), "Do you really want to delete the spritesheet [" + info.getName() + "]?\n Entities that use the sprite won't be rendered anymore!", "Delete Spritesheet?", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.OK_OPTION) {
            EditorScreen.instance().getGameFile().getSpriteSheets().remove(getOrigin());
            ImageCache.clearAll();
            Spritesheet.remove(info.getName());
            EditorScreen.instance().getMapComponent().reloadEnvironment();
            Program.getAssetTree().forceUpdate();
        }
    } else if (getOrigin() instanceof EmitterData) {
        EmitterData emitter = (EmitterData) getOrigin();
        int n = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), "Do you really want to delete the emitter [" + emitter.getName() + "]", "Delete Emitter?", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.OK_OPTION) {
            EditorScreen.instance().getGameFile().getEmitters().remove(getOrigin());
            EditorScreen.instance().getMapComponent().reloadEnvironment();
            Program.getAssetTree().forceUpdate();
        }
    } else if (getOrigin() instanceof Blueprint) {
        Blueprint blueprint = (Blueprint) getOrigin();
        int n = JOptionPane.showConfirmDialog(Game.getScreenManager().getRenderComponent(), "Do you really want to delete the blueprint [" + blueprint.getName() + "]?", "Delete Blueprint?", JOptionPane.YES_NO_OPTION);
        if (n == JOptionPane.OK_OPTION) {
            EditorScreen.instance().getGameFile().getBluePrints().remove(getOrigin());
            Program.getAssetTree().forceUpdate();
        }
    }
}
Also used : SpriteSheetInfo(de.gurkenlabs.litiengine.SpriteSheetInfo) Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint) EmitterData(de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)

Example 5 with Blueprint

use of de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint in project litiengine by gurkenlabs.

the class AssetPanelItem method exportBlueprint.

private void exportBlueprint() {
    if (!(this.getOrigin() instanceof Blueprint)) {
        return;
    }
    Blueprint mapObject = (Blueprint) this.getOrigin();
    XmlExportDialog.export(mapObject, "Blueprint", mapObject.getName());
}
Also used : Blueprint(de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)

Aggregations

Blueprint (de.gurkenlabs.litiengine.environment.tilemap.xml.Blueprint)6 MapObject (de.gurkenlabs.litiengine.environment.tilemap.xml.MapObject)3 SpriteSheetInfo (de.gurkenlabs.litiengine.SpriteSheetInfo)2 IMapObject (de.gurkenlabs.litiengine.environment.tilemap.IMapObject)2 EmitterData (de.gurkenlabs.litiengine.graphics.particles.xml.EmitterData)2 Point (java.awt.Point)1 File (java.io.File)1