Minor editor/world processor fixes and tweaks (#10505)

* Rules search and info button tweaks

* Tweak spawnunit and some searching (again)

* Just revert a condition removal
This commit is contained in:
ApsZoldat 2025-04-04 20:49:35 +03:00 committed by GitHub
parent aa7cdf7642
commit 212be01571
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 20 additions and 13 deletions

View file

@ -56,7 +56,7 @@ public class BannedContentDialog<T extends UnlockableContent> extends BaseDialog
t.table(s -> {
s.label(() -> "@search").padRight(10);
var field = s.field(contentSearch, value -> {
contentSearch = value;
contentSearch = value.trim().replaceAll(" +", " ").toLowerCase();
rebuildTables();
}).get();
s.button(Icon.cancel, Styles.emptyi, () -> {

View file

@ -757,7 +757,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
if(!Core.atlas.isFound(region) || !block.inEditor
|| block.buildVisibility == BuildVisibility.debugOnly
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.toLowerCase()))
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.trim().replaceAll(" +", " ").toLowerCase()))
) continue;
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);

View file

@ -1433,7 +1433,7 @@ public class LExecutor{
Team t = team.team();
if(type.obj() instanceof UnitType type && !type.internal && !type.hidden && t != null && Units.canCreate(t, type)){
if(type.obj() instanceof UnitType type && !type.internal && Units.canCreate(t, type)){
//random offset to prevent stacking
var unit = type.spawn(t, World.unconv(x.numf()) + Mathf.range(0.01f), World.unconv(y.numf()) + Mathf.range(0.01f));
spawner.spawnEffect(unit);

View file

@ -22,6 +22,7 @@ import mindustry.type.Weather.*;
import mindustry.ui.*;
import mindustry.world.*;
import static arc.Core.*;
import static arc.util.Time.*;
import static mindustry.Vars.*;
@ -117,24 +118,30 @@ public class CustomRulesDialog extends BaseDialog{
}
void setup(){
categories.clear();
cont.clear();
cont.table(t -> {
t.add("@search").padRight(10);
var field = t.field(ruleSearch, text -> {
ruleSearch = text.trim().replaceAll(" +", " ").toLowerCase();
setup();
setupMain();
}).grow().pad(8).get();
field.setCursorPosition(ruleSearch.length());
Core.scene.setKeyboardFocus(field);
t.button(Icon.cancel, Styles.emptyi, () -> {
ruleSearch = "";
setup();
setupMain();
}).padLeft(10f).size(35f);
t.button(Icon.zoom, Styles.emptyi, this::setup).size(54f);
}).row();
cont.pane(m -> main = m).scrollX(false);
main.margin(10f);
Cell<ScrollPane> paneCell = cont.pane(m -> main = m);
setupMain();
paneCell.scrollX(main.getPrefWidth() + 40f > graphics.getWidth());
}
void setupMain(){
categories.clear();
main.clear();
main.left().defaults().fillX().left();
main.row();
@ -333,7 +340,7 @@ public class CustomRulesDialog extends BaseDialog{
public void category(String name){
current = new Table();
current.left().defaults().fillX().left().pad(5);
current.left().defaults().fillX().expandX().left().pad(5);
currentName = name;
categories.add(current);
categoryNames.add(currentName);
@ -403,7 +410,7 @@ public class CustomRulesDialog extends BaseDialog{
t.add(text).left().padRight(5)
.update(a -> a.setColor(condition.get() ? Color.white : Color.gray));
t.field((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s)))
.padRight(100f)
.padRight(50f)
.update(a -> a.setDisabled(!condition.get()))
.valid(f -> Strings.canParsePositiveFloat(f) && Strings.parseFloat(f) >= min && Strings.parseFloat(f) <= max).width(120f).left();
}).padTop(0);
@ -429,7 +436,7 @@ public class CustomRulesDialog extends BaseDialog{
Table table = new Table();
table.add(cell.get()).left().expandX().fillX();
cell.clearElement();
table.button(Icon.infoSmall, () -> ui.showInfo(text + ".info")).size(32f).padRight(24f).right();
table.button(Icon.infoSmall, () -> ui.showInfo(text + ".info")).size(32f).right();
cell.setElement(table).left().expandX().fillX();
}else{
cell.tooltip(text + ".info");

View file

@ -105,7 +105,7 @@ public class HudFragment{
|| (!block.inEditor && !(block instanceof RemoveWall) && !(block instanceof RemoveOre))
|| !block.isOnPlanet(state.rules.planet)
|| block.buildVisibility == BuildVisibility.debugOnly
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.toLowerCase()))
|| (!searchText.isEmpty() && !block.localizedName.toLowerCase().contains(searchText.trim().replaceAll(" +", " ").toLowerCase()))
) continue;
ImageButton button = new ImageButton(Tex.whiteui, Styles.clearNoneTogglei);