generation UI fix + other miniscule ui fix (#7117)

This commit is contained in:
JniTrRny
2022-07-04 00:54:30 +07:00
committed by GitHub
parent 685e3cac83
commit 0201e08ac9
7 changed files with 47 additions and 34 deletions

View File

@@ -294,7 +294,9 @@ public class MapGenerateDialog extends BaseDialog{
}
t.button(Icon.copy, style, () -> {
filters.insert(filters.indexOf(filter), filter);
GenerateFilter copy = filter.copy();
copy.randomize();
filters.insert(filters.indexOf(filter) + 1, copy);
rebuildFilters();
update();
}).tooltip("@editor.copy");

View File

@@ -36,6 +36,16 @@ public class LogicDialog extends BaseDialog{
addCloseListener();
shown(this::setup);
hidden(() -> consumer.get(canvas.save()));
onResize(() -> {
setup();
canvas.rebuild();
});
}
private void setup(){
buttons.clearChildren();
buttons.defaults().size(160f, 64f);
buttons.button("@back", Icon.left, this::hide).name("back");
@@ -204,10 +214,6 @@ public class LogicDialog extends BaseDialog{
row();
add(buttons).growX().name("canvas");
hidden(() -> consumer.get(canvas.save()));
onResize(() -> canvas.rebuild());
}
public void show(String code, LExecutor executor, boolean privileged, Cons<String> modified){

View File

@@ -106,7 +106,6 @@ public abstract class FilterOption{
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), () -> {
BaseDialog dialog = new BaseDialog("@filter.option." + name);
dialog.setFillParent(false);
dialog.cont.pane(t -> {
int i = 0;
for(Block block : Vars.content.blocks()){
@@ -119,7 +118,8 @@ public abstract class FilterOption{
});
if(++i % 10 == 0) t.row();
}
});
dialog.setFillParent(i > 100);
}).padRight(8f).scrollX(false);
dialog.addCloseButton();

View File

@@ -12,7 +12,7 @@ import mindustry.gen.*;
import mindustry.world.*;
import mindustry.world.blocks.environment.*;
public abstract class GenerateFilter{
public abstract class GenerateFilter implements Cloneable{
public int seed = 0;
public void apply(Tiles tiles, GenerateInput in){
@@ -128,6 +128,14 @@ public abstract class GenerateFilter{
return Mathf.randomSeed(Pack.longInt(x, y + seed));
}
public GenerateFilter copy(){
try{
return (GenerateFilter) clone();
}catch(CloneNotSupportedException disgrace){
throw new RuntimeException("java is the best language", disgrace);
}
}
/** an input for generating at a certain coordinate. should only be instantiated once. */
public static class GenerateInput{

View File

@@ -19,9 +19,9 @@ public class RiverNoiseFilter extends GenerateFilter{
new SliderOption("octaves", () -> octaves, f -> octaves = f, 1f, 10f),
new SliderOption("falloff", () -> falloff, f -> falloff = f, 0f, 1f),
new BlockOption("target", () -> target, b -> target = b, anyOptional),
new BlockOption("block", () -> block, b -> block = b, wallsOnly),
new BlockOption("floor", () -> floor, b -> floor = b, floorsOnly),
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOnly)
new BlockOption("block", () -> block, b -> block = b, wallsOptional),
new BlockOption("floor", () -> floor, b -> floor = b, floorsOptional),
new BlockOption("floor2", () -> floor2, b -> floor2 = b, floorsOptional)
};
}
@@ -35,13 +35,13 @@ public class RiverNoiseFilter extends GenerateFilter{
float noise = rnoise(in.x, in.y, (int)octaves, scl, falloff, 1f);
if(noise >= threshold && (target == Blocks.air || in.floor == target || in.block == target)){
in.floor = floor;
if(floor != Blocks.air) in.floor = floor;
if(in.block.solid){
if(in.block.solid && block != Blocks.air && in.block != Blocks.air){
in.block = block;
}
if(noise >= threshold2){
if(noise >= threshold2 && floor2 != Blocks.air){
in.floor = floor2;
}
}

View File

@@ -27,7 +27,7 @@ public class KeybindDialog extends Dialog{
protected ObjectIntMap<Section> sectionControls = new ObjectIntMap<>();
public KeybindDialog(){
super(bundle.get("keybind.title", "Rebind Keys"));
super(bundle.get("keybind.title"));
setup();
addCloseButton();
setFillParent(true);
@@ -154,7 +154,7 @@ public class KeybindDialog extends Dialog{
openDialog(section, keybind);
}).width(130f);
}
table.button("@settings.resetKey", tstyle, () -> keybinds.resetToDefault(section, keybind)).width(130f);
table.button("@settings.resetKey", tstyle, () -> keybinds.resetToDefault(section, keybind)).width(130f).pad(2f).padLeft(4f);
table.row();
}
@@ -194,7 +194,7 @@ public class KeybindDialog extends Dialog{
}
private void openDialog(Section section, KeyBind name){
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis", "Press an axis or key...") : bundle.get("keybind.press", "Press a key..."));
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
rebindKey = name;

View File

@@ -270,26 +270,26 @@ public class SettingsMenuDialog extends BaseDialog{
TextButtonStyle style = Styles.flatt;
float marg = 8f, isize = iconMed;
float isize = iconMed;
menu.defaults().size(300f, 60f);
menu.button("@settings.game", Icon.settings, style, isize, () -> visible(0)).marginLeft(marg).row();
menu.button("@settings.graphics", Icon.image, style, isize, () -> visible(1)).marginLeft(marg).row();
menu.button("@settings.sound", Icon.filters, style, isize, () -> visible(2)).marginLeft(marg).row();
menu.button("@settings.language", Icon.chat, style, isize, ui.language::show).marginLeft(marg).row();
menu.defaults().size(300f, 60f).marginLeft(8f);
menu.button("@settings.game", Icon.settings, style, isize, () -> visible(0)).row();
menu.button("@settings.graphics", Icon.image, style, isize, () -> visible(1)).row();
menu.button("@settings.sound", Icon.filters, style, isize, () -> visible(2)).row();
menu.button("@settings.language", Icon.chat, style, isize, ui.language::show).row();
if(!mobile || Core.settings.getBool("keyboard")){
menu.button("@settings.controls", Icon.move, style, isize, ui.controls::show).marginLeft(marg).row();
menu.button("@settings.controls", Icon.move, style, isize, ui.controls::show).row();
}
menu.button("@settings.data", Icon.save, style, isize, () -> dataDialog.show()).marginLeft(marg).row();
menu.button("@settings.data", Icon.save, style, isize, () -> dataDialog.show()).row();
int i = 3;
for(var cat : categories){
int index = i;
if(cat.icon == null){
menu.button(cat.name, style, () -> visible(index)).marginLeft(marg).row();
menu.button(cat.name, style, () -> visible(index)).row();
}else{
menu.button(cat.name, cat.icon, style, isize, () -> visible(index)).with(b -> ((Image)b.getChildren().get(1)).setScaling(Scaling.fit)).marginLeft(marg).row();
menu.button(cat.name, cat.icon, style, isize, () -> visible(index)).with(b -> ((Image)b.getChildren().get(1)).setScaling(Scaling.fit)).row();
}
i++;
}
@@ -438,22 +438,19 @@ public class SettingsMenuDialog extends BaseDialog{
}
graphics.checkPref("effects", true);
graphics.checkPref("atmosphere", !mobile);
graphics.checkPref("destroyedblocks", true);
graphics.checkPref("blockstatus", false);
graphics.checkPref("playerchat", true);
if(!mobile){
graphics.checkPref("coreitems", true);
}
if(!mobile) graphics.checkPref("coreitems", true);
graphics.row();
graphics.checkPref("minimap", !mobile);
graphics.checkPref("smoothcamera", true);
graphics.checkPref("position", false);
if(!mobile){
graphics.checkPref("mouseposition", false);
}
if(!mobile) graphics.checkPref("mouseposition", false);
graphics.checkPref("fps", false);
graphics.checkPref("playerindicators", true);
graphics.checkPref("indicators", true);
graphics.checkPref("atmosphere", !mobile);
graphics.checkPref("showweather", true);
graphics.checkPref("animatedwater", true);