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