ok, done. The code I wrote it will be considered a real trash for a REAL programmer like Spike, LH, mh and others, but, for me, it's quite a success!
Instead of creating a GUI with a slider which it's quite complex to me to do it in quakec (and Spike's example in object oriented quakec it's too difficult to comprehend to me), I created a pre-determined number of rows (60 to be precise) which are populate by ip, name, players present / max players allowed and ping.
Masks are still not implemented. Next time, if I've time!
Code: Select all
void UI_MenuMultiplayerServerlist(float screeenwidth,float screeenheight)
{
local float field_address = gethostcacheindexforkey("address");
local float field_name = gethostcacheindexforkey("name");
local float field_ping = gethostcacheindexforkey("ping");
local float field_numplayers = gethostcacheindexforkey("numplayers");
local float field_maxplayers = gethostcacheindexforkey("maxplayers");
local float maxsv = gethostcachevalue(SLIST_HOSTCACHEVIEWCOUNT);//VITAL!! without this set, refresh won't work!!!
local int i,f=0;
local .float baroddeven=0;
local float thisping,baropacity;
//draw row headers
drawstring([50, 0, 0], "Address", [4, 4, 0], [0, 0.45, 0.7], 0.8, 0);
drawstring([15, 0, 0], "Ping", [4, 4, 0], [0, 0.45, 0.7], 0.8, 0);
drawstring([400, 0, 0], "Players / Max players", [4, 4, 0], [0, 0.45, 0.7], 0.8, 0);
drawstring([250, 0, 0], "Server name", [4, 4, 0], [0, 0.45, 0.7], 0.8, 0);
//populate rows
if(self.menuPage == UI_MENU_PAGE_MULTI_SERVERLIST){
for(i=0; i<UI_MENU_MULTI_SERVERLIST_MAX_ROWS; i++){
f+=UI_MENU_MULTI_SERVERLIST_CHARSIZE;
thisping = gethostcachenumber(field_ping, i);
//don't draw empty rows
if(thisping > 0){
//odd - even row background
self.baroddeven = !self.baroddeven;
if(self.baroddeven){
baropacity = 0.1;
}
else{
baropacity = 0.25;
}
//draw row elements
drawstring([50, f, 0], sprintf("%-16s", gethostcachestring(field_address, i)), [UI_MENU_MULTI_SERVERLIST_CHARSIZE, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0], [1, 1, 1], 1, 0);
drawstring([15, f, 0], sprintf("%d", gethostcachenumber(field_ping, i)), [UI_MENU_MULTI_SERVERLIST_CHARSIZE, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0], [1, 1, 1], 1, 0);
drawstring([400, f, 0], strcat(sprintf("%d", gethostcachenumber(field_numplayers, i))," / ",sprintf("%d", gethostcachenumber(field_maxplayers, i))), [UI_MENU_MULTI_SERVERLIST_CHARSIZE, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0], [1, 1, 1], 1, 0);
drawstring([250, f, 0], sprintf("%s", gethostcachestring(field_name, i)), [UI_MENU_MULTI_SERVERLIST_CHARSIZE, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0], [1, 1, 1], 1, 0);
drawfill([0,f,0] ,[screeenwidth, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0],[1 , 1, 1], baropacity,0);
}
}
local string addressselected = gethostcachestring(field_address, uiMenuServerListSelectedAddress);
//draw server selected text
if(strlen(addressselected)<4){
drawstring([screeenwidth-360,screeenheight-80, 0], "No server selected", [8, 8, 0], [0.7, 0.2, 0.2], 0.6, 0);
}
else{
drawstring([screeenwidth-360,screeenheight-80, 0], strcat("Server selected: ",gethostcachestring(field_address, uiMenuServerListSelectedAddress)), [8, 8, 0], [1, 1, 1], 0.9, 0);
}
//selected highlighted bar
if(uiMenuServerListSelectedLocY<370){
drawfill([0,(uiMenuServerListSelectedLocY+UI_MENU_MULTI_SERVERLIST_CHARSIZE),0] ,[screeenwidth, UI_MENU_MULTI_SERVERLIST_CHARSIZE, 0],[0.4 , 0.4, 0], 0.35,0);
}
}
}