Search in sources :

Example 1 with HandlerPersister

use of com.b3dgs.lionengine.game.feature.HandlerPersister in project lionengine by b3dgs.

the class MapTileHelper method importAndSave.

/**
 * Import and save the level.
 *
 * @param levelrip The level rip.
 * @param sheetsConfig The file that define the sheets configuration.
 * @param out The output media.
 * @param mapPersister The persister reference.
 */
public static void importAndSave(Media levelrip, Media sheetsConfig, Media out, MapTilePersister mapPersister) {
    final Services services = new Services();
    final MapTileGame map = services.create(MapTileGame.class);
    map.create(levelrip, sheetsConfig);
    map.addFeature(mapPersister);
    services.add(new Factory(services));
    services.add(new Handler(services));
    final HandlerPersister persister = new HandlerPersister(services);
    try (FileWriting output = new FileWriting(out)) {
        mapPersister.save(output);
        persister.save(output);
    } catch (final IOException exception) {
        Verbose.exception(exception, "Error on saving map !");
    }
}
Also used : Services(com.b3dgs.lionengine.game.feature.Services) FileWriting(com.b3dgs.lionengine.io.FileWriting) MapTileGame(com.b3dgs.lionengine.game.feature.tile.map.MapTileGame) HandlerPersister(com.b3dgs.lionengine.game.feature.HandlerPersister) Factory(com.b3dgs.lionengine.game.feature.Factory) Handler(com.b3dgs.lionengine.game.feature.Handler) IOException(java.io.IOException)

Aggregations

Factory (com.b3dgs.lionengine.game.feature.Factory)1 Handler (com.b3dgs.lionengine.game.feature.Handler)1 HandlerPersister (com.b3dgs.lionengine.game.feature.HandlerPersister)1 Services (com.b3dgs.lionengine.game.feature.Services)1 MapTileGame (com.b3dgs.lionengine.game.feature.tile.map.MapTileGame)1 FileWriting (com.b3dgs.lionengine.io.FileWriting)1 IOException (java.io.IOException)1