mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-03-09 20:29:06 +07:00
Add a copy button to spawn groups (#5957)
* copy button * rebuild groups on removal * two factor sorting * copy method for spawngroup * implement Clonable * revert to copy to call clone
This commit is contained in:
parent
08d7390775
commit
9076325fa1
@ -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<SpawnGroup> sort;
|
||||
final Comparator<SpawnGroup> sort;
|
||||
|
||||
Sort(Floatf<SpawnGroup> sort){
|
||||
Sort(Comparator<SpawnGroup> sort){
|
||||
this.sort = sort;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user