summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/client.txt5
-rw-r--r--src/client/ui/menu.c8
-rw-r--r--src/client/ui/servers.c32
-rw-r--r--src/client/ui/ui.h1
4 files changed, 46 insertions, 0 deletions
diff --git a/doc/client.txt b/doc/client.txt
index 0d6fc6c..c2a3095 100644
--- a/doc/client.txt
+++ b/doc/client.txt
@@ -968,6 +968,11 @@ ui_sortservers::
- 4 — sort by players
- 5 — sort by RTT
+ui_colorservers::
+ Enables highlighting of entries in server browser with different colors.
+ Currently, this option grays out password protected and anticheat enforced
+ servers. Default value is 0 (disabled).
+
ui_pingrate::
Specifies the server pinging rate used by server browser, in packets per
second. Default value is 0, which estimates the default pinging rate based
diff --git a/src/client/ui/menu.c b/src/client/ui/menu.c
index ce45b25..642bbaf 100644
--- a/src/client/ui/menu.c
+++ b/src/client/ui/menu.c
@@ -1397,6 +1397,10 @@ static void MenuList_Draw(menuList_t *l)
// draw contents
s = (char *)l->items[i] + l->extrasize;
+ if (l->mlFlags & MLF_COLOR) {
+ R_SetColor(*((uint32_t *)(s - 4)));
+ }
+
xx = x;
for (j = 0; j < l->numcolumns; j++) {
if (!*s) {
@@ -1412,6 +1416,10 @@ static void MenuList_Draw(menuList_t *l)
yy += MLIST_SPACING;
}
+
+ if (l->mlFlags & MLF_COLOR) {
+ R_SetColor(U32_WHITE);
+ }
}
void MenuList_Sort(menuList_t *l, int offset, int (*cmpfunc)(const void *, const void *))
diff --git a/src/client/ui/servers.c b/src/client/ui/servers.c
index c7dd0aa..1ff97e0 100644
--- a/src/client/ui/servers.c
+++ b/src/client/ui/servers.c
@@ -59,6 +59,7 @@ typedef struct {
int numPlayers;
char *players[MAX_STATUS_PLAYERS];
unsigned timestamp;
+ uint32_t color;
char name[1];
} serverslot_t;
@@ -81,6 +82,7 @@ typedef struct {
static m_servers_t m_servers;
static cvar_t *ui_sortservers;
+static cvar_t *ui_colorservers;
static cvar_t *ui_pingrate;
static void UpdateSelection(void)
@@ -180,6 +182,20 @@ static serverslot_t *FindSlot(const netadr_t *search, int *index_p)
return found;
}
+static uint32_t ColorForStatus(const serverStatus_t *status)
+{
+ if (atoi(Info_ValueForKey(status->infostring, "needpass")) >= 1)
+ return uis.color.disabled.u32;
+
+ if (atoi(Info_ValueForKey(status->infostring, "anticheat")) >= 2)
+ return uis.color.disabled.u32;
+
+ if (Q_stricmp(Info_ValueForKey(status->infostring, "NoFake"), "ENABLED") == 0)
+ return uis.color.disabled.u32;
+
+ return U32_WHITE;
+}
+
/*
=================
UI_StatusEvent
@@ -253,6 +269,7 @@ void UI_StatusEvent(const serverStatus_t *status)
slot->status = SLOT_VALID;
slot->address = net_from;
slot->hostname = hostname;
+ slot->color = ColorForStatus(status);
m_servers.list.items[i] = slot;
@@ -336,6 +353,7 @@ void UI_ErrorEvent(netadr_t *from)
slot->status = SLOT_ERROR;
slot->address = address;
slot->hostname = hostname;
+ slot->color = U32_WHITE;
slot->numRules = 0;
slot->numPlayers = 0;
slot->timestamp = timestamp;
@@ -396,6 +414,7 @@ static menuSound_t PingSelected(void)
slot->status = SLOT_PENDING;
slot->address = address;
slot->hostname = hostname;
+ slot->color = U32_WHITE;
slot->numRules = 0;
slot->numPlayers = 0;
slot->timestamp = com_eventTime;
@@ -448,6 +467,7 @@ static void AddServer(const netadr_t *address, const char *hostname)
slot->status = SLOT_IDLE;
slot->address = *address;
slot->hostname = UI_CopyString(hostname);
+ slot->color = U32_WHITE;
slot->numRules = 0;
slot->numPlayers = 0;
slot->timestamp = com_eventTime;
@@ -1037,10 +1057,20 @@ static void Free(menuFrameWork_t *self)
memset(&m_servers, 0, sizeof(m_servers));
}
+static void ui_colorservers_changed(cvar_t *self)
+{
+ if (self->integer)
+ m_servers.list.mlFlags |= MLF_COLOR;
+ else
+ m_servers.list.mlFlags &= ~MLF_COLOR;
+}
+
void M_Menu_Servers(void)
{
ui_sortservers = Cvar_Get("ui_sortservers", "0", 0);
ui_sortservers->changed = ui_sortservers_changed;
+ ui_colorservers = Cvar_Get("ui_colorservers", "0", 0);
+ ui_colorservers->changed = ui_colorservers_changed;
ui_pingrate = Cvar_Get("ui_pingrate", "0", 0);
m_servers.menu.name = "servers";
@@ -1083,6 +1113,8 @@ void M_Menu_Servers(void)
m_servers.list.columns[4].uiFlags = UI_RIGHT;
m_servers.list.columns[4].name = "RTT";
+ ui_colorservers_changed(ui_colorservers);
+
//
// server info
//
diff --git a/src/client/ui/ui.h b/src/client/ui/ui.h
index cd7fb60..7c1df9c 100644
--- a/src/client/ui/ui.h
+++ b/src/client/ui/ui.h
@@ -175,6 +175,7 @@ typedef struct menuSlider_s {
#define MLF_HEADER 0x00000001
#define MLF_SCROLLBAR 0x00000002
+#define MLF_COLOR 0x00000004
typedef struct menuListColumn_s {
char *name;