mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
"""better""" map generation dialog
This commit is contained in:
parent
0ffa0351b5
commit
2b0fbd9904
@ -83,6 +83,8 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
if(!applied){
|
||||
hidden(this::apply);
|
||||
}
|
||||
|
||||
onResize(() -> rebuildFilters());
|
||||
}
|
||||
|
||||
public void show(Array<GenerateFilter> filters, Consumer<Array<GenerateFilter>> applier){
|
||||
@ -183,8 +185,8 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
setScaling(Scaling.none);
|
||||
}});
|
||||
visible(() -> generating && !updateEditorOnChange);
|
||||
}}).size(mobile ? 300f : 400f).padRight(10);
|
||||
t.pane(p -> filterTable = p.marginRight(6)).width(300f).update(pane -> {
|
||||
}}).grow().padRight(10);
|
||||
t.pane(p -> filterTable = p.marginRight(6)).update(pane -> {
|
||||
if(Core.scene.getKeyboardFocus() instanceof Dialog && Core.scene.getKeyboardFocus() != this){
|
||||
return;
|
||||
}
|
||||
@ -196,7 +198,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
}else{
|
||||
Core.scene.setScrollFocus(null);
|
||||
}
|
||||
}).get().setScrollingDisabled(true, false);
|
||||
}).grow().get().setScrollingDisabled(true, false);
|
||||
}).grow();
|
||||
|
||||
buffer1 = create();
|
||||
@ -218,8 +220,10 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
}
|
||||
|
||||
void rebuildFilters(){
|
||||
int cols = Math.max((int)(filterTable.getParent().getWidth() / Unit.dp.scl(290f)), 1);
|
||||
filterTable.clearChildren();
|
||||
filterTable.top();
|
||||
filterTable.top().left();
|
||||
int i = 0;
|
||||
|
||||
for(GenerateFilter filter : filters){
|
||||
|
||||
@ -227,6 +231,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
filterTable.table("button", c -> {
|
||||
//icons to perform actions
|
||||
c.table(t -> {
|
||||
t.top();
|
||||
t.add(filter.name()).padTop(5).color(Pal.accent).growX().left();
|
||||
|
||||
t.row();
|
||||
@ -273,8 +278,10 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
f.row();
|
||||
}
|
||||
}).grow().left().pad(2);
|
||||
}).width(280f).pad(3);
|
||||
filterTable.row();
|
||||
}).width(280f).pad(3).top().left();
|
||||
if(++i % cols == 0){
|
||||
filterTable.row();
|
||||
}
|
||||
}
|
||||
|
||||
if(filters.isEmpty()){
|
||||
|
@ -43,8 +43,19 @@ public class MirrorFilter extends GenerateFilter{
|
||||
@Override
|
||||
public void draw(Image image){
|
||||
super.draw(image);
|
||||
|
||||
Vector2 vsize = Scaling.fit.apply(image.getDrawable().getMinWidth(), image.getDrawable().getMinHeight(), image.getWidth(), image.getHeight());
|
||||
float imageWidth = vsize.x;
|
||||
float imageHeight = vsize.y;
|
||||
|
||||
float size = Math.max(image.getWidth() *2, image.getHeight()*2);
|
||||
Consumer<Vector2> clamper = v -> v.clamp(image.getX(), image.getX() + image.getWidth(), image.getY(), image.getY() + image.getHeight());
|
||||
Consumer<Vector2> clamper = v ->
|
||||
v.clamp(
|
||||
image.getX() + image.getWidth()/2f - imageWidth/2f,
|
||||
image.getX() + image.getWidth()/2f + imageWidth/2f,
|
||||
image.getY() + image.getHeight()/2f - imageHeight/2f,
|
||||
image.getY() + image.getHeight()/2f + imageHeight/2f);
|
||||
|
||||
clamper.accept(Tmp.v1.trns(angle - 90, size).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY()));
|
||||
clamper.accept(Tmp.v2.set(Tmp.v1).sub(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY()).rotate(180f).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY()));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user