Put zone previews into atlas
This commit is contained in:
@@ -8,6 +8,7 @@ import io.anuke.arc.math.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
@@ -19,7 +20,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
public class ClientLauncher extends ApplicationCore{
|
||||
private static final int loadingFPS = 20;
|
||||
|
||||
private float smoothProgress, smoothTime;
|
||||
private float smoothProgress;
|
||||
private long lastTime;
|
||||
private long beginTime;
|
||||
private boolean finished = false;
|
||||
@@ -42,12 +43,23 @@ public class ClientLauncher extends ApplicationCore{
|
||||
UI.loadDefaultFont();
|
||||
UI.loadSystemCursors();
|
||||
|
||||
//1. bundles
|
||||
//2. rest of vars
|
||||
assets.load(new Vars());
|
||||
assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t;
|
||||
|
||||
assets.loadRun("maps", Map.class, () -> {
|
||||
maps.loadPreviews();
|
||||
});
|
||||
|
||||
Musics.load();
|
||||
Sounds.load();
|
||||
|
||||
assets.loadRun("contentcreate", Content.class, () -> {
|
||||
content.createContent();
|
||||
content.loadColors();
|
||||
});
|
||||
|
||||
add(logic = new Logic());
|
||||
add(control = new Control());
|
||||
add(renderer = new Renderer());
|
||||
@@ -55,7 +67,7 @@ public class ClientLauncher extends ApplicationCore{
|
||||
add(netServer = new NetServer());
|
||||
add(netClient = new NetClient());
|
||||
|
||||
assets.loadRun("Content", ContentLoader.class, () -> {
|
||||
assets.loadRun("contentinit", ContentLoader.class, () -> {
|
||||
content.init();
|
||||
content.load();
|
||||
});
|
||||
@@ -133,7 +145,6 @@ public class ClientLauncher extends ApplicationCore{
|
||||
|
||||
void drawLoading(){
|
||||
smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f);
|
||||
smoothTime += Time.delta();
|
||||
|
||||
Core.graphics.clear(Pal.darkerGray);
|
||||
Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
@@ -163,7 +174,7 @@ public class ClientLauncher extends ApplicationCore{
|
||||
|
||||
if(assets.getCurrentLoading() != null){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,10 +239,6 @@ public class Vars implements Loadable{
|
||||
tmpDirectory = dataDirectory.child("tmp/");
|
||||
|
||||
maps.load();
|
||||
if(!headless){
|
||||
content.loadColors();
|
||||
maps.loadPreviews();
|
||||
}
|
||||
}
|
||||
|
||||
public static void loadSettings(){
|
||||
@@ -251,6 +247,8 @@ public class Vars implements Loadable{
|
||||
Core.keybinds.setDefaults(Binding.values());
|
||||
Core.settings.load();
|
||||
|
||||
if(!loadLocales) return;
|
||||
|
||||
try{
|
||||
//try loading external 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.graphics.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
@@ -42,14 +41,8 @@ public class ContentLoader{
|
||||
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. */
|
||||
private void createContent(){
|
||||
public void createContent(){
|
||||
if(loaded){
|
||||
Log.info("Content already loaded, skipping.");
|
||||
return;
|
||||
|
||||
@@ -43,9 +43,6 @@ public class Renderer implements ApplicationListener{
|
||||
|
||||
public Renderer(){
|
||||
camera = new Camera();
|
||||
if(settings.getBool("bloom")){
|
||||
setupBloom();
|
||||
}
|
||||
Shaders.init();
|
||||
|
||||
Effects.setScreenShakeProvider((intensity, duration) -> {
|
||||
@@ -93,6 +90,13 @@ public class Renderer implements ApplicationListener{
|
||||
clearColor = new Color(0f, 0f, 0f, 1f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
if(settings.getBool("bloom")){
|
||||
setupBloom();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
//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.loaders.*;
|
||||
import io.anuke.arc.assets.loaders.resolvers.*;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
|
||||
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 Map map;
|
||||
|
||||
|
||||
@@ -323,8 +323,6 @@ public class Maps{
|
||||
}catch(Exception ignored){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void createNewPreview(Map map){
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package io.anuke.mindustry.type;
|
||||
|
||||
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.graphics.g2d.*;
|
||||
import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.util.*;
|
||||
@@ -30,7 +27,7 @@ public class Zone extends UnlockableContent{
|
||||
public int configureWave = 15;
|
||||
public int launchPeriod = 10;
|
||||
public Loadout loadout = Loadouts.basicShard;
|
||||
public Texture preview;
|
||||
public TextureRegion preview;
|
||||
|
||||
protected ItemStack[] baseLaunchCost = {};
|
||||
protected Array<ItemStack> startingItems = new Array<>();
|
||||
@@ -41,13 +38,11 @@ public class Zone extends UnlockableContent{
|
||||
public Zone(String name, Generator generator){
|
||||
super(name);
|
||||
this.generator = generator;
|
||||
}
|
||||
|
||||
if(!headless && Core.assets != null){
|
||||
FileHandle file = Core.files.internal("zones/" + name + ".png");
|
||||
if(file.exists()){
|
||||
Core.assets.load(new AssetDescriptor<>(file, Texture.class)).loaded = t -> preview = (Texture)t;
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void load(){
|
||||
preview = Core.atlas.find(name);
|
||||
}
|
||||
|
||||
public Rules getRules(){
|
||||
|
||||
@@ -14,9 +14,8 @@ import io.anuke.arc.scene.ui.layout.*;
|
||||
import io.anuke.arc.scene.utils.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.mindustry.content.*;
|
||||
import io.anuke.mindustry.core.*;
|
||||
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.graphics.*;
|
||||
import io.anuke.mindustry.io.SaveIO.*;
|
||||
@@ -33,13 +32,10 @@ public class DeployDialog extends FloatingDialog{
|
||||
private ObjectSet<ZoneNode> nodes = new ObjectSet<>();
|
||||
private ZoneInfoDialog info = new ZoneInfoDialog();
|
||||
private Rectangle bounds = new Rectangle();
|
||||
private Texture nomap = new Texture("zones/nomap.png");
|
||||
|
||||
public DeployDialog(){
|
||||
super("", "fulldialog");
|
||||
|
||||
Events.on(DisposeEvent.class, e -> nomap.dispose());
|
||||
|
||||
ZoneNode root = new ZoneNode(Zones.groundZero, null);
|
||||
|
||||
TreeLayout layout = new TreeLayout();
|
||||
@@ -195,7 +191,7 @@ public class DeployDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
Button button = new Button("square");
|
||||
|
||||
Reference in New Issue
Block a user