mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 04:28:27 +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
|
about.button = About
|
||||||
name = Name:
|
name = Name:
|
||||||
noname = Pick a[accent] player name[] first.
|
noname = Pick a[accent] player name[] first.
|
||||||
|
search = Search:
|
||||||
planetmap = Planet Map
|
planetmap = Planet Map
|
||||||
launchcore = Launch Core
|
launchcore = Launch Core
|
||||||
filename = File Name:
|
filename = File Name:
|
||||||
|
@ -40,6 +40,8 @@ public class JoinDialog extends BaseDialog{
|
|||||||
int lastPort;
|
int lastPort;
|
||||||
Task ping;
|
Task ping;
|
||||||
|
|
||||||
|
String serverSearch = "";
|
||||||
|
|
||||||
public JoinDialog(){
|
public JoinDialog(){
|
||||||
super("@joingame");
|
super("@joingame");
|
||||||
|
|
||||||
@ -395,6 +397,15 @@ public class JoinDialog extends BaseDialog{
|
|||||||
|
|
||||||
global.clear();
|
global.clear();
|
||||||
global.background(null);
|
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 ++){
|
for(int i = 0; i < defaultServers.size; i ++){
|
||||||
ServerGroup group = defaultServers.get((i + defaultServers.size/2) % defaultServers.size);
|
ServerGroup group = defaultServers.get((i + defaultServers.size/2) % defaultServers.size);
|
||||||
boolean hidden = group.hidden();
|
boolean hidden = group.hidden();
|
||||||
@ -411,6 +422,15 @@ public class JoinDialog extends BaseDialog{
|
|||||||
net.pingHost(resaddress, resport, res -> {
|
net.pingHost(resaddress, resport, res -> {
|
||||||
if(refreshes != cur) return;
|
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
|
//add header
|
||||||
if(groupTable[0] == null){
|
if(groupTable[0] == null){
|
||||||
global.table(t -> groupTable[0] = t).row();
|
global.table(t -> groupTable[0] = t).row();
|
||||||
|
Loading…
Reference in New Issue
Block a user