Editor filter bugfixes
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
package mindustry.maps.filters;
|
||||
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -15,9 +14,9 @@ public class BlendFilter extends GenerateFilter{
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 15f),
|
||||
new BlockOption("block", () -> block, b -> block = b, anyOptional),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
|
||||
new BlockOption("floor", () -> floor, b -> floor = b, anyOptional),
|
||||
new BlockOption("ignore", () -> ignore, b -> ignore = b, floorsOptional)
|
||||
);
|
||||
}
|
||||
@@ -34,7 +33,7 @@ public class BlendFilter extends GenerateFilter{
|
||||
|
||||
@Override
|
||||
public void apply(){
|
||||
if(in.floor == block || block == Blocks.air || in.floor == ignore) return;
|
||||
if(in.floor == block || block == Blocks.air || in.floor == ignore || (!floor.isFloor() && (in.block == block || in.block == ignore))) return;
|
||||
|
||||
int rad = (int)radius;
|
||||
boolean found = false;
|
||||
@@ -42,7 +41,7 @@ public class BlendFilter extends GenerateFilter{
|
||||
outer:
|
||||
for(int x = -rad; x <= rad; x++){
|
||||
for(int y = -rad; y <= rad; y++){
|
||||
if(Mathf.within(x, y, rad)) continue;
|
||||
if(x*x + y*y > rad) continue;
|
||||
Tile tile = in.tile(in.x + x, in.y + y);
|
||||
|
||||
if(tile.floor() == block || tile.block() == block || tile.overlay() == block){
|
||||
@@ -53,7 +52,11 @@ public class BlendFilter extends GenerateFilter{
|
||||
}
|
||||
|
||||
if(found){
|
||||
in.floor = floor;
|
||||
if(!floor.isFloor()){
|
||||
in.block = floor;
|
||||
}else{
|
||||
in.floor = floor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import arc.scene.ui.layout.*;
|
||||
import mindustry.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.environment.*;
|
||||
@@ -105,6 +104,7 @@ public abstract class FilterOption{
|
||||
if(++i % 10 == 0) dialog.cont.row();
|
||||
}
|
||||
|
||||
dialog.closeOnBack();
|
||||
dialog.show();
|
||||
}).pad(4).margin(12f);
|
||||
|
||||
|
||||
@@ -75,11 +75,16 @@ public abstract class GenerateFilter{
|
||||
/** draw any additional guides */
|
||||
public void draw(Image image){}
|
||||
|
||||
/** localized display name */
|
||||
public String name(){
|
||||
public String simpleName(){
|
||||
Class c = getClass();
|
||||
if(c.isAnonymousClass()) c = c.getSuperclass();
|
||||
return Core.bundle.get("filter." + c.getSimpleName().toLowerCase().replace("filter", ""), c.getSimpleName().replace("Filter", ""));
|
||||
return c.getSimpleName().toLowerCase().replace("filter", "");
|
||||
}
|
||||
|
||||
/** localized display name */
|
||||
public String name(){
|
||||
var s = simpleName();
|
||||
return Core.bundle.get("filter." + s);
|
||||
}
|
||||
|
||||
public char icon(){
|
||||
|
||||
@@ -10,14 +10,15 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MedianFilter extends GenerateFilter{
|
||||
private static final IntSeq blocks = new IntSeq(), floors = new IntSeq();
|
||||
|
||||
float radius = 2;
|
||||
float percentile = 0.5f;
|
||||
IntSeq blocks = new IntSeq(), floors = new IntSeq();
|
||||
|
||||
@Override
|
||||
public FilterOption[] options(){
|
||||
return Structs.arr(
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 12f),
|
||||
new SliderOption("radius", () -> radius, f -> radius = f, 1f, 10f),
|
||||
new SliderOption("percentile", () -> percentile, f -> percentile = f, 0f, 1f)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user