Workshop tweaks
This commit is contained in:
@@ -64,7 +64,7 @@ public class Map implements Comparable<Map>{
|
||||
}
|
||||
|
||||
public FileHandle previewFile(){
|
||||
return Vars.mapPreviewDirectory.child(file.nameWithoutExtension() + ".png");
|
||||
return Vars.mapPreviewDirectory.child((workshop ? file.parent().name() : file.nameWithoutExtension()) + ".png");
|
||||
}
|
||||
|
||||
public FileHandle cacheFile(){
|
||||
@@ -133,6 +133,8 @@ public class Map implements Comparable<Map>{
|
||||
|
||||
@Override
|
||||
public int compareTo(Map map){
|
||||
int work = -Boolean.compare(workshop, map.workshop);
|
||||
if(work != 0) return work;
|
||||
int type = -Boolean.compare(custom, map.custom);
|
||||
if(type != 0) return type;
|
||||
int modes = Boolean.compare(Gamemode.pvp.valid(this), Gamemode.pvp.valid(map));
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.anuke.arc.assets.loaders.resolvers.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
|
||||
@@ -20,7 +21,7 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
try{
|
||||
super.loadAsync(manager, fileName, file.sibling(file.nameWithoutExtension()), parameter);
|
||||
}catch(Exception e){
|
||||
e.printStackTrace();
|
||||
Log.err(e);
|
||||
MapPreviewParameter param = (MapPreviewParameter)parameter;
|
||||
Vars.maps.queueNewPreview(param.map);
|
||||
}
|
||||
@@ -31,11 +32,11 @@ public class MapPreviewLoader extends TextureLoader{
|
||||
try{
|
||||
return super.loadSync(manager, fileName, file, parameter);
|
||||
}catch(Throwable e){
|
||||
e.printStackTrace();
|
||||
Log.err(e);
|
||||
try{
|
||||
return new Texture(file);
|
||||
}catch(Throwable e2){
|
||||
e2.printStackTrace();
|
||||
Log.err(e2);
|
||||
return new Texture("sprites/error.png");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -324,10 +324,8 @@ public class Maps{
|
||||
public void loadPreviews(){
|
||||
|
||||
for(Map map : maps){
|
||||
Log.info("Generating preview for {0}", map.name());
|
||||
//try to load preview
|
||||
if(map.previewFile().exists()){
|
||||
Log.info("> exists");
|
||||
//this may fail, but calls queueNewPreview
|
||||
Core.assets.load(new AssetDescriptor<>(map.previewFile().path() + "." + mapExtension, Texture.class, new MapPreviewParameter(map))).loaded = t -> map.texture = (Texture)t;
|
||||
|
||||
@@ -338,7 +336,6 @@ public class Maps{
|
||||
queueNewPreview(map);
|
||||
}
|
||||
}else{
|
||||
Log.info("> doesn't exist, queuing");
|
||||
queueNewPreview(map);
|
||||
}
|
||||
}
|
||||
@@ -347,7 +344,6 @@ public class Maps{
|
||||
private void createAllPreviews(){
|
||||
Core.app.post(() -> {
|
||||
for(Map map : previewList){
|
||||
Log.info("> > GEN NEW preview for {0}", map.name());
|
||||
createNewPreview(map, e -> Core.app.post(() -> map.texture = Core.assets.get("sprites/error.png")));
|
||||
}
|
||||
previewList.clear();
|
||||
|
||||
Reference in New Issue
Block a user