From 125150921e0c96986401e72a229fcace65b66fd7 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sun, 26 Feb 2006 23:16:09 +0000 Subject: [PATCH] use highlighting instead of blinking, few other color changes git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2033 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/m_master.c | 157 +++++++++++++++++++++++++-------------- 1 file changed, 100 insertions(+), 57 deletions(-) diff --git a/engine/client/m_master.c b/engine/client/m_master.c index 0358e9de7..44c0e7c6a 100644 --- a/engine/client/m_master.c +++ b/engine/client/m_master.c @@ -106,6 +106,16 @@ static void NM_PrintColoured (int cx, int cy, int colour, qbyte *str) } } +static void NM_PrintHighlighted (int cx, int cy, int colour, int bg, qbyte *str) +{ + while (*str) + { + NM_DrawColouredCharacter (cx, cy, (*str) | (colour<0) + + if (highlight >= 0) { - NM_DrawColouredCharacter (right, y, (*(unsigned char *)text) | (colour<0) + { + NM_DrawColouredCharacter (right, y, (*(unsigned char *)text) | (colour<0) + { + NM_DrawColouredCharacter (right, y, (*(unsigned char *)text) | (colour<name) { if (server->special & SS_FAVORITE) @@ -378,40 +405,39 @@ void M_DrawServerList(void) else if (server->special & SS_QUAKE3) colour = COLOR_BLUE; else if (server->special & SS_NETQUAKE) - colour = COLOR_WHITE; + colour = COLOR_GREY; else if (server->special & SS_QTV) colour = COLOR_MAGENTA; else colour = COLOR_WHITE; - if (blink) - { - if (server->special & SS_NETQUAKE) - colour = COLOR_MAGENTA; //nq blinks magenta - else - colour = COLOR_CYAN; - } - x = vid.width; + // make sure we have a highlighted background + if (highlight >= 0) + { + int i = 8; + for (; i < vid.width - 8; i += 8) + Draw_ColouredCharacter(i, y, ' ' | CON_NONCLEARBG | (COLOR_WHITE << CON_FGSHIFT) | (highlight << CON_BGSHIFT)); + } + if (sb_showtimelimit.value) - x = M_AddColumn(x, y, va("%i", server->tl), 3, colour); //time limit + x = M_AddColumn(x, y, va("%i", server->tl), 3, colour, highlight); //time limit if (sb_showfraglimit.value) - x = M_AddColumn(x, y, va("%i", server->fl), 3, colour); //frag limit + x = M_AddColumn(x, y, va("%i", server->fl), 3, colour, highlight); //frag limit if (sb_showplayers.value) - x = M_AddColumn(x, y, va("%i/%i", server->players, server->maxplayers), 6, colour); + x = M_AddColumn(x, y, va("%i/%i", server->players, server->maxplayers), 6, colour, highlight); if (sb_showmap.value) - x = M_AddColumn(x, y, server->map, 9, colour); + x = M_AddColumn(x, y, server->map, 9, colour, highlight); if (sb_showgamedir.value) - x = M_AddColumn(x, y, server->gamedir, 9, colour); + x = M_AddColumn(x, y, server->gamedir, 9, colour, highlight); if (sb_showping.value) - x = M_AddColumn(x, y, va("%i", server->ping), 4, colour); //frag limit + x = M_AddColumn(x, y, va("%i", server->ping), 4, colour, highlight); //frag limit if (sb_showaddress.value) - x = M_AddColumn(x, y, NET_AdrToString(server->adr), 21, colour); - x = M_AddColumn(x, y, server->name, x/8-1, colour); + x = M_AddColumn(x, y, NET_AdrToString(server->adr), 21, colour, highlight); + x = M_AddColumn(x, y, server->name, x/8-1, colour, highlight); } - blink = 0; if (*server->name) y+=8; @@ -426,11 +452,11 @@ void M_DrawServerList(void) void M_DrawSources (void) { - int blink; int snum=0; int op; int y = 3*8; master_t *mast; + int clr; slist_numoptions = 0; //find total sources. @@ -471,23 +497,30 @@ void M_DrawSources (void) if (M_MasterIsFiltered(mast)) continue; - if (slist_option == snum) - blink = (int)(realtime*3)&1; - else - blink = 0; + switch (mast->type) + { + case MT_MASTERHTTP: + case MT_MASTERHTTPQW: + clr = COLOR_YELLOW; + break; + case MT_MASTERQW: + case MT_MASTERQ2: + clr = COLOR_WHITE; + break; + case MT_SINGLENQ: + case MT_SINGLEQW: + case MT_SINGLEQ2: + clr = COLOR_GREEN; + break; + default: + clr = COLOR_RED; + } - if (blink) - NM_PrintColoured(46, y, 6, va("%s", mast->name)); //blinking. - else if (mast->type == MT_MASTERQW || mast->type == MT_MASTERQ2) - NM_PrintColoured(46, y, COLOR_WHITE, va("%s", mast->name)); //white. -#ifdef NQPROT - else if (mast->type == MT_SINGLENQ) - NM_PrintColoured(46, y, COLOR_GREEN, va("%s", mast->name)); //green. -#endif - else if (mast->type == MT_SINGLEQW || mast->type == MT_SINGLEQ2) - NM_PrintColoured(46, y, COLOR_GREEN, va("%s", mast->name)); //green. + if (slist_option == snum) // highlight it if selected + NM_PrintHighlighted(46, y, clr, COLOR_DARKBLUE, va("%s", mast->name)); else - NM_PrintColoured(46, y, COLOR_RED, va("%s", mast->name)); //red. + NM_PrintColoured(46, y, clr, va("%s", mast->name)); + y+=8; snum++; } @@ -526,30 +559,37 @@ void M_DrawSListOptions (void) { int c; int op; + char *s; slist_numoptions = NUMSLISTOPTIONS; for (op = 0; op < NUMSLISTOPTIONS; op++) { - if (slist_option == op && (int)(realtime*3)&1) - c = COLOR_CYAN; //cyan + if (options[op].cvar->value>0 || (*options[op].cvar->string && *options[op].cvar->string != '0')) + c = COLOR_RED; else - c = (options[op].cvar->value>0 || (*options[op].cvar->string && *options[op].cvar->string != '0'))?COLOR_RED:COLOR_WHITE;//red if on. + c = COLOR_WHITE; + switch(options[op].type) { default: - NM_PrintColoured(46, op*8+8*3, c, options[op].title); + s = options[op].title; break; case 1: if (!options[op].cvar->value) { - NM_PrintColoured(46, op*8+8*3, c, va("%s ", options[op].title)); + s = va("%s ", options[op].title); break; } case 2: - NM_PrintColoured(46, op*8+8*3, c, va("%s %s", options[op].title, options[op].cvar->string)); + s = va("%s %s", options[op].title, options[op].cvar->string); break; } + + if (slist_option == op) // selected + NM_PrintHighlighted(46, op*8+8*3, c, COLOR_DARKBLUE, s); + else + NM_PrintColoured(46, op*8+8*3, c, s); } } @@ -621,7 +661,10 @@ void M_DrawServers(void) lofs = width/2 - 7*4; for (snum = 0; snum < NUMSLISTHEADERS; snum++) { - NM_PrintColoured(width*snum+width/2 - strlen(titles[snum])*4, 0, slist_type==snum?COLOR_RED:COLOR_WHITE, titles[snum]); + if (slist_type == snum) + NM_PrintHighlighted(width*snum+width/2 - strlen(titles[snum])*4, 0, COLOR_WHITE, COLOR_DARKBLUE, titles[snum]); + else + NM_PrintColoured(width*snum+width/2 - strlen(titles[snum])*4, 0, COLOR_WHITE, titles[snum]); } NM_PrintColoured(8, 8, COLOR_WHITE, "\35"); for (snum = 16; snum < vid.width-16; snum+=8)