Put zone previews into atlas

This commit is contained in:
Anuken
2019-08-27 19:33:41 -04:00
parent 40405332ec
commit 5134aca723
32 changed files with 1176 additions and 1075 deletions

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

+8
View File
@@ -0,0 +1,8 @@
{
duplicatePadding: true,
combineSubdirectories: true,
flattenPaths: true,
maxWidth: 2048,
maxHeight: 2048,
fast: true
}

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 718 B

After

Width:  |  Height:  |  Size: 719 B

File diff suppressed because it is too large Load Diff
Binary file not shown.

Before

Width:  |  Height:  |  Size: 672 KiB

After

Width:  |  Height:  |  Size: 682 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 258 KiB

After

Width:  |  Height:  |  Size: 274 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 278 KiB

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 581 KiB

After

Width:  |  Height:  |  Size: 278 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 586 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.7 KiB

@@ -8,6 +8,7 @@ import io.anuke.arc.math.*;
import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.core.*; import io.anuke.mindustry.core.*;
import io.anuke.mindustry.game.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.gen.*; import io.anuke.mindustry.gen.*;
import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.graphics.*;
@@ -19,7 +20,7 @@ import static io.anuke.mindustry.Vars.*;
public class ClientLauncher extends ApplicationCore{ public class ClientLauncher extends ApplicationCore{
private static final int loadingFPS = 20; private static final int loadingFPS = 20;
private float smoothProgress, smoothTime; private float smoothProgress;
private long lastTime; private long lastTime;
private long beginTime; private long beginTime;
private boolean finished = false; private boolean finished = false;
@@ -42,12 +43,23 @@ public class ClientLauncher extends ApplicationCore{
UI.loadDefaultFont(); UI.loadDefaultFont();
UI.loadSystemCursors(); UI.loadSystemCursors();
//1. bundles
//2. rest of vars
assets.load(new Vars()); assets.load(new Vars());
assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t; assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t;
assets.loadRun("maps", Map.class, () -> {
maps.loadPreviews();
});
Musics.load(); Musics.load();
Sounds.load(); Sounds.load();
assets.loadRun("contentcreate", Content.class, () -> {
content.createContent();
content.loadColors();
});
add(logic = new Logic()); add(logic = new Logic());
add(control = new Control()); add(control = new Control());
add(renderer = new Renderer()); add(renderer = new Renderer());
@@ -55,7 +67,7 @@ public class ClientLauncher extends ApplicationCore{
add(netServer = new NetServer()); add(netServer = new NetServer());
add(netClient = new NetClient()); add(netClient = new NetClient());
assets.loadRun("Content", ContentLoader.class, () -> { assets.loadRun("contentinit", ContentLoader.class, () -> {
content.init(); content.init();
content.load(); content.load();
}); });
@@ -133,7 +145,6 @@ public class ClientLauncher extends ApplicationCore{
void drawLoading(){ void drawLoading(){
smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f); smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f);
smoothTime += Time.delta();
Core.graphics.clear(Pal.darkerGray); Core.graphics.clear(Pal.darkerGray);
Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight()); Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
@@ -163,7 +174,7 @@ public class ClientLauncher extends ApplicationCore{
if(assets.getCurrentLoading() != null){ if(assets.getCurrentLoading() != null){
String name = assets.getCurrentLoading().fileName.toLowerCase(); String name = assets.getCurrentLoading().fileName.toLowerCase();
String key = name.contains("content") ? "content" : name.contains("msav") ? "map" : name.contains("ogg") || name.contains("mp3") ? "sound" : name.contains("png") ? "image" : "system"; String key = name.contains("content") ? "content" : name.contains("msav") || name.contains("maps") ? "map" : name.contains("ogg") || name.contains("mp3") ? "sound" : name.contains("png") ? "image" : "system";
font.draw(bundle.get("load." + key, ""), graphics.getWidth() / 2f, graphics.getHeight() / 2f - height / 2f - UnitScl.dp.scl(10f), Align.center); font.draw(bundle.get("load." + key, ""), graphics.getWidth() / 2f, graphics.getHeight() / 2f - height / 2f - UnitScl.dp.scl(10f), Align.center);
} }
} }
+2 -4
View File
@@ -239,10 +239,6 @@ public class Vars implements Loadable{
tmpDirectory = dataDirectory.child("tmp/"); tmpDirectory = dataDirectory.child("tmp/");
maps.load(); maps.load();
if(!headless){
content.loadColors();
maps.loadPreviews();
}
} }
public static void loadSettings(){ public static void loadSettings(){
@@ -251,6 +247,8 @@ public class Vars implements Loadable{
Core.keybinds.setDefaults(Binding.values()); Core.keybinds.setDefaults(Binding.values());
Core.settings.load(); Core.settings.load();
if(!loadLocales) return;
try{ try{
//try loading external bundle //try loading external bundle
FileHandle handle = Core.files.local("bundle"); FileHandle handle = Core.files.local("bundle");
@@ -4,7 +4,6 @@ import io.anuke.arc.collection.*;
import io.anuke.arc.function.*; import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.*;
import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.*;
import io.anuke.mindustry.entities.bullet.*; import io.anuke.mindustry.entities.bullet.*;
import io.anuke.mindustry.game.*; import io.anuke.mindustry.game.*;
@@ -42,14 +41,8 @@ public class ContentLoader{
new LegacyColorMapper(), new LegacyColorMapper(),
}; };
public ContentLoader(){
//hack; allows content to initialize itself by referring to Mins.content, even though it hasn't been fully constructed yet
Vars.content = this;
createContent();
}
/** Creates all content types. */ /** Creates all content types. */
private void createContent(){ public void createContent(){
if(loaded){ if(loaded){
Log.info("Content already loaded, skipping."); Log.info("Content already loaded, skipping.");
return; return;
@@ -43,9 +43,6 @@ public class Renderer implements ApplicationListener{
public Renderer(){ public Renderer(){
camera = new Camera(); camera = new Camera();
if(settings.getBool("bloom")){
setupBloom();
}
Shaders.init(); Shaders.init();
Effects.setScreenShakeProvider((intensity, duration) -> { Effects.setScreenShakeProvider((intensity, duration) -> {
@@ -93,6 +90,13 @@ public class Renderer implements ApplicationListener{
clearColor = new Color(0f, 0f, 0f, 1f); clearColor = new Color(0f, 0f, 0f, 1f);
} }
@Override
public void init(){
if(settings.getBool("bloom")){
setupBloom();
}
}
@Override @Override
public void update(){ public void update(){
//TODO hack, find source of this bug //TODO hack, find source of this bug
@@ -3,8 +3,10 @@ package io.anuke.mindustry.maps;
import io.anuke.arc.assets.*; import io.anuke.arc.assets.*;
import io.anuke.arc.assets.loaders.*; import io.anuke.arc.assets.loaders.*;
import io.anuke.arc.assets.loaders.resolvers.*; import io.anuke.arc.assets.loaders.resolvers.*;
import io.anuke.arc.collection.*;
import io.anuke.arc.files.*; import io.anuke.arc.files.*;
import io.anuke.mindustry.*; import io.anuke.mindustry.*;
import io.anuke.mindustry.game.*;
public class MapPreviewLoader extends TextureLoader{ public class MapPreviewLoader extends TextureLoader{
@@ -23,6 +25,11 @@ public class MapPreviewLoader extends TextureLoader{
} }
} }
@Override
public Array<AssetDescriptor> getDependencies(String fileName, FileHandle file, TextureParameter parameter){
return Array.with(new AssetDescriptor<>("contentcreate", Content.class));
}
public static class MapPreviewParameter extends TextureParameter{ public static class MapPreviewParameter extends TextureParameter{
public Map map; public Map map;
@@ -323,8 +323,6 @@ public class Maps{
}catch(Exception ignored){ }catch(Exception ignored){
} }
} }
} }
public void createNewPreview(Map map){ public void createNewPreview(Map map){
+5 -10
View File
@@ -1,11 +1,8 @@
package io.anuke.mindustry.type; package io.anuke.mindustry.type;
import io.anuke.arc.*; import io.anuke.arc.*;
import io.anuke.arc.assets.*;
import io.anuke.arc.collection.*; import io.anuke.arc.collection.*;
import io.anuke.arc.files.*;
import io.anuke.arc.function.*; import io.anuke.arc.function.*;
import io.anuke.arc.graphics.*;
import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.graphics.g2d.*;
import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
@@ -30,7 +27,7 @@ public class Zone extends UnlockableContent{
public int configureWave = 15; public int configureWave = 15;
public int launchPeriod = 10; public int launchPeriod = 10;
public Loadout loadout = Loadouts.basicShard; public Loadout loadout = Loadouts.basicShard;
public Texture preview; public TextureRegion preview;
protected ItemStack[] baseLaunchCost = {}; protected ItemStack[] baseLaunchCost = {};
protected Array<ItemStack> startingItems = new Array<>(); protected Array<ItemStack> startingItems = new Array<>();
@@ -41,13 +38,11 @@ public class Zone extends UnlockableContent{
public Zone(String name, Generator generator){ public Zone(String name, Generator generator){
super(name); super(name);
this.generator = generator; this.generator = generator;
}
if(!headless && Core.assets != null){ @Override
FileHandle file = Core.files.internal("zones/" + name + ".png"); public void load(){
if(file.exists()){ preview = Core.atlas.find(name);
Core.assets.load(new AssetDescriptor<>(file, Texture.class)).loaded = t -> preview = (Texture)t;
}
}
} }
public Rules getRules(){ public Rules getRules(){
@@ -14,9 +14,8 @@ import io.anuke.arc.scene.ui.layout.*;
import io.anuke.arc.scene.utils.*; import io.anuke.arc.scene.utils.*;
import io.anuke.arc.util.*; import io.anuke.arc.util.*;
import io.anuke.mindustry.content.*; import io.anuke.mindustry.content.*;
import io.anuke.mindustry.core.*;
import io.anuke.mindustry.core.GameState.*; import io.anuke.mindustry.core.GameState.*;
import io.anuke.mindustry.game.EventType.*; import io.anuke.mindustry.core.*;
import io.anuke.mindustry.game.Saves.*; import io.anuke.mindustry.game.Saves.*;
import io.anuke.mindustry.graphics.*; import io.anuke.mindustry.graphics.*;
import io.anuke.mindustry.io.SaveIO.*; import io.anuke.mindustry.io.SaveIO.*;
@@ -33,13 +32,10 @@ public class DeployDialog extends FloatingDialog{
private ObjectSet<ZoneNode> nodes = new ObjectSet<>(); private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
private ZoneInfoDialog info = new ZoneInfoDialog(); private ZoneInfoDialog info = new ZoneInfoDialog();
private Rectangle bounds = new Rectangle(); private Rectangle bounds = new Rectangle();
private Texture nomap = new Texture("zones/nomap.png");
public DeployDialog(){ public DeployDialog(){
super("", "fulldialog"); super("", "fulldialog");
Events.on(DisposeEvent.class, e -> nomap.dispose());
ZoneNode root = new ZoneNode(Zones.groundZero, null); ZoneNode root = new ZoneNode(Zones.groundZero, null);
TreeLayout layout = new TreeLayout(); TreeLayout layout = new TreeLayout();
@@ -195,7 +191,7 @@ public class DeployDialog extends FloatingDialog{
} }
stack.setSize(Tmp.v1.x, Tmp.v1.y); stack.setSize(Tmp.v1.x, Tmp.v1.y);
stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview != null ? node.zone.preview : nomap).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.DARK_GRAY : Color.fromGray(0.2f)).grow())); stack.add(new Table(t -> t.margin(4f).add(new Image(node.zone.preview).setScaling(Scaling.stretch)).color(node.zone.unlocked() ? Color.DARK_GRAY : Color.fromGray(0.2f)).grow()));
stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center)); stack.update(() -> stack.setPosition(node.x + panX + width / 2f, node.y + panY + height / 2f, Align.center));
Button button = new Button("square"); Button button = new Button("square");
@@ -17,11 +17,11 @@ public class MindustryServer implements ApplicationListener{
public void init(){ public void init(){
Core.settings.setDataDirectory(Core.files.local("config")); Core.settings.setDataDirectory(Core.files.local("config"));
loadLocales = false; loadLocales = false;
Vars.init();
headless = true; headless = true;
loadSettings(); Vars.loadSettings();
Vars.init();
content.createContent();
Core.app.addListener(logic = new Logic()); Core.app.addListener(logic = new Logic());
Core.app.addListener(netServer = new NetServer()); Core.app.addListener(netServer = new NetServer());
+1 -1
View File
@@ -320,7 +320,7 @@ task pack(dependsOn: classes){
//antialias everything except UI elements //antialias everything except UI elements
fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file -> fileTree(dir: '../core/assets-raw/sprites_out/', include: "**/*.png").visit{ file ->
if(file.isDirectory() || (file.toString().replace("\\", "/").contains("/ui/") && !file.toString().contains("icon-small") && !file.toString().contains("icon-medium") && !file.toString().contains("icon-large"))) return if(file.isDirectory() || file.toString().replace("\\", "/").contains("zones/") || (file.toString().replace("\\", "/").contains("/ui/") && !file.toString().contains("icon-small") && !file.toString().contains("icon-medium") && !file.toString().contains("icon-large"))) return
antialias(file.file) antialias(file.file)
} }
@@ -23,6 +23,7 @@ public class ImagePacker{
Log.setLogger(new NoopLogHandler()); Log.setLogger(new NoopLogHandler());
Vars.content = new ContentLoader(); Vars.content = new ContentLoader();
Vars.content.createContent();
Log.setLogger(new LogHandler()); Log.setLogger(new LogHandler());
Files.walk(Paths.get("../../../assets-raw/sprites_out")).forEach(path -> { Files.walk(Paths.get("../../../assets-raw/sprites_out")).forEach(path -> {