Fixed map loading bugs
Before Width: | Height: | Size: 9.7 KiB After Width: | Height: | Size: 9.7 KiB |
Before Width: | Height: | Size: 38 KiB After Width: | Height: | Size: 38 KiB |
Before Width: | Height: | Size: 8.0 KiB After Width: | Height: | Size: 8.0 KiB |
Before Width: | Height: | Size: 8.8 KiB After Width: | Height: | Size: 8.8 KiB |
Before Width: | Height: | Size: 7.2 KiB After Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 33 KiB |
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
Before Width: | Height: | Size: 719 B After Width: | Height: | Size: 718 B |
Before Width: | Height: | Size: 682 KiB After Width: | Height: | Size: 672 KiB |
Before Width: | Height: | Size: 274 KiB After Width: | Height: | Size: 258 KiB |
Before Width: | Height: | Size: 579 KiB After Width: | Height: | Size: 574 KiB |
@ -184,7 +184,7 @@ public class Maps{
|
|||||||
FileHandle dest = findFile();
|
FileHandle dest = findFile();
|
||||||
file.copyTo(dest);
|
file.copyTo(dest);
|
||||||
|
|
||||||
loadMap(dest, true);
|
createNewPreview(loadMap(dest, true), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Attempts to run the following code;
|
/** Attempts to run the following code;
|
||||||
@ -341,7 +341,7 @@ public class Maps{
|
|||||||
private void createAllPreviews(){
|
private void createAllPreviews(){
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
for(Map map : previewList){
|
for(Map map : previewList){
|
||||||
createNewPreview(map);
|
createNewPreview(map, false);
|
||||||
}
|
}
|
||||||
previewList.clear();
|
previewList.clear();
|
||||||
});
|
});
|
||||||
@ -351,12 +351,16 @@ public class Maps{
|
|||||||
Core.app.post(() -> previewList.add(map));
|
Core.app.post(() -> previewList.add(map));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createNewPreview(Map map){
|
private void createNewPreview(Map map, boolean immediate){
|
||||||
try{
|
try{
|
||||||
//if it's here, then the preview failed to load or doesn't exist, make it
|
//if it's here, then the preview failed to load or doesn't exist, make it
|
||||||
//this has to be done synchronously!
|
//this has to be done synchronously!
|
||||||
Pixmap pix = MapIO.generatePreview(map);
|
Pixmap pix = MapIO.generatePreview(map);
|
||||||
|
if(immediate){
|
||||||
|
map.texture = new Texture(pix);
|
||||||
|
}else{
|
||||||
Core.app.post(() -> map.texture = new Texture(pix));
|
Core.app.post(() -> map.texture = new Texture(pix));
|
||||||
|
}
|
||||||
executor.submit(() -> {
|
executor.submit(() -> {
|
||||||
try{
|
try{
|
||||||
map.previewFile().writePNG(pix);
|
map.previewFile().writePNG(pix);
|
||||||
@ -404,7 +408,7 @@ public class Maps{
|
|||||||
return customMapDirectory.child("map_" + i + "." + mapExtension);
|
return customMapDirectory.child("map_" + i + "." + mapExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadMap(FileHandle file, boolean custom) throws IOException{
|
private Map loadMap(FileHandle file, boolean custom) throws IOException{
|
||||||
Map map = MapIO.createMap(file, custom);
|
Map map = MapIO.createMap(file, custom);
|
||||||
|
|
||||||
if(map.name() == null){
|
if(map.name() == null){
|
||||||
@ -413,6 +417,7 @@ public class Maps{
|
|||||||
|
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
maps.sort();
|
maps.sort();
|
||||||
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadCustomMaps(){
|
private void loadCustomMaps(){
|
||||||
|
@ -42,7 +42,7 @@ public class Zone extends UnlockableContent{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load(){
|
public void load(){
|
||||||
preview = Core.atlas.find(name);
|
preview = Core.atlas.find("zone-" + name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Rules getRules(){
|
public Rules getRules(){
|
||||||
|
@ -62,6 +62,7 @@ public class MapsDialog extends FloatingDialog{
|
|||||||
if(!ios){
|
if(!ios){
|
||||||
buttons.addImageTextButton("$editor.importmap", "icon-load", iconsize, () -> {
|
buttons.addImageTextButton("$editor.importmap", "icon-load", iconsize, () -> {
|
||||||
platform.showFileChooser("$editor.importmap", "Map File", file -> {
|
platform.showFileChooser("$editor.importmap", "Map File", file -> {
|
||||||
|
ui.loadAnd(() -> {
|
||||||
maps.tryCatchMapError(() -> {
|
maps.tryCatchMapError(() -> {
|
||||||
if(MapIO.isImage(file)){
|
if(MapIO.isImage(file)){
|
||||||
ui.showError("$editor.errorimage");
|
ui.showError("$editor.errorimage");
|
||||||
@ -96,7 +97,8 @@ public class MapsDialog extends FloatingDialog{
|
|||||||
}else if(conflict != null){
|
}else if(conflict != null){
|
||||||
ui.showConfirm("$confirm", "$editor.overwrite.confirm", () -> {
|
ui.showConfirm("$confirm", "$editor.overwrite.confirm", () -> {
|
||||||
maps.tryCatchMapError(() -> {
|
maps.tryCatchMapError(() -> {
|
||||||
maps.importMap(file);
|
maps.removeMap(conflict);
|
||||||
|
maps.importMap(map.file);
|
||||||
setup();
|
setup();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -106,6 +108,7 @@ public class MapsDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
}, true, FileChooser.anyMapFiles);
|
}, true, FileChooser.anyMapFiles);
|
||||||
}).size(210f, 64f);
|
}).size(210f, 64f);
|
||||||
}
|
}
|
||||||
|