Generation quick copy & paste (#7520)
* several UI changes * block ID bad
This commit is contained in:
@@ -118,9 +118,9 @@ public class SpawnGroup implements JsonSerializable, Cloneable{
|
|||||||
if(unitAmount != 1) json.writeValue("amount", unitAmount);
|
if(unitAmount != 1) json.writeValue("amount", unitAmount);
|
||||||
if(effect != null) json.writeValue("effect", effect.name);
|
if(effect != null) json.writeValue("effect", effect.name);
|
||||||
if(spawn != -1) json.writeValue("spawn", spawn);
|
if(spawn != -1) json.writeValue("spawn", spawn);
|
||||||
if(payloads != null && payloads.size > 0){
|
if(payloads != null && payloads.size > 0) json.writeValue("payloads", payloads.map(u -> u.name).toArray(String.class));
|
||||||
json.writeValue("payloads", payloads.map(u -> u.name).toArray(String.class));
|
if(items != null && items.amount > 0) json.writeValue("items", items);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -138,9 +138,9 @@ public class SpawnGroup implements JsonSerializable, Cloneable{
|
|||||||
shieldScaling = data.getFloat("shieldScaling", 0);
|
shieldScaling = data.getFloat("shieldScaling", 0);
|
||||||
unitAmount = data.getInt("amount", 1);
|
unitAmount = data.getInt("amount", 1);
|
||||||
spawn = data.getInt("spawn", -1);
|
spawn = data.getInt("spawn", -1);
|
||||||
if(data.has("payloads")){
|
if(data.has("payloads")) payloads = Seq.with(json.readValue(String[].class, data.get("payloads"))).map(s -> content.getByName(ContentType.unit, s));
|
||||||
payloads = Seq.with(json.readValue(String[].class, data.get("payloads"))).map(s -> content.getByName(ContentType.unit, s));
|
if(data.has("items")) items = json.readValue(ItemStack.class, data.get("items"));
|
||||||
}
|
|
||||||
|
|
||||||
//old boss effect ID
|
//old boss effect ID
|
||||||
if(data.has("effect") && data.get("effect").isNumber() && data.getInt("effect", -1) == 8){
|
if(data.has("effect") && data.get("effect").isNumber() && data.getInt("effect", -1) == 8){
|
||||||
|
|||||||
@@ -9,12 +9,14 @@ import static mindustry.maps.filters.FilterOption.*;
|
|||||||
public class ClearFilter extends GenerateFilter{
|
public class ClearFilter extends GenerateFilter{
|
||||||
public Block target = Blocks.stone;
|
public Block target = Blocks.stone;
|
||||||
public Block replace = Blocks.air;
|
public Block replace = Blocks.air;
|
||||||
|
public Block ignore = Blocks.air;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FilterOption[] options(){
|
public FilterOption[] options(){
|
||||||
return new FilterOption[]{
|
return new FilterOption[]{
|
||||||
new BlockOption("target", () -> target, b -> target = b, anyOptional),
|
new BlockOption("target", () -> target, b -> target = b, anyOptional),
|
||||||
new BlockOption("replacement", () -> replace, b -> replace = b, anyOptional)
|
new BlockOption("replacement", () -> replace, b -> replace = b, anyOptional),
|
||||||
|
new BlockOption("ignore", () -> ignore, b -> ignore = b, anyOptional)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +27,7 @@ public class ClearFilter extends GenerateFilter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void apply(GenerateInput in){
|
public void apply(GenerateInput in){
|
||||||
|
if(ignore != Blocks.air && (in.block == ignore || in.floor == ignore || in.overlay == ignore)) return;
|
||||||
|
|
||||||
if(in.block == target || in.floor == target || (target.isOverlay() && in.overlay == target)){
|
if(in.block == target || in.floor == target || (target.isOverlay() && in.overlay == target)){
|
||||||
//special case: when air is the result, replace only the overlay or wall
|
//special case: when air is the result, replace only the overlay or wall
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package mindustry.maps.filters;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
|
import arc.input.*;
|
||||||
import arc.scene.*;
|
import arc.scene.*;
|
||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
@@ -103,7 +104,7 @@ public abstract class FilterOption{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table){
|
public void build(Table table){
|
||||||
table.button(b -> b.image(supplier.get().uiIcon).update(i -> ((TextureRegionDrawable)i.getDrawable())
|
Button button = table.button(b -> b.image(supplier.get().uiIcon).update(i -> ((TextureRegionDrawable)i.getDrawable())
|
||||||
.setRegion(supplier.get() == Blocks.air ? Icon.none.getRegion() : supplier.get().uiIcon)).size(iconSmall), () -> {
|
.setRegion(supplier.get() == Blocks.air ? Icon.none.getRegion() : supplier.get().uiIcon)).size(iconSmall), () -> {
|
||||||
BaseDialog dialog = new BaseDialog("@filter.option." + name);
|
BaseDialog dialog = new BaseDialog("@filter.option." + name);
|
||||||
dialog.cont.pane(t -> {
|
dialog.cont.pane(t -> {
|
||||||
@@ -124,7 +125,19 @@ public abstract class FilterOption{
|
|||||||
|
|
||||||
dialog.addCloseButton();
|
dialog.addCloseButton();
|
||||||
dialog.show();
|
dialog.show();
|
||||||
}).pad(4).margin(12f);
|
}).pad(4).margin(12f).get();
|
||||||
|
|
||||||
|
button.clicked(KeyCode.mouseMiddle, () -> {
|
||||||
|
Core.app.setClipboardText(supplier.get().name);
|
||||||
|
ui.showInfoFade("@copied");
|
||||||
|
});
|
||||||
|
|
||||||
|
button.clicked(KeyCode.mouseRight, () -> {
|
||||||
|
if(content.block(Core.app.getClipboardText()) != null && filter.get(content.block(Core.app.getClipboardText()))){
|
||||||
|
consumer.get(content.block(Core.app.getClipboardText()));
|
||||||
|
changed.run();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
table.add("@filter.option." + name);
|
table.add("@filter.option." + name);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
|
|||||||
public class LoadDialog extends BaseDialog{
|
public class LoadDialog extends BaseDialog{
|
||||||
Table slots;
|
Table slots;
|
||||||
String searchString;
|
String searchString;
|
||||||
Gamemode filteredMode;
|
Seq<Gamemode> filteredModes;
|
||||||
TextField searchField;
|
TextField searchField;
|
||||||
ScrollPane pane;
|
ScrollPane pane;
|
||||||
|
|
||||||
@@ -50,6 +50,7 @@ public class LoadDialog extends BaseDialog{
|
|||||||
cont.clear();
|
cont.clear();
|
||||||
|
|
||||||
slots = new Table();
|
slots = new Table();
|
||||||
|
filteredModes = new Seq<>();
|
||||||
pane = new ScrollPane(slots);
|
pane = new ScrollPane(slots);
|
||||||
|
|
||||||
rebuild();
|
rebuild();
|
||||||
@@ -66,9 +67,9 @@ public class LoadDialog extends BaseDialog{
|
|||||||
boolean sandbox = mode == Gamemode.sandbox;
|
boolean sandbox = mode == Gamemode.sandbox;
|
||||||
if(Core.atlas.isFound(icon.getRegion()) || sandbox){
|
if(Core.atlas.isFound(icon.getRegion()) || sandbox){
|
||||||
search.button(sandbox ? Icon.terrain : icon, Styles.emptyTogglei, () -> {
|
search.button(sandbox ? Icon.terrain : icon, Styles.emptyTogglei, () -> {
|
||||||
filteredMode = filteredMode == mode ? null : mode;
|
if(!filteredModes.addUnique(mode)) filteredModes.remove(mode);
|
||||||
rebuild();
|
rebuild();
|
||||||
}).size(60f).checked(b -> filteredMode == mode).tooltip("@mode." + mode.name() + ".name");
|
}).size(60f).padLeft(-8f).checked(b -> !filteredModes.contains(mode)).tooltip("@mode." + mode.name() + ".name");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ public class LoadDialog extends BaseDialog{
|
|||||||
for(SaveSlot slot : array){
|
for(SaveSlot slot : array){
|
||||||
if(slot.isHidden()
|
if(slot.isHidden()
|
||||||
|| (searchString != null && !Strings.stripColors(slot.getName()).toLowerCase().contains(searchString))
|
|| (searchString != null && !Strings.stripColors(slot.getName()).toLowerCase().contains(searchString))
|
||||||
|| (filteredMode != null && filteredMode != slot.mode())){
|
|| (!filteredModes.isEmpty() && filteredModes.contains(slot.mode()))){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ public class MapsDialog extends BaseDialog{
|
|||||||
rebuildMaps();
|
rebuildMaps();
|
||||||
}).maxTextLength(50).growX().get();
|
}).maxTextLength(50).growX().get();
|
||||||
searchField.setMessageText("@editor.search");
|
searchField.setMessageText("@editor.search");
|
||||||
search.button(Icon.filter, Styles.emptyi, this::showMapFilters);
|
search.button(Icon.filter, Styles.emptyi, this::showMapFilters).tooltip("@editor.filters");
|
||||||
|
|
||||||
cont.add(search).growX();
|
cont.add(search).growX();
|
||||||
cont.row();
|
cont.row();
|
||||||
|
|||||||
Reference in New Issue
Block a user