mirror of
https://github.com/nzp-team/quakec.git
synced 2025-02-01 14:11:05 +00:00
MENU: menu_coop.qc: add manual refresh button
This commit is contained in:
parent
ef5d3209f8
commit
22ff9e5fd7
1 changed files with 26 additions and 3 deletions
|
@ -76,6 +76,7 @@ void() Menu_Coop_Password_Update =
|
|||
}
|
||||
};
|
||||
|
||||
// this flushes the server cache
|
||||
void() Menu_Coop_Browse_Refresh =
|
||||
{
|
||||
static float refreshtime;
|
||||
|
@ -83,7 +84,27 @@ void() Menu_Coop_Browse_Refresh =
|
|||
if (refreshtime > time)
|
||||
return;
|
||||
|
||||
refreshtime = time + 0.1;
|
||||
refreshtime = time + 0.5;
|
||||
|
||||
resethostcachemasks();
|
||||
// TODO: figure out why this returns 0 servers
|
||||
// sethostcachemaskstring(0, gethostcacheindexforkey("gamedir"), cvar_string("game"), SLIST_TEST_EQUAL);
|
||||
sethostcachesort(gethostcacheindexforkey("ping"), false);
|
||||
refreshhostcache(true);
|
||||
resorthostcache();
|
||||
|
||||
num_cached_servers = (int)gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);
|
||||
};
|
||||
|
||||
// this updates the current server cache
|
||||
void() Menu_Coop_Browse_Update =
|
||||
{
|
||||
static float refreshtime;
|
||||
|
||||
if (refreshtime > time)
|
||||
return;
|
||||
|
||||
refreshtime = time + 0.5;
|
||||
|
||||
resethostcachemasks();
|
||||
// TODO: figure out why this returns 0 servers
|
||||
|
@ -97,19 +118,21 @@ void() Menu_Coop_Browse_Refresh =
|
|||
|
||||
void() Menu_Coop_Browse =
|
||||
{
|
||||
|
||||
Menu_Coop_Browse_Refresh();
|
||||
Menu_Coop_Browse_Update();
|
||||
|
||||
Menu_DrawBackground();
|
||||
|
||||
Menu_DrawTitle("BROWSE SERVERS");
|
||||
|
||||
// refresh button
|
||||
|
||||
// draw server list
|
||||
sui_set_align([SUI_ALIGN_CENTER, SUI_ALIGN_CENTER]);
|
||||
static vector serverlist_scrollofs;
|
||||
vector vsize = sui_current_frame_size();
|
||||
Menu_ServerList("cbm_serverlist", [0, 0], [vsize.x, vsize.y / 2], serverlist_scrollofs, num_cached_servers);
|
||||
|
||||
Menu_Button(-2, "cbm_refresh", "REFRESH", "Refresh server list.") ? Menu_Coop_Browse_Refresh() : 0;
|
||||
Menu_Button(-1, "cbm_back", "BACK", "Return to Join Game Menu.") ? current_menu = MENU_COOPJOIN : 0;
|
||||
|
||||
sui_pop_frame();
|
||||
|
|
Loading…
Reference in a new issue