Search bar cleanup
This commit is contained in:
@@ -77,7 +77,7 @@ abstract class BuilderComp implements Posc, Teamc, Rotc{
|
||||
if(plans.size > 1){
|
||||
int total = 0;
|
||||
BuildPlan req;
|
||||
while((dst((req = buildPlan()).tile()) > finalPlaceDst || shouldSkip(req, core)) && total < plans.size){
|
||||
while((!within((req = buildPlan()).tile(), finalPlaceDst) || shouldSkip(req, core)) && total < plans.size){
|
||||
plans.removeFirst();
|
||||
plans.addLast(req);
|
||||
total++;
|
||||
|
||||
@@ -8,6 +8,7 @@ abstract class TimerComp{
|
||||
transient Interval timer = new Interval(6);
|
||||
|
||||
public boolean timer(int index, float time){
|
||||
if(Float.isInfinite(time)) return false;
|
||||
return timer.get(index, time);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,50 +1,55 @@
|
||||
package mindustry.ui;
|
||||
|
||||
import arc.func.*;
|
||||
import arc.graphics.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class SearchBar{
|
||||
|
||||
public static <T> Table add(Table parent, Seq<T> list, Func<String, String> queryf,
|
||||
Func<T, String> namef, Cons2<Table, T> itemc, Cons<Cell<Table>> barc){
|
||||
Cons<String>[] rebuild = new Cons[]{null};
|
||||
Func<T, String> namef, Cons2<Table, T> itemc, boolean show){
|
||||
Table[] pane = {null};
|
||||
|
||||
barc.get(parent.table(search -> {
|
||||
rebuild[0] = str -> {
|
||||
String query = queryf.get(str);
|
||||
Cons<String> rebuild = str -> {
|
||||
String query = queryf.get(str);
|
||||
|
||||
pane[0].clear();
|
||||
list.each(item -> {
|
||||
if(query.isEmpty() || matches(query, namef.get(item))){
|
||||
itemc.get(pane[0], item);
|
||||
}
|
||||
});
|
||||
};
|
||||
pane[0].clear();
|
||||
boolean any = false;
|
||||
for(T item : list){
|
||||
if(query.isEmpty() || matches(query, namef.get(item))){
|
||||
any = true;
|
||||
itemc.get(pane[0], item);
|
||||
}
|
||||
}
|
||||
|
||||
search.image(Icon.zoom).padRight(8f);
|
||||
search.field("", rebuild[0]).growX();
|
||||
}).fillX().padBottom(4));
|
||||
if(!any){
|
||||
pane[0].add("@none.found").color(Color.lightGray).pad(4);
|
||||
}
|
||||
};
|
||||
|
||||
if(show){
|
||||
parent.table(search -> {
|
||||
search.image(Icon.zoom).padRight(8f);
|
||||
search.field("", rebuild).growX();
|
||||
}).fillX().padBottom(4);
|
||||
}
|
||||
|
||||
parent.row();
|
||||
parent.pane(table -> {
|
||||
pane[0] = table;
|
||||
rebuild[0].get("");
|
||||
rebuild.get("");
|
||||
});
|
||||
return pane[0];
|
||||
}
|
||||
|
||||
public static <T> Table add(Table parent, Seq<T> list, Func<String, String> queryf, Func<T, String> namef, Cons2<Table, T> itemc){
|
||||
return add(parent, list, queryf, namef, itemc, c -> {});
|
||||
return add(parent, list, queryf, namef, itemc, true);
|
||||
}
|
||||
|
||||
public static <T> Table add(Table parent, Seq<T> list, Func<T, String> namef, Cons2<Table, T> itemc, Cons<Cell<Table>> barc){
|
||||
return add(parent, list, String::toLowerCase, namef, itemc, barc);
|
||||
}
|
||||
|
||||
public static <T> Table add(Table parent, Seq<T> list, Func<T, String> namef, Cons2<Table, T> itemc){
|
||||
return add(parent, list, String::toLowerCase, namef, itemc);
|
||||
public static <T> Table add(Table parent, Seq<T> list, Func<T, String> namef, Cons2<Table, T> itemc, boolean show){
|
||||
return add(parent, list, String::toLowerCase, namef, itemc, show);
|
||||
}
|
||||
|
||||
/** Match a list item with the search query, case insensitive */
|
||||
|
||||
@@ -312,12 +312,7 @@ public class ModsDialog extends BaseDialog{
|
||||
}).growX().right().padRight(-8f).padTop(-8f);
|
||||
}, Styles.clearPartialt, () -> showMod(mod)).size(w, h).growX().pad(4f);
|
||||
table.row();
|
||||
}, bar -> {
|
||||
if(mobile && !Core.graphics.isPortrait()){
|
||||
//hide search bar on mobile, takes up too much space
|
||||
bar.get().clear();
|
||||
}
|
||||
}).margin(10f).top();
|
||||
}, !mobile || Core.graphics.isPortrait()).margin(10f).top();
|
||||
}else{
|
||||
cont.table(Styles.black6, t -> t.add("@mods.none")).height(80f);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user