1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-10-06 04:47:14 +03:00

Community server search (#7305)

* basic community server search

* normalise capitalisation

* localise "Search:"
This commit is contained in:
Luna 2022-08-11 16:36:10 +01:00 committed by GitHub
parent 1a85c85a22
commit e28dbfad69
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -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:

View File

@ -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();