This is a fork of Zandronum Beta for Mac Os (Silicon and Intel)
修訂 | 66b94bcd9b8021e0b12f2c9ef90743aa69f1201c (tree) |
---|---|
時間 | 2022-08-22 12:29:43 |
作者 | Adam Kaminski <kaminskiadam9@gmai...> |
Commiter | Adam Kaminski |
Added an option to filter the server list by name within the built-in server browser menu.
@@ -105,6 +105,10 @@ | ||
105 | 105 | { |
106 | 106 | M_BuildServerList(); |
107 | 107 | } |
108 | +CUSTOM_CVAR( String, menu_browser_filtername, "", CVAR_ARCHIVE ) // [AK] | |
109 | +{ | |
110 | + M_BuildServerList(); | |
111 | +} | |
108 | 112 | |
109 | 113 | // ================================================================================================= |
110 | 114 | // |
@@ -479,6 +483,24 @@ | ||
479 | 483 | return ( false ); |
480 | 484 | } |
481 | 485 | |
486 | + // [AK] Only show servers containing words that we want to filter in. | |
487 | + if ( strlen( menu_browser_filtername ) > 0 ) | |
488 | + { | |
489 | + FString hostName = BROWSER_GetHostName( lServer ); | |
490 | + FString filterName = menu_browser_filtername.GetGenericRep( CVAR_String ).String; | |
491 | + | |
492 | + // [AK] A filter string that's longer than the server's name obviously means that it can't be shown. | |
493 | + if ( filterName.Len( ) > hostName.Len( )) | |
494 | + return ( false ); | |
495 | + | |
496 | + // [AK] Set both strings to lowercase first. | |
497 | + hostName.ToLower( ); | |
498 | + filterName.ToLower( ); | |
499 | + | |
500 | + if ( strstr( hostName, filterName ) == NULL ) | |
501 | + return ( false ); | |
502 | + } | |
503 | + | |
482 | 504 | return ( true ); |
483 | 505 | } |
484 | 506 |
@@ -588,6 +610,13 @@ | ||
588 | 610 | } |
589 | 611 | |
590 | 612 | //***************************************************************************** |
613 | +// [AK] | |
614 | +CCMD ( menu_clear_browser_filter ) | |
615 | +{ | |
616 | + menu_browser_filtername = ""; | |
617 | +} | |
618 | + | |
619 | +//***************************************************************************** | |
591 | 620 | // |
592 | 621 | CCMD ( menu_join_selected_server ) |
593 | 622 | { |
@@ -244,6 +244,7 @@ | ||
244 | 244 | Option "Sort by", "menu_browser_sortby", "ZA_ServerSortType" |
245 | 245 | Option "Show empty", "menu_browser_showempty", "YesNo" |
246 | 246 | Option "Show full", "menu_browser_showfull", "YesNo" |
247 | + TextField "Filter name", "menu_browser_filtername" | |
247 | 248 | StaticText " " |
248 | 249 | StaticText " " // Header |
249 | 250 | StaticText " " |
@@ -257,6 +258,7 @@ | ||
257 | 258 | ServerBrowserSlot 7 |
258 | 259 | StaticText " " |
259 | 260 | Command "Refresh", "querymaster" |
261 | + Command "Clear filter", "menu_clear_browser_filter" | |
260 | 262 | Submenu "Get server info", "ZA_ServerInfo" |
261 | 263 | SafeCommand "Join game!", "menu_join_selected_server" |
262 | 264 | } |