Skip to content

Commit

Permalink
same list depth for right/left justified serverbroser fields
Browse files Browse the repository at this point in the history
fixes #10
  • Loading branch information
sauerbraten committed Dec 21, 2020
1 parent ed4a9d4 commit 1b4ebe6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 31 deletions.
28 changes: 11 additions & 17 deletions patches/serverbrowser.patch
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,19 @@ Index: src/fpsgame/fps.cpp
===================================================================
--- src/fpsgame/fps.cpp (revision 6479)
+++ src/fpsgame/fps.cpp (working copy)
@@ -1173,13 +1173,34 @@
@@ -1173,13 +1173,28 @@
}
}

+ #define justified(elem,handleclick,dir) \
+ { \
+ if(dir) \
+ { \
+ g->pushlist(); \
+ g->spring(); \
+ g->pushlist(); /* get vertical list dir back, so mergehits works */ \
+ } \
+ g->pushlist(); \
+ if(dir) g->spring(); \
+ g->pushlist(); /* get vertical list dir back, so mergehits works */ \
+ int up = elem; \
+ if(handleclick && up&G3D_UP) return true; \
+ if(dir) \
+ { \
+ g->poplist(); \
+ g->poplist(); \
+ } \
+ g->poplist(); \
+ g->poplist(); \
+ }
+
+ #include "colors.h"
Expand All @@ -55,7 +49,7 @@ Index: src/fpsgame/fps.cpp
if(struts[i]) g->strut(struts[i]);
g->mergehits(true);
return true;
@@ -1204,36 +1227,37 @@
@@ -1204,36 +1221,37 @@

bool serverinfoentry(g3d_gui *g, int i, const char *name, int port, const char *sdesc, const char *map, int ping, const vector<int> &attr, int np)
{
Expand Down Expand Up @@ -85,11 +79,11 @@ Index: src/fpsgame/fps.cpp

case 7:
- if(g->buttonf("%d ", 0xFFFFDD, NULL, port)&G3D_UP) return true;
+ leftjustified(g->buttonf("%s ", COL_WHITE, NULL, name));
+ leftjustified(g->buttonf("%s", COL_WHITE, NULL, name));
break;

case 8:
+ rightjustified(g->buttonf("%d ", COL_WHITE, NULL, port));
+ rightjustified(g->buttonf("%d", COL_WHITE, NULL, port));
+ break;
+
+ case 9:
Expand All @@ -99,11 +93,11 @@ Index: src/fpsgame/fps.cpp
+ leftjustified(g->button(sdesc, COL_WHITE));
}
- else if(g->buttonf("[%s protocol] ", 0xFFFFDD, NULL, attr.empty() ? "unknown" : (attr[0] < PROTOCOL_VERSION ? "older" : "newer"))&G3D_UP) return true;
+ else leftjustified(g->buttonf("[%s protocol] ", COL_WHITE, NULL, attr.empty() ? "unknown" : (attr[0] < PROTOCOL_VERSION ? "older" : "newer")));
+ else leftjustified(g->buttonf("[%s protocol]", COL_WHITE, NULL, attr.empty() ? "unknown" : (attr[0] < PROTOCOL_VERSION ? "older" : "newer")));
break;
}
return false;
@@ -1243,52 +1267,55 @@
@@ -1243,52 +1261,55 @@
{
case 0:
{
Expand Down
22 changes: 8 additions & 14 deletions src/fpsgame/fps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,19 +1187,13 @@ namespace game

#define justified(elem,handleclick,dir) \
{ \
if(dir) \
{ \
g->pushlist(); \
g->spring(); \
g->pushlist(); /* get vertical list dir back, so mergehits works */ \
} \
g->pushlist(); \
if(dir) g->spring(); \
g->pushlist(); /* get vertical list dir back, so mergehits works */ \
int up = elem; \
if(handleclick && up&G3D_UP) return true; \
if(dir) \
{ \
g->poplist(); \
g->poplist(); \
} \
g->poplist(); \
g->poplist(); \
}

#include "colors.h"
Expand Down Expand Up @@ -1255,19 +1249,19 @@ namespace game
break;

case 7:
leftjustified(g->buttonf("%s ", COL_WHITE, NULL, name));
leftjustified(g->buttonf("%s", COL_WHITE, NULL, name));
break;

case 8:
rightjustified(g->buttonf("%d ", COL_WHITE, NULL, port));
rightjustified(g->buttonf("%d", COL_WHITE, NULL, port));
break;

case 9:
if(ping < 0)
{
leftjustified(g->button(sdesc, COL_WHITE));
}
else leftjustified(g->buttonf("[%s protocol] ", COL_WHITE, NULL, attr.empty() ? "unknown" : (attr[0] < PROTOCOL_VERSION ? "older" : "newer")));
else leftjustified(g->buttonf("[%s protocol]", COL_WHITE, NULL, attr.empty() ? "unknown" : (attr[0] < PROTOCOL_VERSION ? "older" : "newer")));
break;
}
return false;
Expand Down

0 comments on commit 1b4ebe6

Please sign in to comment.