diff --git a/core/src/mindustry/editor/WaveInfoDialog.java b/core/src/mindustry/editor/WaveInfoDialog.java index 359c0b2499..9f3dc474aa 100644 --- a/core/src/mindustry/editor/WaveInfoDialog.java +++ b/core/src/mindustry/editor/WaveInfoDialog.java @@ -1,7 +1,6 @@ package mindustry.editor; import arc.*; -import arc.func.*; import arc.graphics.*; import arc.math.*; import arc.scene.event.*; @@ -20,6 +19,8 @@ import mindustry.type.*; import mindustry.ui.*; import mindustry.ui.dialogs.*; +import java.util.*; + import static mindustry.Vars.*; import static mindustry.game.SpawnGroup.*; @@ -205,6 +206,13 @@ public class WaveInfoDialog extends BaseDialog{ b.label(() -> (group.begin + 1) + "").color(Color.lightGray).minWidth(45f).labelAlign(Align.left).left(); + b.button(Icon.copySmall, Styles.emptyi, () -> { + SpawnGroup newGroup = group.copy(); + expandedGroup = newGroup; + groups.add(newGroup); + buildGroups(); + }).pad(-6).size(46f); + b.button(group.effect != null && group.effect != StatusEffects.none ? new TextureRegionDrawable(group.effect.uiIcon) : Icon.logicSmall, @@ -215,7 +223,7 @@ public class WaveInfoDialog extends BaseDialog{ groups.remove(group); table.getCell(t).pad(0f); t.remove(); - updateWaves(); + buildGroups(); }).pad(-6).size(46f).padRight(-12f); }, () -> { expandedGroup = expandedGroup == group ? null : group; @@ -374,15 +382,15 @@ public class WaveInfoDialog extends BaseDialog{ } enum Sort{ - begin(g -> g.begin), - health(g -> g.type.health), - type(g -> g.type.id); + begin(Structs.comps(Structs.comparingFloat(g -> g.begin), Structs.comparingFloat(g -> g.type.id))), + health(Structs.comps(Structs.comparingFloat(g -> g.type.health), Structs.comparingFloat(g -> g.begin))), + type(Structs.comps(Structs.comparingFloat(g -> g.type.id), Structs.comparingFloat(g -> g.begin))); static final Sort[] all = values(); - final Floatf sort; + final Comparator sort; - Sort(Floatf sort){ + Sort(Comparator sort){ this.sort = sort; } } diff --git a/core/src/mindustry/game/SpawnGroup.java b/core/src/mindustry/game/SpawnGroup.java index 115c78a7e6..0c93a71820 100644 --- a/core/src/mindustry/game/SpawnGroup.java +++ b/core/src/mindustry/game/SpawnGroup.java @@ -19,7 +19,7 @@ import static mindustry.Vars.*; * weapon equipped, ammo used, and status effects. * Each spawn group can have multiple sub-groups spawned in different areas of the map. */ -public class SpawnGroup implements JsonSerializable{ +public class SpawnGroup implements JsonSerializable, Cloneable{ public static final int never = Integer.MAX_VALUE; /** The unit type spawned */ @@ -157,6 +157,14 @@ public class SpawnGroup implements JsonSerializable{ '}'; } + public SpawnGroup copy(){ + try { + return (SpawnGroup)clone(); + }catch(CloneNotSupportedException how){ + throw new RuntimeException("If you see this, what did you even do?", how); + } + } + @Override public boolean equals(Object o){ if(this == o) return true;