mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 02:37:12 +07:00
Better loading screen / Fixed unit tests
This commit is contained in:
parent
5dfc3fd576
commit
bd15287420
@ -36,11 +36,11 @@ public class ClientLauncher extends ApplicationCore{
|
||||
batch = new SpriteBatch();
|
||||
assets = new AssetManager();
|
||||
atlas = TextureAtlas.blankAtlas();
|
||||
assets.load("sprites/logo.png", Texture.class);
|
||||
assets.finishLoading();
|
||||
|
||||
Time.mark();
|
||||
UI.loadDefaultFont();
|
||||
UI.loadSystemCursors();
|
||||
Log.info("UI init: {0}", Time.elapsed());
|
||||
|
||||
assets.load(new Vars());
|
||||
assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t;
|
||||
@ -88,16 +88,17 @@ public class ClientLauncher extends ApplicationCore{
|
||||
|
||||
@Override
|
||||
public void update(){
|
||||
if(!assets.update(1000 / loadingFPS)){
|
||||
if(!finished){
|
||||
drawLoading();
|
||||
}else{
|
||||
if(!finished){
|
||||
Log.info("Time to load: {0}", Time.timeSinceMillis(beginTime));
|
||||
post();
|
||||
if(assets.update(1000 / loadingFPS)){
|
||||
Log.info("Total time to load: {0}", Time.timeSinceMillis(beginTime));
|
||||
for(ApplicationListener listener : modules){
|
||||
listener.init();
|
||||
}
|
||||
finished = true;
|
||||
Events.fire(new ClientLoadEvent());
|
||||
}
|
||||
|
||||
}else{
|
||||
super.update();
|
||||
}
|
||||
|
||||
@ -134,18 +135,43 @@ public class ClientLauncher extends ApplicationCore{
|
||||
smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f);
|
||||
smoothTime += Time.delta();
|
||||
|
||||
Core.graphics.clear(Color.BLACK);
|
||||
Core.graphics.clear(Pal.darkerGray);
|
||||
Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
|
||||
|
||||
float height = UnitScl.dp.scl(50f);
|
||||
Texture logo = Core.assets.get("sprites/logo.png");
|
||||
float logoscl = UnitScl.dp.scl(1);
|
||||
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - UnitScl.dp.scl(20));
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
|
||||
float fx = (int)(Core.graphics.getWidth() / 2f);
|
||||
float fy = (int)(Core.graphics.getHeight() - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? UnitScl.dp.scl(30f) : 0f);
|
||||
|
||||
Draw.color();
|
||||
|
||||
//Draw.rect(Draw.wrap(logo), fx, fy, logow, logoh);
|
||||
|
||||
Lines.stroke(graphics.getWidth()*10, Color.BLACK);
|
||||
Tmp.v1.set(graphics.getWidth(), graphics.getHeight()).scl(smoothProgress);
|
||||
Fill.poly(graphics.getWidth()/2f, graphics.getHeight()/2f, 6, Mathf.dst(graphics.getWidth()/2f, graphics.getHeight()/2f) * smoothProgress);
|
||||
//Lines.line(0, 0, Tmp.v1.x, Tmp.v1.y, CapStyle.none);
|
||||
Draw.reset();
|
||||
|
||||
float w = graphics.getWidth()*0.6f;
|
||||
|
||||
Draw.color(Pal.darkerGray);
|
||||
Fill.rect(graphics.getWidth()/2f, graphics.getHeight()/2f, graphics.getWidth(), height);
|
||||
Draw.color(Pal.accent, Color.WHITE, Mathf.absin(smoothTime, 5f, 1f) * 0.5f);
|
||||
Fill.crect(0, graphics.getHeight()/2f - height/2f, graphics.getWidth() * smoothProgress, height);
|
||||
Fill.rect(graphics.getWidth()/2f, graphics.getHeight()/2f, w, height);
|
||||
|
||||
Draw.color(Pal.accent);
|
||||
Fill.crect(graphics.getWidth()/2f-w/2f, graphics.getHeight()/2f - height/2f, w * smoothProgress, height);
|
||||
|
||||
for(int i : Mathf.signs){
|
||||
Fill.tri(graphics.getWidth()/2f + w/2f*i, graphics.getHeight()/2f + height/2f, graphics.getWidth()/2f + w/2f*i, graphics.getHeight()/2f - height/2f, graphics.getWidth()/2f + w/2f*i + height/2f*i, graphics.getHeight()/2f);
|
||||
}
|
||||
|
||||
if(assets.isLoaded("outline")){
|
||||
BitmapFont font = assets.get("outline");
|
||||
font.draw((int)(assets.getProgress() * 100) + "%", graphics.getWidth() / 2f, graphics.getHeight() / 2f, Align.center);
|
||||
font.draw((int)(assets.getProgress() * 100) + "%", graphics.getWidth() / 2f, graphics.getHeight() / 2f + UnitScl.dp.scl(10f), Align.center);
|
||||
|
||||
if(assets.getCurrentLoading() != null){
|
||||
String name = assets.getCurrentLoading().fileName.toLowerCase();
|
||||
|
@ -85,4 +85,6 @@ public class Drawf{
|
||||
float oy = 17f / 63f * length;
|
||||
Draw.rect(Core.atlas.find("shape-3"), x, y - oy + length / 2f, width, length, width / 2f, oy, rotation - 90);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public class Zone extends UnlockableContent{
|
||||
super(name);
|
||||
this.generator = generator;
|
||||
|
||||
if(!headless){
|
||||
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;
|
||||
|
@ -22,7 +22,6 @@ import io.anuke.mindustry.ui.MobileButton;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class MenuFragment extends Fragment{
|
||||
private Texture logo = new Texture("sprites/logo.png");
|
||||
private Table container, submenu;
|
||||
private Button currentMenu;
|
||||
private MenuRenderer renderer;
|
||||
@ -30,10 +29,22 @@ public class MenuFragment extends Fragment{
|
||||
public MenuFragment(){
|
||||
Events.on(DisposeEvent.class, event -> {
|
||||
renderer.dispose();
|
||||
logo.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
public static void drawLogo(){
|
||||
Texture logo = Core.assets.get("sprites/logo.png");
|
||||
float logoscl = UnitScl.dp.scl(1);
|
||||
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - UnitScl.dp.scl(20));
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
|
||||
float fx = (int)(Core.graphics.getWidth() / 2f);
|
||||
float fy = (int)(Core.graphics.getHeight() - 6 - logoh) + logoh / 2 - (Core.graphics.isPortrait() ? UnitScl.dp.scl(30f) : 0f);
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(Draw.wrap(logo), fx, fy, logow, logoh);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build(Group parent){
|
||||
renderer = new MenuRenderer();
|
||||
@ -72,6 +83,7 @@ public class MenuFragment extends Fragment{
|
||||
String versionText = "[#ffffffba]" + ((Version.build == -1) ? "[#fc8140aa]custom build" : Version.modifier + " build " + Version.build);
|
||||
|
||||
parent.fill((x, y, w, h) -> {
|
||||
Texture logo = Core.assets.get("sprites/logo.png");
|
||||
float logoscl = UnitScl.dp.scl(1);
|
||||
float logow = Math.min(logo.getWidth() * logoscl, Core.graphics.getWidth() - UnitScl.dp.scl(20));
|
||||
float logoh = logow * (float)logo.getHeight() / logo.getWidth();
|
||||
@ -81,6 +93,7 @@ public class MenuFragment extends Fragment{
|
||||
|
||||
Draw.color();
|
||||
Draw.rect(Draw.wrap(logo), fx, fy, logow, logoh);
|
||||
|
||||
Core.scene.skin.font().setColor(Color.WHITE);
|
||||
Core.scene.skin.font().draw(versionText, fx, fy - logoh/2f, Align.center);
|
||||
}).touchable(Touchable.disabled);
|
||||
|
@ -24,7 +24,6 @@ public class MindustryServer implements ApplicationListener{
|
||||
loadSettings();
|
||||
|
||||
Core.app.addListener(logic = new Logic());
|
||||
Core.app.addListener(world = new World());
|
||||
Core.app.addListener(netServer = new NetServer());
|
||||
Core.app.addListener(new ServerControl(args));
|
||||
|
||||
|
@ -1,33 +1,33 @@
|
||||
package io.anuke.mindustry.server;
|
||||
|
||||
import io.anuke.arc.*;
|
||||
import io.anuke.arc.collection.Array;
|
||||
import io.anuke.arc.collection.Array.ArrayIterable;
|
||||
import io.anuke.arc.collection.ObjectSet;
|
||||
import io.anuke.arc.files.FileHandle;
|
||||
import io.anuke.arc.collection.*;
|
||||
import io.anuke.arc.collection.Array.*;
|
||||
import io.anuke.arc.files.*;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.Timer;
|
||||
import io.anuke.arc.util.CommandHandler.*;
|
||||
import io.anuke.arc.util.Timer.Task;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
import io.anuke.mindustry.entities.type.Player;
|
||||
import io.anuke.arc.util.Timer.*;
|
||||
import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.core.GameState.*;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.game.*;
|
||||
import io.anuke.mindustry.game.EventType.GameOverEvent;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.game.EventType.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.io.*;
|
||||
import io.anuke.mindustry.maps.Map;
|
||||
import io.anuke.mindustry.maps.MapException;
|
||||
import io.anuke.mindustry.net.Administration.PlayerInfo;
|
||||
import io.anuke.mindustry.maps.*;
|
||||
import io.anuke.mindustry.net.Administration.*;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.Packets.KickReason;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemType;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.mindustry.type.*;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.*;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Scanner;
|
||||
import java.time.*;
|
||||
import java.time.format.*;
|
||||
import java.util.*;
|
||||
|
||||
import static io.anuke.arc.util.Log.*;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
@ -144,7 +144,7 @@ public class ServerControl implements ApplicationListener{
|
||||
|
||||
if(Core.settings.getBool("shuffle")){
|
||||
if(maps.all().size > 0){
|
||||
Array<Map> maps = maps.customMaps().size == 0 ? maps.defaultMaps() : maps.customMaps();
|
||||
Array<Map> maps = Vars.maps.customMaps().size == 0 ? Vars.maps.defaultMaps() : Vars.maps.customMaps();
|
||||
|
||||
Map previous = world.getMap();
|
||||
Map map = maps.random(previous);
|
||||
|
@ -41,16 +41,13 @@ public class ApplicationTests{
|
||||
ApplicationCore core = new ApplicationCore(){
|
||||
@Override
|
||||
public void setup(){
|
||||
headless = true;
|
||||
Vars.init();
|
||||
|
||||
headless = true;
|
||||
|
||||
load();
|
||||
content.createContent();
|
||||
|
||||
add(logic = new Logic());
|
||||
add(world = new World());
|
||||
add(netServer = new NetServer());
|
||||
|
||||
content.init();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -32,7 +32,6 @@ public class PowerTestFixture{
|
||||
static void initializeDependencies(){
|
||||
Core.graphics = new FakeGraphics();
|
||||
Vars.content = new ContentLoader();
|
||||
Vars.content.createContent();
|
||||
Log.setUseColors(false);
|
||||
Time.setDeltaProvider(() -> 0.5f);
|
||||
}
|
||||
|
@ -23,7 +23,6 @@ public class ImagePacker{
|
||||
|
||||
Log.setLogger(new NoopLogHandler());
|
||||
Vars.content = new ContentLoader();
|
||||
Vars.content.createContent();
|
||||
Log.setLogger(new LogHandler());
|
||||
|
||||
Files.walk(Paths.get("../../../assets-raw/sprites_out")).forEach(path -> {
|
||||
|
Loading…
Reference in New Issue
Block a user