Database dialog search bar
This commit is contained in:
@@ -386,7 +386,7 @@ public class Bullets implements ContentList{
|
||||
hittable = false;
|
||||
}};
|
||||
|
||||
pyraFlame = new BulletType(4f, 50f){{
|
||||
pyraFlame = new BulletType(4f, 55f){{
|
||||
ammoMultiplier = 6f;
|
||||
hitSize = 7f;
|
||||
lifetime = 18f;
|
||||
|
||||
@@ -20,6 +20,8 @@ import mindustry.world.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class DatabaseDialog extends BaseDialog{
|
||||
private TextField search;
|
||||
private Table all = new Table();
|
||||
|
||||
public DatabaseDialog(){
|
||||
super("@database");
|
||||
@@ -28,28 +30,38 @@ public class DatabaseDialog extends BaseDialog{
|
||||
addCloseButton();
|
||||
shown(this::rebuild);
|
||||
onResize(this::rebuild);
|
||||
|
||||
all.margin(20).marginTop(0f);
|
||||
|
||||
cont.table(s -> {
|
||||
s.image(Icon.zoom).padRight(8);
|
||||
search = s.field(null, text -> rebuild()).growX().get();
|
||||
search.setMessageText(Core.bundle.get("players.search"));
|
||||
}).fillX().padBottom(4).row();
|
||||
|
||||
cont.pane(all);
|
||||
}
|
||||
|
||||
void rebuild(){
|
||||
cont.clear();
|
||||
|
||||
Table table = new Table();
|
||||
table.margin(20);
|
||||
ScrollPane pane = new ScrollPane(table);
|
||||
all.clear();
|
||||
var text = search.getText();
|
||||
|
||||
Seq<Content>[] allContent = Vars.content.getContentMap();
|
||||
|
||||
for(int j = 0; j < allContent.length; j++){
|
||||
ContentType type = ContentType.all[j];
|
||||
|
||||
Seq<Content> array = allContent[j].select(c -> c instanceof UnlockableContent u && (!u.isHidden() || u.node() != null));
|
||||
Seq<Content> array = allContent[j]
|
||||
.select(c -> c instanceof UnlockableContent u &&
|
||||
(!u.isHidden() || u.node() != null) &&
|
||||
(text.isEmpty() || u.localizedName.toLowerCase().contains(text.toLowerCase())));
|
||||
if(array.size == 0) continue;
|
||||
|
||||
table.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
table.row();
|
||||
table.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
|
||||
table.row();
|
||||
table.table(list -> {
|
||||
all.add("@content." + type.name() + ".name").growX().left().color(Pal.accent);
|
||||
all.row();
|
||||
all.image().growX().pad(5).padLeft(0).padRight(0).height(3).color(Pal.accent);
|
||||
all.row();
|
||||
all.table(list -> {
|
||||
list.left();
|
||||
|
||||
int cols = (int)Mathf.clamp((Core.graphics.getWidth() - Scl.scl(30)) / Scl.scl(32 + 10), 1, 22);
|
||||
@@ -94,10 +106,12 @@ public class DatabaseDialog extends BaseDialog{
|
||||
}
|
||||
}
|
||||
}).growX().left().padBottom(10);
|
||||
table.row();
|
||||
all.row();
|
||||
}
|
||||
|
||||
cont.add(pane);
|
||||
if(all.getChildren().isEmpty()){
|
||||
all.add("@none.found");
|
||||
}
|
||||
}
|
||||
|
||||
boolean unlocked(UnlockableContent content){
|
||||
|
||||
@@ -20,7 +20,7 @@ public class PlayerListFragment extends Fragment{
|
||||
public Table content = new Table().marginRight(13f).marginLeft(13f);
|
||||
private boolean visible = false;
|
||||
private Interval timer = new Interval();
|
||||
private TextField sField;
|
||||
private TextField search;
|
||||
private Seq<Player> players = new Seq<>();
|
||||
|
||||
@Override
|
||||
@@ -47,12 +47,9 @@ public class PlayerListFragment extends Fragment{
|
||||
cont.table(Tex.buttonTrans, pane -> {
|
||||
pane.label(() -> Core.bundle.format(Groups.player.size() == 1 ? "players.single" : "players", Groups.player.size()));
|
||||
pane.row();
|
||||
sField = pane.field(null, text -> {
|
||||
rebuild();
|
||||
}).grow().pad(8).get();
|
||||
sField.name = "search";
|
||||
sField.setMaxLength(maxNameLength);
|
||||
sField.setMessageText(Core.bundle.format("players.search"));
|
||||
|
||||
search = pane.field(null, text -> rebuild()).grow().pad(8).name("search").maxTextLength(maxNameLength).get();
|
||||
search.setMessageText(Core.bundle.get("players.search"));
|
||||
|
||||
pane.row();
|
||||
pane.pane(content).grow().get().setScrollingDisabled(true, false);
|
||||
@@ -83,8 +80,8 @@ public class PlayerListFragment extends Fragment{
|
||||
Groups.player.copy(players);
|
||||
|
||||
players.sort(Structs.comps(Structs.comparing(Player::team), Structs.comparingBool(p -> !p.admin)));
|
||||
if(sField.getText().length() > 0){
|
||||
players.filter(p -> Strings.stripColors(p.name().toLowerCase()).contains(sField.getText().toLowerCase()));
|
||||
if(search.getText().length() > 0){
|
||||
players.filter(p -> Strings.stripColors(p.name().toLowerCase()).contains(search.getText().toLowerCase()));
|
||||
}
|
||||
|
||||
for(var user : players){
|
||||
@@ -181,7 +178,7 @@ public class PlayerListFragment extends Fragment{
|
||||
rebuild();
|
||||
}else{
|
||||
Core.scene.setKeyboardFocus(null);
|
||||
sField.clearText();
|
||||
search.clearText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user