From 7cc94057a1e6a61ce38d08c1862e2af38f8d3a99 Mon Sep 17 00:00:00 2001 From: Anuken Date: Tue, 28 Jul 2020 15:27:43 -0400 Subject: [PATCH] Display modes for waves --- core/assets/bundles/bundle.properties | 6 + core/src/mindustry/content/UnitTypes.java | 4 +- core/src/mindustry/editor/WaveGraph.java | 114 ++++++++++++++---- core/src/mindustry/editor/WaveInfoDialog.java | 70 +++++++---- gradle.properties | 2 +- 5 files changed, 146 insertions(+), 50 deletions(-) diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 9ba28d903d..90cfe73dcb 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -340,6 +340,12 @@ waves.load = Load from Clipboard waves.invalid = Invalid waves in clipboard. waves.copied = Waves copied. waves.none = No enemies defined.\nNote that empty wave layouts will automatically be replaced with the default layout. + +#these are intentionally in lower case +wavemode.counts = counts +wavemode.totals = totals +wavemode.health = health + editor.default = [lightgray] details = Details... edit = Edit... diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index ac070898f2..414eddac83 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -520,7 +520,7 @@ public class UnitTypes implements ContentList{ rotateSpeed = 3.5f; flying = true; lowAltitude = true; - health = 7000; + health = 9000; armor = 9f; engineOffset = 21; engineSize = 5.3f; @@ -542,7 +542,7 @@ public class UnitTypes implements ContentList{ rotateSpeed = 2.5f; flying = true; lowAltitude = true; - health = 13000; + health = 18000; engineOffset = 38; engineSize = 7.3f; hitsize = 58f; diff --git a/core/src/mindustry/editor/WaveGraph.java b/core/src/mindustry/editor/WaveGraph.java index 143a5839df..eb2ac64359 100644 --- a/core/src/mindustry/editor/WaveGraph.java +++ b/core/src/mindustry/editor/WaveGraph.java @@ -3,6 +3,7 @@ package mindustry.editor; import arc.graphics.*; import arc.graphics.g2d.*; import arc.math.*; +import arc.scene.ui.*; import arc.scene.ui.layout.*; import arc.struct.*; import arc.util.*; @@ -10,6 +11,7 @@ import arc.util.pooling.*; import mindustry.*; import mindustry.game.*; import mindustry.gen.*; +import mindustry.graphics.*; import mindustry.type.*; import mindustry.ui.*; @@ -17,9 +19,11 @@ public class WaveGraph extends Table{ public Seq groups = new Seq<>(); public int from, to = 20; + private Mode mode = Mode.counts; private int[][] values; private OrderedSet used = new OrderedSet<>(); - private int max; + private int max, maxTotal; + private float maxHealth; private Table colors; private ObjectSet hidden = new ObjectSet<>(); @@ -30,29 +34,64 @@ public class WaveGraph extends Table{ Lines.stroke(Scl.scl(3f)); Lines.precise(true); - float offsetX = Scl.scl(30f), offsetY = Scl.scl(20f); - - float graphX = x + offsetX, graphY = y + offsetY, graphW = width - offsetX, graphH = height - offsetY; - float spacing = graphW / (values.length - 1); - - for(UnitType type : used){ - Draw.color(color(type)); - Draw.alpha(parentAlpha); - Lines.beginLine(); - for(int i = 0; i < values.length; i++){ - int val = values[i][type.id]; - - float cx = graphX + i*spacing, cy = 2f + graphY + val * (graphH - 4f) / max; - Lines.linePoint(cx, cy); - } - Lines.endLine(); - } - GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new); BitmapFont font = Fonts.outline; lay.setText(font, "1"); + float fh = lay.height; + float offsetX = Scl.scl(30f), offsetY = Scl.scl(22f) + fh + Scl.scl(5f); + + float graphX = x + offsetX, graphY = y + offsetY, graphW = width - offsetX, graphH = height - offsetY; + float spacing = graphW / (values.length - 1); + + if(mode == Mode.counts){ + for(UnitType type : used.orderedItems()){ + Draw.color(color(type)); + Draw.alpha(parentAlpha); + + Lines.beginLine(); + + for(int i = 0; i < values.length; i++){ + int val = values[i][type.id]; + float cx = graphX + i*spacing, cy = 2f + graphY + val * (graphH - 4f) / max; + Lines.linePoint(cx, cy); + } + + Lines.endLine(); + } + }else if(mode == Mode.totals){ + Lines.beginLine(); + + Draw.color(Pal.accent); + for(int i = 0; i < values.length; i++){ + int sum = 0; + for(UnitType type : used.orderedItems()){ + sum += values[i][type.id]; + } + + float cx = graphX + i*spacing, cy = 2f + graphY + sum * (graphH - 4f) / maxTotal; + Lines.linePoint(cx, cy); + } + + Lines.endLine(); + }else if(mode == Mode.health){ + Lines.beginLine(); + + Draw.color(Pal.health); + for(int i = 0; i < values.length; i++){ + float sum = 0; + for(UnitType type : used.orderedItems()){ + sum += type.health * values[i][type.id]; + } + + float cx = graphX + i*spacing, cy = 2f + graphY + sum * (graphH - 4f) / maxHealth; + Lines.linePoint(cx, cy); + } + + Lines.endLine(); + } + //how many numbers can fit here float totalMarks = (height - offsetY - getMarginBottom() *2f - 1f) / (lay.height * 2); @@ -68,13 +107,18 @@ public class WaveGraph extends Table{ font.draw("" + i, cx, cy + lay.height/2f - Scl.scl(3f), Align.right); } - float len = 4f; + float len = Scl.scl(4f); + font.setColor(Color.lightGray); for(int i = 0; i < values.length; i++){ - float cy = y, cx = x + graphW / (values.length - 1) * i + offsetX; + float cy = y + fh, cx = x + graphW / (values.length - 1) * i + offsetX; Lines.line(cx, cy, cx, cy + len); + if(i == values.length/2){ + font.draw("" + (i + from), cx, cy - 2f, Align.center); + } } + font.setColor(Color.white); Pools.free(lay); @@ -85,15 +129,31 @@ public class WaveGraph extends Table{ row(); table(t -> colors = t).growX(); + + row(); + + table(t -> { + t.left(); + ButtonGroup