mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-21 12:08:34 +07:00
Community server search (#7305)
* basic community server search * normalise capitalisation * localise "Search:"
This commit is contained in:
parent
1a85c85a22
commit
e28dbfad69
@ -168,6 +168,7 @@ mod.scripts.disable = Your device does not support mods with scripts. You must d
|
||||
about.button = About
|
||||
name = Name:
|
||||
noname = Pick a[accent] player name[] first.
|
||||
search = Search:
|
||||
planetmap = Planet Map
|
||||
launchcore = Launch Core
|
||||
filename = File Name:
|
||||
|
@ -40,6 +40,8 @@ public class JoinDialog extends BaseDialog{
|
||||
int lastPort;
|
||||
Task ping;
|
||||
|
||||
String serverSearch = "";
|
||||
|
||||
public JoinDialog(){
|
||||
super("@joingame");
|
||||
|
||||
@ -395,6 +397,15 @@ public class JoinDialog extends BaseDialog{
|
||||
|
||||
global.clear();
|
||||
global.background(null);
|
||||
|
||||
global.table(t -> {
|
||||
t.add("@search").padRight(10);
|
||||
t.field(serverSearch, text ->
|
||||
serverSearch = text.trim().replaceAll(" +", " ").toLowerCase()
|
||||
).grow().pad(8);
|
||||
t.button(Icon.zoom, Styles.emptyi, this::refreshCommunity).size(54f);
|
||||
}).width(targetWidth()).height(70f).pad(4).row();
|
||||
|
||||
for(int i = 0; i < defaultServers.size; i ++){
|
||||
ServerGroup group = defaultServers.get((i + defaultServers.size/2) % defaultServers.size);
|
||||
boolean hidden = group.hidden();
|
||||
@ -411,6 +422,15 @@ public class JoinDialog extends BaseDialog{
|
||||
net.pingHost(resaddress, resport, res -> {
|
||||
if(refreshes != cur) return;
|
||||
|
||||
if(!serverSearch.isEmpty()){
|
||||
if(!(group.name.toLowerCase().contains(serverSearch)
|
||||
|| res.name.toLowerCase().contains(serverSearch)
|
||||
|| res.description.toLowerCase().contains(serverSearch)
|
||||
|| res.mapname.toLowerCase().contains(serverSearch)
|
||||
|| (res.modeName != null && res.modeName.toLowerCase().contains(serverSearch))))
|
||||
return;
|
||||
}
|
||||
|
||||
//add header
|
||||
if(groupTable[0] == null){
|
||||
global.table(t -> groupTable[0] = t).row();
|
||||
|
Loading…
Reference in New Issue
Block a user