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