package pack; import javax.microedition.midlet.*; import javax.microedition.lcdui.*; import javax.microedition.lcdui.game.*; import game.*; import java.io.*; import javax.microedition.io.file.*; import javax.microedition.io.*; public class MapEditor extends MIDlet { private TiledLayer tl; private EditCanvas ec; public void startApp() { } public void pauseApp() { } public void destroyApp(boolean unconditional) { } //Загрузка и выгрузка замощёного слоя public TiledLayer openLayer(String pathTile, String pathImage){ TiledLayer tl; Image img; try { FileConnection fct = (FileConnection) Connector.open(pathTile); FileConnection fci = (FileConnection) Connector.open(pathImage); if (fci.exists()) { img=Image.createImage(fci.openDataInputStream()); } else { img=null; } if (fct.exists()) { DataInputStream disl = fct.openDataInputStream(); Map.loadTiledLayer(disl, img); } else { tl=null; } } catch (IOException exc) { return null; } return tl; } public void createTile(TiledLayer tl, String pathTile, String pathImage){ try { FileConnection fc = (FileConnection) Connector.open(pathTile); if (!fc.exists()){ fc.create(); } DataOutputStream dos = fc.openDataOutputStream(); Map.writeTiledLayer(tl, pathImage, dos); } catch (Exception exc) { } } }