load .we with layers

- and fix some bug : max is within range ( perhaps not as many as those added ...)
- quick hack in CharProvider to skip spaces ... ( bad it applies to strings too ...)
This commit is contained in:
philippe lhardy
2020-11-05 21:31:28 +01:00
parent bf918333bf
commit 6c9800047c
5 changed files with 63 additions and 36 deletions

View File

@@ -799,7 +799,19 @@ implements StatusListener
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(infile);
setModel(new MazePersistWorldEdit().parseInputStream("we",inputStream));
LabyLayers newLayers = new MazePersistWorldEdit().parseInputStream("we",inputStream);
if ( ! newLayers.isEmpty()) {
int l = layer;
for (int i = newLayers.getMin(); i <= newLayers.getMax(); i++) {
LabyModel m = newLayers.getLayer(i);
if (m != null) {
System.out.println("add layer " + l);
layers.addLabyModel(l, m);
l++;
}
}
setModel(layers.getLayer(layer));
}
} catch (IOException io) {
io.printStackTrace(System.err);
statusField.setText("[ERROR] Can't load " + infile.getAbsolutePath());