From 8b5adca750b305252e7c286eae02585c61c9aee7 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 5 May 2020 23:01:12 -0400 Subject: [PATCH] Early prototype loading screen --- .../mindustry/android/AndroidLauncher.java | 1 + core/src/mindustry/ClientLauncher.java | 239 +++++++++++++++++- core/src/mindustry/input/DesktopInput.java | 14 +- .../mindustry/desktop/DesktopLauncher.java | 2 +- gradle.properties | 2 +- 5 files changed, 248 insertions(+), 10 deletions(-) diff --git a/android/src/mindustry/android/AndroidLauncher.java b/android/src/mindustry/android/AndroidLauncher.java index 1c233438ff..7996c2c93a 100644 --- a/android/src/mindustry/android/AndroidLauncher.java +++ b/android/src/mindustry/android/AndroidLauncher.java @@ -146,6 +146,7 @@ public class AndroidLauncher extends AndroidApplication{ useImmersiveMode = true; hideStatusBar = true; errorHandler = CrashSender::log; + stencil = 8; }}); checkFiles(getIntent()); diff --git a/core/src/mindustry/ClientLauncher.java b/core/src/mindustry/ClientLauncher.java index 37d7175fb9..0488e124a7 100644 --- a/core/src/mindustry/ClientLauncher.java +++ b/core/src/mindustry/ClientLauncher.java @@ -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(); } } diff --git a/core/src/mindustry/input/DesktopInput.java b/core/src/mindustry/input/DesktopInput.java index 673030a87e..cfb470e8c3 100644 --- a/core/src/mindustry/input/DesktopInput.java +++ b/core/src/mindustry/input/DesktopInput.java @@ -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); diff --git a/desktop/src/mindustry/desktop/DesktopLauncher.java b/desktop/src/mindustry/desktop/DesktopLauncher.java index 6e3f50a59a..ca360a8c84 100644 --- a/desktop/src/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/mindustry/desktop/DesktopLauncher.java @@ -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"); diff --git a/gradle.properties b/gradle.properties index d08ca8d1a4..08651183d6 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=9ad12d12fdd74d673f7c9b9d95f25d95ade114a5 +archash=7389745639e5aa7a71b6e7a0d3f4ba4a4b1dc278