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