1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 03:31:19 +03:00

Early prototype loading screen

This commit is contained in:
Anuken 2020-05-05 23:01:12 -04:00
parent 346ac88009
commit 8b5adca750
5 changed files with 248 additions and 10 deletions

View File

@ -146,6 +146,7 @@ public class AndroidLauncher extends AndroidApplication{
useImmersiveMode = true;
hideStatusBar = true;
errorHandler = CrashSender::log;
stencil = 8;
}});
checkFiles(getIntent());

View File

@ -6,8 +6,10 @@ import arc.assets.loaders.*;
import arc.audio.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import arc.input.*;
import arc.math.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import arc.util.async.*;
import mindustry.core.*;
@ -16,10 +18,13 @@ import mindustry.game.EventType.*;
import mindustry.gen.*;
import mindustry.graphics.*;
import mindustry.maps.*;
import mindustry.maps.Map;
import mindustry.mod.*;
import mindustry.net.Net;
import mindustry.ui.*;
import java.util.*;
import static arc.Core.*;
import static mindustry.Vars.*;
@ -30,6 +35,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
private long lastTime;
private long beginTime;
private boolean finished = false;
private FloatArray floats = new FloatArray();
@Override
public void setup(){
@ -120,7 +126,7 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
public void update(){
if(!finished){
drawLoading();
if(assets.update(1000 / loadingFPS)){
if(false && assets.update(1000 / loadingFPS)){
Log.info("Total time to load: @", Time.timeSinceMillis(beginTime));
for(ApplicationListener listener : modules){
listener.init();
@ -171,12 +177,239 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
}
}
float testprogress = 0f;
static String[] properties = new String[4];
static Color color = new Color(Pal.accent).lerp(Color.black, 0.5f);
static{
String red = "[#" + Color.scarlet.cpy().a(0.5f).toString() + "]";
String orange = "[#" + color.toString() + "]";
for(int i = 0; i < 4; i++){
Properties props = System.getProperties();
StringBuilder builder = new StringBuilder();
for(Object key : props.keySet()){
String str = (String)key;
if(Mathf.chance(0.6)){
builder.append(orange);
if(Mathf.chance(0.2)) builder.append(red);
builder.append(str).append("::").append(props.get(str)).append("[]\n");
if(Mathf.chance(0.3)){
builder.append("\n");
}
}
}
properties[i] = builder.toString();
}
}
void drawLoading(){
smoothProgress = Mathf.lerpDelta(smoothProgress, assets.getProgress(), 0.1f);
Core.graphics.clear(Pal.darkerGray);
Core.graphics.clear(Color.black);
float w = Core.graphics.getWidth(), h = Core.graphics.getHeight(), s = Scl.scl();
Lines.precise(true);
Draw.proj().setOrtho(0, 0, Core.graphics.getWidth(), Core.graphics.getHeight());
int lightVerts = 20;
float lightRad = Math.max(w, h)*0.6f;
//light
if(true){
Fill.light(w/2, h/2, lightVerts, lightRad, Tmp.c1.set(Pal.accent).a(0.15f), Color.clear);
}
float space = Scl.scl(60);
float progress = assets.getProgress();
int dotw = (int)(w / space)/2 + 1;
int doth = (int)(h / space)/2 + 1;
//TODO remove
if(true){
testprogress += Time.delta() / (60f * 3);
progress = testprogress;
if(input.keyTap(KeyCode.space)){
testprogress = 0;
}
}
//dot matrix
if(false){
Draw.color(Pal.accent);
Draw.alpha(0.3f);
for(int cx = -dotw; cx <= dotw; cx++){
for(int cy = -doth; cy <= doth; cy++){
float dx = cx * space + w/2f, dy = cy * space + h/2f;
Fill.square(dx, dy, 1.5f*s, 45);
}
}
Draw.reset();
}
//square matrix
if(true){
Draw.color(Pal.accent);
Draw.alpha(0.1f);
Lines.stroke(s*3f);
for(int cx = -dotw; cx <= dotw; cx++){
for(int cy = -doth; cy <= doth; cy++){
float dx = cx * space + w/2f, dy = cy * space + h/2f;
Lines.poly(dx, dy, 4, space/2f);
}
}
}
//bars
if(false){
Draw.color(Pal.accent, Color.black, 0.7f);
for(int cx = -dotw; cx <= dotw; cx++){
float height = 400f * s * Mathf.randomSeed(cx);
float dx = cx * space + w/2f, dy = 0;
Lines.rect(dx - space/2f, dy, space, height, 1*s, 2*s);
}
Draw.reset();
}
//background text and indicator
if(true){
float rads = 110*s;
float rad = Math.min(Math.min(w, h) / 3.1f, Math.min(w, h)/2f - rads);
float rad2 = rad + rads;
float epad = 60f * s;
float mpad = 100f*s;
Draw.color(color);
Lines.stroke(2f * s);
Lines.poly(w/2, h/2, 4, rad);
Lines.poly(w/2, h/2, 4, rad2);
int propi = 0;
for(int sx : Mathf.signs){
for(int sy : Mathf.signs){
float y1 = h/2f + sy*rad2, y2 = h/2f + sy*120f;
//Lines.beginLine();
floats.clear();
if(w > h){ //non-portrait
floats.add(w/2f + sx*mpad, y1);
floats.add(w/2f + (w/2f-epad)*sx, y1);
floats.add(w/2f + (w/2f-epad)*sx, y2);
floats.add(w/2f + sx*mpad + sx*Math.abs(y2-y1), y2);
}else{ //portrait
floats.add(w/2f + sx*mpad, y1);
floats.add(w/2f + sx*mpad, h/2f + (h/2f-epad)*sy);
floats.add(w/2f + sx*mpad + sx*Math.abs(y2-y1), h/2f + (h/2f-epad)*sy);
floats.add(w/2f + sx*mpad + sx*Math.abs(y2-y1), y2);
}
float minx = Float.MAX_VALUE, miny = Float.MAX_VALUE, maxx = 0, maxy = 0;
for(int i = 0; i < floats.size; i+= 2){
float x = floats.items[i], y = floats.items[i + 1];
minx = Math.min(x, minx);
miny = Math.min(y, miny);
maxx = Math.max(x, maxx);
maxy = Math.max(y, maxy);
}
Lines.polyline(floats, true);
Draw.flush();
Gl.clear(Gl.stencilBufferBit);
Gl.stencilMask(0xFF);
Gl.colorMask(false, false, false, false);
Gl.enable(Gl.stencilTest);
Gl.stencilFunc(Gl.always, 1, 0xFF);
Gl.stencilMask(0xFF);
Gl.stencilOp(Gl.replace, Gl.replace, Gl.replace);
Fill.poly(floats);
Draw.flush();
Gl.stencilOp(Gl.keep, Gl.keep, Gl.keep);
Gl.colorMask(true, true, true, true);
Gl.stencilFunc(Gl.equal, 1, 0xFF);
if(assets.isLoaded("tech")){
BitmapFont font = assets.get("tech");
font.getData().markupEnabled = true;
font.draw(properties[propi++], minx, maxy);
}else{
Core.assets.finishLoadingAsset("tech");
}
Draw.flush();
Gl.disable(Gl.stencilTest);
}
}
}
//middle display
if(true){
float bspace = s * 100f;
float bsize = s * 80f;
int bars = (int)(w / bspace / 2) + 1;
float pscale = 1f / bars;
float barScale = 1.5f;
Draw.color(Color.black);
Fill.rect(w/2, h/2, w, bsize * barScale);
Lines.stroke(1f*s);
Draw.color(color);
Lines.rect(0, h/2 - bsize * barScale/2f, w, bsize * barScale, 10, 0);
for(int i = 1; i < bars; i++){
float cx = i * bspace;
float fract = 1f - (i - 1) / (float)(bars - 1);
float alpha = progress >= fract ? 1f : Mathf.clamp((pscale - (fract - progress)) / pscale);
Draw.color(Color.black, color, alpha);
for(int dir : Mathf.signs){
float width = bsize/1.7f;
float skew = bsize/2f;
Fill.rects(w/2 + cx*dir - width/2f + dir*skew, h/2f - bsize/2f + bsize/2f, width, bsize/2f, -dir*skew);
Fill.rects(w/2 + cx*dir - width/2f, h/2f - bsize/2f, width, bsize/2f, dir*skew);
//Lines.poly(w/2 + cx*dir, h/2f, 3, bsize, 90 + dir*90);
}
}
}
if(assets.isLoaded("tech")){
BitmapFont font = assets.get("tech");
font.setColor(Pal.accent);
Draw.color(Color.black);
font.draw(System.getProperty("java.version") + "\n\n[scarlet][[ready]", w/2f, h/2f + 120, Align.center);
}else{
}
/*
float height = Scl.scl(50f);
Draw.color(Color.black);
@ -207,6 +440,8 @@ public abstract class ClientLauncher extends ApplicationCore implements Platform
font.draw(bundle.get("load." + key, ""), graphics.getWidth() / 2f, graphics.getHeight() / 2f - height / 2f - Scl.scl(10f), Align.center);
}
}
*/
Lines.precise(false);
Draw.flush();
}
}

View File

@ -170,13 +170,15 @@ public class DesktopInput extends InputHandler{
}
if((player.dead() || state.isPaused()) && !ui.chatfrag.shown()){
//move camera around
float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f;
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
if(!(scene.getKeyboardFocus() instanceof TextField)){
//move camera around
float camSpeed = !Core.input.keyDown(Binding.dash) ? 3f : 8f;
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta() * camSpeed));
if(Core.input.keyDown(Binding.mouse_move)){
Core.camera.position.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * camSpeed;
Core.camera.position.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * camSpeed;
if(Core.input.keyDown(Binding.mouse_move)){
Core.camera.position.x += Mathf.clamp((Core.input.mouseX() - Core.graphics.getWidth() / 2f) * 0.005f, -1, 1) * camSpeed;
Core.camera.position.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2f) * 0.005f, -1, 1) * camSpeed;
}
}
}else if(!player.dead()){
Core.camera.position.lerpDelta(player, 0.08f);

View File

@ -40,7 +40,7 @@ public class DesktopLauncher extends ClientLauncher{
new SdlApplication(new DesktopLauncher(arg), new SdlConfig(){{
title = "Mindustry";
maximized = true;
stencil = 0;
stencil = 8;
width = 900;
height = 700;
setWindowIcon(FileType.internal, "icons/icon_64.png");

View File

@ -1,3 +1,3 @@
org.gradle.daemon=true
org.gradle.jvmargs=-Xms256m -Xmx1024m
archash=9ad12d12fdd74d673f7c9b9d95f25d95ade114a5
archash=7389745639e5aa7a71b6e7a0d3f4ba4a4b1dc278