non-functional loading screen
This commit is contained in:
@@ -9,7 +9,7 @@ import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.filters.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Min.maps;
|
||||
|
||||
public class Map implements Comparable<Map>{
|
||||
/** Whether this is a custom map. */
|
||||
@@ -50,16 +50,20 @@ public class Map implements Comparable<Map>{
|
||||
}
|
||||
|
||||
public Map(StringMap tags){
|
||||
this(Vars.customMapDirectory.child(tags.get("name", "unknown")), 0, 0, tags, true);
|
||||
this(Min.customMapDirectory.child(tags.get("name", "unknown")), 0, 0, tags, true);
|
||||
}
|
||||
|
||||
public int getHightScore(){
|
||||
return Core.settings.getInt("hiscore" + file.nameWithoutExtension(), 0);
|
||||
}
|
||||
|
||||
public FileHandle previewFile(){
|
||||
return Min.mapPreviewDirectory.child(file.nameWithoutExtension() + ".png");
|
||||
}
|
||||
|
||||
public void setHighScore(int score){
|
||||
Core.settings.put("hiscore" + file.nameWithoutExtension(), score);
|
||||
Vars.data.modified();
|
||||
Min.data.modified();
|
||||
}
|
||||
|
||||
/** Returns the result of applying this map's rules to the specified gamemode.*/
|
||||
@@ -80,7 +84,7 @@ public class Map implements Comparable<Map>{
|
||||
public Rules rules(Rules base){
|
||||
try{
|
||||
Rules result = JsonIO.read(Rules.class, base, tags.get("rules", "{}"));
|
||||
if(result.spawns.isEmpty()) result.spawns = Vars.defaultWaves.get();
|
||||
if(result.spawns.isEmpty()) result.spawns = Min.defaultWaves.get();
|
||||
return result;
|
||||
}catch(Exception e){
|
||||
//error reading rules. ignore?
|
||||
@@ -94,7 +98,7 @@ public class Map implements Comparable<Map>{
|
||||
if(tags.getInt("build", -1) < 83 && tags.getInt("build", -1) != -1 && tags.get("genfilters", "").isEmpty()){
|
||||
return Array.with();
|
||||
}
|
||||
return world.maps.readFilters(tags.get("genfilters", ""));
|
||||
return maps.readFilters(tags.get("genfilters", ""));
|
||||
}
|
||||
|
||||
public String author(){
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.assets.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.function.*;
|
||||
import io.anuke.arc.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.async.*;
|
||||
import io.anuke.arc.util.serialization.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
@@ -16,9 +18,9 @@ import io.anuke.mindustry.world.blocks.storage.*;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Min.*;
|
||||
|
||||
public class Maps implements Disposable{
|
||||
public class Maps{
|
||||
/** List of all built-in maps. Filenames only. */
|
||||
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "veins", "glacier"};
|
||||
/** All maps stored in an ordered array. */
|
||||
@@ -26,6 +28,8 @@ public class Maps implements Disposable{
|
||||
/** Serializer for meta. */
|
||||
private Json json = new Json();
|
||||
|
||||
private AsyncExecutor executor = new AsyncExecutor(2);
|
||||
|
||||
/** Returns a list of all maps, including custom ones. */
|
||||
public Array<Map> all(){
|
||||
return maps;
|
||||
@@ -74,7 +78,13 @@ public class Maps implements Disposable{
|
||||
}
|
||||
|
||||
public void reload(){
|
||||
dispose();
|
||||
for(Map map : maps){
|
||||
if(map.texture != null){
|
||||
map.texture.dispose();
|
||||
map.texture = null;
|
||||
}
|
||||
}
|
||||
maps.clear();
|
||||
load();
|
||||
}
|
||||
|
||||
@@ -128,7 +138,10 @@ public class Maps implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
map.texture = new Texture(MapIO.generatePreview(world.getTiles()));
|
||||
Pixmap pix = MapIO.generatePreview(world.getTiles());
|
||||
executor.submit(() -> map.previewFile().writePNG(pix));
|
||||
|
||||
map.texture = new Texture(pix);
|
||||
}
|
||||
maps.add(map);
|
||||
maps.sort();
|
||||
@@ -284,6 +297,31 @@ public class Maps implements Disposable{
|
||||
}
|
||||
}
|
||||
|
||||
public void loadPreviews(){
|
||||
for(Map map : maps){
|
||||
try{
|
||||
//try to load preview
|
||||
if(map.previewFile().exists()){
|
||||
try{
|
||||
Core.assets.load(new AssetDescriptor<>(map.previewFile(), Texture.class)).loaded = t -> map.texture = (Texture)t;
|
||||
//if it works, keep going
|
||||
continue;
|
||||
}catch(Exception e){
|
||||
Log.err("Found cached preview, but failed to load it!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
//if it's here, then the preview failed to load or doesn't exist, make it
|
||||
//this has to be done synchronously!
|
||||
Pixmap pix = MapIO.generatePreview(map);
|
||||
Core.app.post(() -> map.texture = new Texture(pix));
|
||||
executor.submit(() -> map.previewFile().writePNG(pix));
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Find a new filename to put a map to. */
|
||||
private FileHandle findFile(){
|
||||
//find a map name that isn't used.
|
||||
@@ -301,10 +339,6 @@ public class Maps implements Disposable{
|
||||
throw new IOException("Map name cannot be empty! File: " + file);
|
||||
}
|
||||
|
||||
if(!headless){
|
||||
map.texture = new Texture(MapIO.generatePreview(map));
|
||||
}
|
||||
|
||||
maps.add(map);
|
||||
//maps.sort();
|
||||
}
|
||||
@@ -321,15 +355,4 @@ public class Maps implements Disposable{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose(){
|
||||
for(Map map : maps){
|
||||
if(map.texture != null){
|
||||
map.texture.dispose();
|
||||
map.texture = null;
|
||||
}
|
||||
}
|
||||
maps.clear();
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.Block.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.updateEditorOnChange;
|
||||
import static io.anuke.mindustry.Min.updateEditorOnChange;
|
||||
|
||||
public abstract class FilterOption{
|
||||
public static final Predicate<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(Icon.full));
|
||||
@@ -81,7 +81,7 @@ public abstract class FilterOption{
|
||||
FloatingDialog dialog = new FloatingDialog("");
|
||||
dialog.setFillParent(false);
|
||||
int i = 0;
|
||||
for(Block block : Vars.content.blocks()){
|
||||
for(Block block : Min.content.blocks()){
|
||||
if(!filter.test(block)) continue;
|
||||
|
||||
dialog.cont.addImage(block == Blocks.air ? Core.atlas.find("icon-none-small") : block.icon(Icon.medium)).size(8 * 4).pad(3).get().clicked(() -> {
|
||||
|
||||
@@ -5,7 +5,7 @@ import io.anuke.arc.math.*;
|
||||
import io.anuke.mindustry.maps.filters.FilterOption.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.content;
|
||||
import static io.anuke.mindustry.Min.content;
|
||||
|
||||
public class MedianFilter extends GenerateFilter{
|
||||
float radius = 2;
|
||||
|
||||
@@ -52,6 +52,6 @@ public class OreMedianFilter extends GenerateFilter{
|
||||
int index = Math.min((int)(blocks.size * percentile), blocks.size - 1);
|
||||
int overlay = blocks.get(index);
|
||||
|
||||
in.ore = Vars.content.block(overlay);
|
||||
in.ore = Min.content.block(overlay);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.storage.*;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import static io.anuke.mindustry.Min.*;
|
||||
|
||||
public class MapGenerator extends Generator{
|
||||
private Map map;
|
||||
@@ -51,7 +51,7 @@ public class MapGenerator extends Generator{
|
||||
@Override
|
||||
public void init(Loadout loadout){
|
||||
this.loadout = loadout;
|
||||
map = world.maps.loadInternalMap(mapName);
|
||||
map = maps.loadInternalMap(mapName);
|
||||
width = map.width;
|
||||
height = map.height;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
|
||||
import static io.anuke.mindustry.Vars.world;
|
||||
import static io.anuke.mindustry.Min.world;
|
||||
|
||||
public abstract class RandomGenerator extends Generator{
|
||||
protected Block floor;
|
||||
|
||||
Reference in New Issue
Block a user