Display modes for waves
This commit is contained in:
@@ -340,6 +340,12 @@ waves.load = Load from Clipboard
|
|||||||
waves.invalid = Invalid waves in clipboard.
|
waves.invalid = Invalid waves in clipboard.
|
||||||
waves.copied = Waves copied.
|
waves.copied = Waves copied.
|
||||||
waves.none = No enemies defined.\nNote that empty wave layouts will automatically be replaced with the default layout.
|
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]<Default>
|
editor.default = [lightgray]<Default>
|
||||||
details = Details...
|
details = Details...
|
||||||
edit = Edit...
|
edit = Edit...
|
||||||
|
|||||||
@@ -520,7 +520,7 @@ public class UnitTypes implements ContentList{
|
|||||||
rotateSpeed = 3.5f;
|
rotateSpeed = 3.5f;
|
||||||
flying = true;
|
flying = true;
|
||||||
lowAltitude = true;
|
lowAltitude = true;
|
||||||
health = 7000;
|
health = 9000;
|
||||||
armor = 9f;
|
armor = 9f;
|
||||||
engineOffset = 21;
|
engineOffset = 21;
|
||||||
engineSize = 5.3f;
|
engineSize = 5.3f;
|
||||||
@@ -542,7 +542,7 @@ public class UnitTypes implements ContentList{
|
|||||||
rotateSpeed = 2.5f;
|
rotateSpeed = 2.5f;
|
||||||
flying = true;
|
flying = true;
|
||||||
lowAltitude = true;
|
lowAltitude = true;
|
||||||
health = 13000;
|
health = 18000;
|
||||||
engineOffset = 38;
|
engineOffset = 38;
|
||||||
engineSize = 7.3f;
|
engineSize = 7.3f;
|
||||||
hitsize = 58f;
|
hitsize = 58f;
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package mindustry.editor;
|
|||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.*;
|
import arc.math.*;
|
||||||
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -10,6 +11,7 @@ import arc.util.pooling.*;
|
|||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.*;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
|
||||||
@@ -17,9 +19,11 @@ public class WaveGraph extends Table{
|
|||||||
public Seq<SpawnGroup> groups = new Seq<>();
|
public Seq<SpawnGroup> groups = new Seq<>();
|
||||||
public int from, to = 20;
|
public int from, to = 20;
|
||||||
|
|
||||||
|
private Mode mode = Mode.counts;
|
||||||
private int[][] values;
|
private int[][] values;
|
||||||
private OrderedSet<UnitType> used = new OrderedSet<>();
|
private OrderedSet<UnitType> used = new OrderedSet<>();
|
||||||
private int max;
|
private int max, maxTotal;
|
||||||
|
private float maxHealth;
|
||||||
private Table colors;
|
private Table colors;
|
||||||
private ObjectSet<UnitType> hidden = new ObjectSet<>();
|
private ObjectSet<UnitType> hidden = new ObjectSet<>();
|
||||||
|
|
||||||
@@ -30,29 +34,64 @@ public class WaveGraph extends Table{
|
|||||||
Lines.stroke(Scl.scl(3f));
|
Lines.stroke(Scl.scl(3f));
|
||||||
Lines.precise(true);
|
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);
|
GlyphLayout lay = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||||
BitmapFont font = Fonts.outline;
|
BitmapFont font = Fonts.outline;
|
||||||
|
|
||||||
lay.setText(font, "1");
|
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
|
//how many numbers can fit here
|
||||||
float totalMarks = (height - offsetY - getMarginBottom() *2f - 1f) / (lay.height * 2);
|
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);
|
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++){
|
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);
|
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);
|
Pools.free(lay);
|
||||||
|
|
||||||
@@ -85,15 +129,31 @@ public class WaveGraph extends Table{
|
|||||||
row();
|
row();
|
||||||
|
|
||||||
table(t -> colors = t).growX();
|
table(t -> colors = t).growX();
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
table(t -> {
|
||||||
|
t.left();
|
||||||
|
ButtonGroup<Button> group = new ButtonGroup<>();
|
||||||
|
|
||||||
|
for(Mode m : Mode.all){
|
||||||
|
t.button("$wavemode." + m.name(), Styles.fullTogglet, () -> {
|
||||||
|
mode = m;
|
||||||
|
}).group(group).height(32f).update(b -> b.setChecked(m == mode)).width(100f);
|
||||||
|
}
|
||||||
|
}).growX();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuild(){
|
public void rebuild(){
|
||||||
values = new int[to - from + 1][Vars.content.units().size];
|
values = new int[to - from + 1][Vars.content.units().size];
|
||||||
used.clear();
|
used.clear();
|
||||||
max = 1;
|
max = maxTotal = 1;
|
||||||
|
maxHealth = 1f;
|
||||||
|
|
||||||
for(int i = from; i <= to; i++){
|
for(int i = from; i <= to; i++){
|
||||||
int index = i - from;
|
int index = i - from;
|
||||||
|
float healthsum = 0f;
|
||||||
|
int sum = 0;
|
||||||
|
|
||||||
for(SpawnGroup spawn : groups){
|
for(SpawnGroup spawn : groups){
|
||||||
int spawned = spawn.getUnitsSpawned(i);
|
int spawned = spawn.getUnitsSpawned(i);
|
||||||
@@ -102,7 +162,11 @@ public class WaveGraph extends Table{
|
|||||||
used.add(spawn.type);
|
used.add(spawn.type);
|
||||||
}
|
}
|
||||||
max = Math.max(max, values[index][spawn.type.id]);
|
max = Math.max(max, values[index][spawn.type.id]);
|
||||||
|
healthsum += spawned * spawn.type.health;
|
||||||
|
sum += spawned;
|
||||||
}
|
}
|
||||||
|
maxTotal = Math.max(maxTotal, sum);
|
||||||
|
maxHealth = Math.max(maxHealth,healthsum);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectSet<UnitType> usedCopy = new ObjectSet<>(used);
|
ObjectSet<UnitType> usedCopy = new ObjectSet<>(used);
|
||||||
@@ -129,10 +193,14 @@ public class WaveGraph extends Table{
|
|||||||
for(UnitType type : hidden){
|
for(UnitType type : hidden){
|
||||||
used.remove(type);
|
used.remove(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Color color(UnitType type){
|
Color color(UnitType type){
|
||||||
return Tmp.c1.fromHsv(type.id / (float)Vars.content.units().size * 360f, 0.7f, 1f);
|
return Tmp.c1.fromHsv(type.id / (float)Vars.content.units().size * 360f, 0.7f, 1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Mode{
|
||||||
|
counts, totals, health;
|
||||||
|
static Mode[] all = values();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import static mindustry.Vars.*;
|
|||||||
import static mindustry.game.SpawnGroup.*;
|
import static mindustry.game.SpawnGroup.*;
|
||||||
|
|
||||||
public class WaveInfoDialog extends BaseDialog{
|
public class WaveInfoDialog extends BaseDialog{
|
||||||
private static final int displayed = 20;
|
private int displayed = 20;
|
||||||
private Seq<SpawnGroup> groups = new Seq<>();
|
private Seq<SpawnGroup> groups = new Seq<>();
|
||||||
|
|
||||||
private Table table;
|
private Table table;
|
||||||
@@ -47,28 +47,6 @@ public class WaveInfoDialog extends BaseDialog{
|
|||||||
|
|
||||||
onResize(this::setup);
|
onResize(this::setup);
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
buttons.button("<<", () -> {
|
|
||||||
}).update(t -> {
|
|
||||||
if(t.getClickListener().isPressed()){
|
|
||||||
updateTimer += Time.delta;
|
|
||||||
if(updateTimer >= updatePeriod){
|
|
||||||
start = Math.max(start - 1, 0);
|
|
||||||
updateTimer = 0f;
|
|
||||||
updateWaves();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
buttons.button(">>", () -> {
|
|
||||||
}).update(t -> {
|
|
||||||
if(t.getClickListener().isPressed()){
|
|
||||||
updateTimer += Time.delta;
|
|
||||||
if(updateTimer >= updatePeriod){
|
|
||||||
start++;
|
|
||||||
updateTimer = 0f;
|
|
||||||
updateWaves();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
buttons.button("$waves.edit", () -> {
|
buttons.button("$waves.edit", () -> {
|
||||||
BaseDialog dialog = new BaseDialog("$waves.edit");
|
BaseDialog dialog = new BaseDialog("$waves.edit");
|
||||||
@@ -99,6 +77,50 @@ public class WaveInfoDialog extends BaseDialog{
|
|||||||
}));
|
}));
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}).size(270f, 64f);
|
}).size(270f, 64f);
|
||||||
|
|
||||||
|
buttons.defaults().width(60f);
|
||||||
|
|
||||||
|
buttons.button("<", () -> {}).update(t -> {
|
||||||
|
if(t.getClickListener().isPressed()){
|
||||||
|
shift(-1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttons.button(">", () -> {}).update(t -> {
|
||||||
|
if(t.getClickListener().isPressed()){
|
||||||
|
shift(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
buttons.button("-", () -> {}).update(t -> {
|
||||||
|
if(t.getClickListener().isPressed()){
|
||||||
|
view(-1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
buttons.button("+", () -> {}).update(t -> {
|
||||||
|
if(t.getClickListener().isPressed()){
|
||||||
|
view(1);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void view(int amount){
|
||||||
|
updateTimer += Time.delta;
|
||||||
|
if(updateTimer >= updatePeriod){
|
||||||
|
displayed += amount;
|
||||||
|
if(displayed < 5) displayed = 5;
|
||||||
|
updateTimer = 0f;
|
||||||
|
updateWaves();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void shift(int amount){
|
||||||
|
updateTimer += Time.delta;
|
||||||
|
if(updateTimer >= updatePeriod){
|
||||||
|
start += amount;
|
||||||
|
if(start < 0) start = 0;
|
||||||
|
updateTimer = 0f;
|
||||||
|
updateWaves();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void setup(){
|
void setup(){
|
||||||
@@ -120,7 +142,7 @@ public class WaveInfoDialog extends BaseDialog{
|
|||||||
setAlignment(Align.center, Align.center);
|
setAlignment(Align.center, Align.center);
|
||||||
}}).width(390f).growY();
|
}}).width(390f).growY();
|
||||||
|
|
||||||
cont.add(graph).grow();
|
cont.add(graph = new WaveGraph()).grow();
|
||||||
|
|
||||||
buildGroups();
|
buildGroups();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||||
archash=9947972b4ee3f60df35ba3d8be42ad5c287c9a43
|
archash=e731db5f9be2004fab0b3b23206f6c2211d01176
|
||||||
|
|||||||
Reference in New Issue
Block a user