Skip to content

Commit

Permalink
server browser: colored background for even/odd/qizmo servers, inspir…
Browse files Browse the repository at this point in the history
…ation from FTEQW server browser, more suggestions welcome
  • Loading branch information
johnnycz committed Jun 16, 2007
1 parent e7a4a8f commit ddc4e6c
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 11 deletions.
23 changes: 15 additions & 8 deletions Ctrl.c
@@ -1,4 +1,4 @@
// $Id: Ctrl.c,v 1.16 2007-06-16 22:23:00 johnnycz Exp $
// $Id: Ctrl.c,v 1.17 2007-06-16 23:00:18 johnnycz Exp $

#include "quakedef.h"
#include "utils.h"
Expand Down Expand Up @@ -101,24 +101,31 @@ void UI_MakeLine2(char *buf, int w)
buf[w] = 0;
}

void UI_DrawColoredAlphaBox(int x, int y, int w, int h, float r, float g, float b, float a)
{
#ifdef GLQUAKE
Draw_AlphaFillRGB(x, y, w, h, r, g, b, a);
#else
Draw_FadeBox(x, y, w, h, (c[0]+c[1]+c[2])/3, a);
#endif
}

void UI_DrawGrayBox(int x, int y, int w, int h)
{ // ridiculous function, eh?
byte *c = StringToRGB(menu_marked_bgcolor.string);
#ifdef GLQUAKE
byte c[4];
float fade = 1;

memcpy(c, StringToRGB(menu_marked_bgcolor.string), sizeof(byte)*4);
#ifdef GLQUAKE
if (menu_marked_fade.value) {
fade = 0.5 * (1.0 + sin(menu_marked_fade.value * Sys_DoubleTime())); // this give us sinusoid from 0 to 1
fade = 0.5 + (1.0 - 0.5) * fade ; // this give us sinusoid from 0.5 to 1, so no zero alpha
fade = bound(0, fade, 1); // guarantee sanity if we mess somewhere
}
#endif

#ifdef GLQUAKE
Draw_AlphaFillRGB(x, y, w, h, fade*c[0]/255, fade*c[1]/255, fade*c[2]/255, (float)c[3]/255);
#else
Draw_FadeBox(x, y, w, h, c[0], 1);
#endif
UI_DrawColoredAlphaBox(x,y,w,h,
fade*c[0]/255.0, fade*c[1]/255.0, fade*c[2]/255.0, c[3]/255.0);
}

void UI_DrawBox(int x, int y, int w, int h)
Expand Down
3 changes: 2 additions & 1 deletion Ctrl.h
@@ -1,4 +1,4 @@
// $Id: Ctrl.h,v 1.12 2007-06-16 22:23:00 johnnycz Exp $
// $Id: Ctrl.h,v 1.13 2007-06-16 23:00:18 johnnycz Exp $

#ifndef __CTRL_H__
#define __CTRL_H__
Expand All @@ -22,6 +22,7 @@ void UI_Print_Center3 (int cx, int cy, int w, char *str, clrinfo_t *clr, int clr
void UI_DrawTextBox (int x, int y, int width, int lines);
void UI_MakeLine(char *buf, int w);
void UI_MakeLine2(char *buf, int w);
void UI_DrawColoredAlphaBox(int x, int y, int w, int h, float r, float g, float b, float a);
void UI_DrawGrayBox(int x, int y, int w, int h);
void UI_DrawBox(int x, int y, int w, int h);

Expand Down
8 changes: 7 additions & 1 deletion EX_browser.c
@@ -1,5 +1,5 @@
/*
$Id: EX_browser.c,v 1.39 2007-06-16 22:23:00 johnnycz Exp $
$Id: EX_browser.c,v 1.40 2007-06-16 23:00:18 johnnycz Exp $
*/

#include "quakedef.h"
Expand Down Expand Up @@ -863,6 +863,12 @@ void Servers_Draw (int x, int y, int w, int h, CTab_t *tab, CTabPage_t *page)
UI_DrawGrayBox(x, y+8*(i+1), w, 8);
UI_DrawCharacter(x + 8*pos, y+8*(i+1), FLASHINGARROW());
}
else if (servers[servnum]->qizmo)
UI_DrawColoredAlphaBox(x, y+8*(i+1), w, 8, 0.1, 0.1, 0.3, 1);
else if (servnum % 2)
UI_DrawColoredAlphaBox(x, y+8*(i+1), w, 8, 0.1, 0.1, 0.1, 0.5);
else
UI_DrawColoredAlphaBox(x, y+8*(i+1), w, 8, 0.2, 0.2, 0.2, 0.5);

// Display server
pos = w/8;
Expand Down
1 change: 1 addition & 0 deletions EX_browser.h
Expand Up @@ -98,6 +98,7 @@ typedef struct server_data_s
int playersn;
server_occupancy occupancy;
int spectatorsn;
qbool qizmo;
qbool support_teams; // is server support team per player
} server_data;

Expand Down
6 changes: 5 additions & 1 deletion EX_browser_net.c
Expand Up @@ -226,13 +226,17 @@ void Parse_Serverinfo(server_data *s, char *info)
sprintf(s->display.timelimit, "%*.*s", COL_TIMELIMIT, COL_TIMELIMIT, strlen(tmp) > COL_TIMELIMIT ? "99" : tmp);

tmp = ValueForKey(s, "*gamedir");
if (tmp != NULL)
s->qizmo = false;
if (tmp != NULL)
sprintf(s->display.gamedir, "%.*s", COL_GAMEDIR, tmp==NULL ? "" : tmp);
else
{
tmp = ValueForKey(s, "*progs");
if (tmp != NULL && !strcmp(tmp, "666"))
{
sprintf(s->display.gamedir, "qizmo");
s->qizmo = true;
}
}

tmp = ValueForKey(s, "map");
Expand Down

0 comments on commit ddc4e6c

Please sign in to comment.