From d545d26d4bf76f01da8de64d7d8c69d130c83109 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 28 Dec 2019 16:38:28 +0100 Subject: [PATCH] Improve player number coloring in the server browser - Servers with only one available slot now have their player count displayed in yellow. - Empty servers now have their player count grayed out. --- fpsgame/fps.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/fpsgame/fps.cpp b/fpsgame/fps.cpp index 7fe7940..2d771c8 100644 --- a/fpsgame/fps.cpp +++ b/fpsgame/fps.cpp @@ -2056,6 +2056,24 @@ namespace game return false; } + const char* playerscolor; + if(attr.length() >= 4) { + if(np >= attr[3]) { + // full server + playerscolor = "\f3"; + } else if (np > attr[3] - 1) { + // almost full server (only one slot left) + playerscolor = "\f2"; + } else if (np <= 0) { + // empty server + playerscolor = "\f4"; + } else { + playerscolor = ""; + } + } else { + playerscolor = ""; + } + if(attr.empty() || attr[0]!=PROTOCOL_VERSION) { switch(i) @@ -2067,7 +2085,7 @@ namespace game case 1: if(attr.length()>=4) { - if(g->buttonf(np >= attr[3] ? "\f3%d/%d " : "%d/%d ", 0xFFFFDD, NULL, np, attr[3])&G3D_UP) return true; + if(g->buttonf("%s%d/%d ", 0xFFFFDD, NULL, playerscolor, np, attr[3])&G3D_UP) return true; } else if(g->buttonf("%d ", 0xFFFFDD, NULL, np)&G3D_UP) return true; break; @@ -2122,7 +2140,7 @@ namespace game case 1: if(attr.length()>=4) { - if(g->buttonf(np >= attr[3] ? "\f3%d/%d " : "%d/%d ", 0xFFFFDD, NULL, np, attr[3])&G3D_UP) return true; + if(g->buttonf("%s%d/%d ", 0xFFFFDD, NULL, playerscolor, np, attr[3])&G3D_UP) return true; } else if(g->buttonf("%d ", 0xFFFFDD, NULL, np)&G3D_UP) return true; break;