From ce6ec2713d73f21877d3bc87a634286b94d0ef0e Mon Sep 17 00:00:00 2001 From: sauerbraten Date: Sun, 11 Apr 2021 22:27:24 +0200 Subject: [PATCH] add gamehud.patch --- Makefile | 1 + README.md | 17 ++-- data/p1xbraten/gamehud.cfg | 57 ++++++++++--- data/p1xbraten/gamehud.cfg.gz.xxd | 59 ++++++++----- data/p1xbraten/stats_gamehud.cfg | 13 +++ patches/gamehud.patch | 134 ++++++++++++++++++++++++++++++ patches/moviehud.patch | 22 ----- src/engine/main.cpp | 1 + src/engine/rendergl.cpp | 35 ++++++-- src/fpsgame/client.cpp | 8 ++ src/fpsgame/fps.cpp | 19 ----- src/fpsgame/p1xbraten_cfgs.cpp | 4 +- 12 files changed, 282 insertions(+), 88 deletions(-) create mode 100644 data/p1xbraten/stats_gamehud.cfg create mode 100644 patches/gamehud.patch diff --git a/Makefile b/Makefile index a495c3f..89ea792 100644 --- a/Makefile +++ b/Makefile @@ -40,6 +40,7 @@ apply-patches: $(PATCH) < patches/zenmode.patch $(PATCH) < patches/authservers.patch $(PATCH) < patches/serverlogging.patch + $(PATCH) < patches/gamehud.patch unix2dos src/vcpp/sauerbraten.nsi unix2dos src/vcpp/sauerbraten.vcxproj cd src && make depend diff --git a/README.md b/README.md index 961710a..7c6b469 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ This repository contains the source for my client mod, as well as the patches ap - [zenmode.patch](#zenmodepatch) - [authservers.patch](#authserverspatch) - [serverlogging.patch](#serverloggingpatch) + - [gamehud.patch](#gamehudpatch) - [Installation](#installation) - [Windows](#windows) - [macOS](#macos) @@ -38,7 +39,6 @@ a.k.a. Features ### [moviehud.patch](./patches/moviehud.patch) -- adds `hidespecfollow` toggle: when 1, hides the "SPECTATOR" and player name in the lower right of the screen when spectating - adds `namesabovehead` toggle: when 0, hides the names above players' models (usually rendered as particle text), while keeping status icons for health boost, armor and quad ### [scoreboard.patch](./patches/scoreboard.patch) @@ -79,14 +79,11 @@ a.k.a. Features All of the new damage-related commands (as well as `getaccuracy`) default to showing `hudplayer`'s stats across all weapons. However, they all take two optional integer arguments to query stats of a certain player and optionally for a specific weapon: `/ [cn] [weapon]` (use -1 as CN to query specific weapon stats about `hudplayer`). - To show comed-like statistics in the lower right corner, run `/exec data/p1xbraten/gamehud.cfg.gz`. + To show comed-like statistics in the lower right corner, copy the contents of [`stats_gamehud.cfg`](./data/p1xbraten/stats_gamehud.cfg) into your `autoexec.cfg`. ### [hudfragmessages.patch](./patches/hudfragmessages.patch) - enables frag messages showing the weapon used to complete the frag (on by default) - - ![fragmessages](https://i.imgur.com/K4GL6oB.png) - - adds the following variables: - `hudfragmessages`: 0 disables all frag messages, 1 enables them for all modes, 2 enables them for non-insta modes only - `maxhudfragmessages`: how many messages to show at most (between 1 and 10) @@ -101,6 +98,8 @@ a.k.a. Features You can easily configure the hud frag messages using the [improved menu](#menu) (options → hud → adjust hud frag messages). +![fragmessages](https://i.imgur.com/K4GL6oB.png) + ### [fullconsole.patch](./patches/fullconsole.patch) - removes the guiskin background of fullconsole in favor of a gradient background on the left @@ -171,6 +170,14 @@ For example, you can put `addauthserver "p1x.pw" "p1x.pw" 28787 "m"` into your ` - logs a "join" message including CN and player name - logs map changes +### [gamehud.patch](./patches/gamehud.patch) + +- properly right-justifies gamehud, wallclock, showfps, and/or showfpsrange lines +- adds a useful playerlist showing who's alive vs. dead when spectating in the lower right corner +- adds `isdead ` command to check if a player is currently dead (only works when you are spectating) + +
gamehud with player state
+ ## Installation The latest builds are always at https://github.com/sauerbraten/p1xbraten/releases/latest. diff --git a/data/p1xbraten/gamehud.cfg b/data/p1xbraten/gamehud.cfg index 7ce401a..2991954 100644 --- a/data/p1xbraten/gamehud.cfg +++ b/data/p1xbraten/gamehud.cfg @@ -1,13 +1,44 @@ -gamehud = [ - format "^f7SG: ^f1%1%% ^f7CG: ^f1%2%% ^f7RL: ^f1%3%% ^f7RI: ^f1%4%% ^f7GL: ^f1%5%% ^n^t^f7frags: ^f0%6 ^f7deaths: ^f3%7 ^f7acc: ^f2%8%% ^f7kpd: ^f5%9" ( - round (getaccuracy -1 1) 0.1 )( - round (getaccuracy -1 2) 0.1 )( - round (getaccuracy -1 3) 0.1 )( - round (getaccuracy -1 4) 0.1 )( - round (getaccuracy -1 5) 0.1 )( - getfrags )( - getdeaths )( - round (getaccuracy) 0.1 )( - round (divf (getfrags) (max (getdeaths) 1)) 0.1 - ) -] \ No newline at end of file +p1xbratengamehud = [ + local playerstates + playerstates = [ + local playerlist teamlist teams players + playerlist = [ + local players playernamecolor + players = $arg1 + looplistconcatword cn $players [ + playernamecolor = (? (= $getfollow $cn) "^f2" (? (isdead $cn) "^f4" "^f7")) + concatword "^n^fs" $playernamecolor (getclientname $cn) "^fr" + ] + ] + teamlist = [ + local teamname teamplayers teamnamecolor + teamname = $arg1 + teamplayers = $arg2 + if $teamname [ + teamnamecolor = (? (=s $teamname "spectators") "^f2" (? (=s $teamname $getteam) "^f1" "^f3")) + ] + concatword "^fs" $teamnamecolor $teamname ":^fr" (playerlist $teamplayers) + ] + teams = (listteams 1 1 0) + if (listlen $teams) [ + looplistconcatword teamname $teams [ + players = (listclients 1 1 0 $teamname) + result (? (listlen $players) (concatword (teamlist $teamname $players) "^n^n") "") + ] + ] [ + players = (listclients 1 1 0) + result (? (listlen $players) (concatword "^fs^f7players:^fr" (playerlist $players) "^n^n") "") + ] + ] + + local specgamehud + if (isspectator $getclientnum) [ + specgamehud = (concatword (playerstates) "^fs^f2SPECTATOR^fr^n") + ] + + if (> (strlen (getalias "gamehud")) 0) [ + specgamehud = (concatword $specgamehud "^n" (gamehud)) + ] + + result $specgamehud +] diff --git a/data/p1xbraten/gamehud.cfg.gz.xxd b/data/p1xbraten/gamehud.cfg.gz.xxd index fee4f3c..72d1c6a 100644 --- a/data/p1xbraten/gamehud.cfg.gz.xxd +++ b/data/p1xbraten/gamehud.cfg.gz.xxd @@ -1,19 +1,40 @@ - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00,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, 0x53, 0x60, 0xa5, 0x3b, 0x28, 0x1f, 0x90, + 0x94, 0xa4, 0xb9, 0x58, 0xd6, 0x90, 0x54, 0x4d, 0xb9, 0xc9, 0x84, 0x5b, + 0x51, 0xe2, 0x00, 0x69, 0x04, 0xcc, 0x0b, 0xb5, 0x2e, 0x56, 0xf3, 0x5b, + 0x31, 0x41, 0xfb, 0xef, 0x0a, 0x10, 0x3d, 0xcc, 0x6f, 0xda, 0xfb, 0x06, + 0xf4, 0x0f, 0xd5, 0x40, 0x31, 0x5d, 0x95, 0x9f, 0x7e, 0x1c, 0x87, 0xf4, + 0x52, 0xa8, 0x02, 0xea, 0xc1, 0x95, 0x09, 0x09, 0x73, 0x90, 0xa6, 0xfd, + 0xb0, 0x8f, 0xd4, 0x89, 0x1e, 0x5b, 0xa0, 0x40, 0xe8, 0xab, 0xa3, 0x4d, + 0xd5, 0x2d, 0x9e, 0x1f, 0xef, 0xef, 0x56, 0xb7, 0xab, 0x87, 0x27, 0x28, + 0x0f, 0x6b, 0x88, 0xb9, 0x31, 0xd1, 0x35, 0x6b, 0x9c, 0xb7, 0xd8, 0x1e, + 0x3e, 0x54, 0x42, 0x0d, 0xc2, 0x31, 0x9e, 0xac, 0x61, 0xd8, 0x80, 0xc6, + 0x1f, 0x09, 0x6b, 0xba, 0x05, 0x2d, 0x42, 0xf7, 0x69, 0xd5, 0xa6, 0x34, + 0x09, 0x25, 0x15, 0x56, 0x5d, 0xf5, 0x09, 0x2a, 0xc3, 0xa6, 0x1c, 0x0d, + 0x05, 0x00, 0x00 diff --git a/data/p1xbraten/stats_gamehud.cfg b/data/p1xbraten/stats_gamehud.cfg new file mode 100644 index 0000000..95b249e --- /dev/null +++ b/data/p1xbraten/stats_gamehud.cfg @@ -0,0 +1,13 @@ +gamehud = [ + format "^f7SG: ^f1%1%% ^f7CG: ^f1%2%% ^f7RL: ^f1%3%% ^f7RI: ^f1%4%% ^f7GL: ^f1%5%% ^n^f7frags: ^f0%6 ^f7deaths: ^f3%7 ^f7acc: ^f2%8%% ^f7kpd: ^f5%9" ( + round (getaccuracy -1 1) 0.1 )( + round (getaccuracy -1 2) 0.1 )( + round (getaccuracy -1 3) 0.1 )( + round (getaccuracy -1 4) 0.1 )( + round (getaccuracy -1 5) 0.1 )( + getfrags )( + getdeaths )( + round (getaccuracy) 0.1 )( + round (divf (getfrags) (max (getdeaths) 1)) 0.1 + ) +] diff --git a/patches/gamehud.patch b/patches/gamehud.patch new file mode 100644 index 0000000..43200cc --- /dev/null +++ b/patches/gamehud.patch @@ -0,0 +1,134 @@ +Index: src/engine/main.cpp +=================================================================== +--- src/engine/main.cpp (revision 6496) ++++ src/engine/main.cpp (working copy) +@@ -1299,3 +1299,4 @@ ++ execfile("data/p1xbraten/gamehud.cfg.gz"); + + identflags |= IDF_PERSIST; + +Index: src/engine/rendergl.cpp +=================================================================== +--- src/engine/rendergl.cpp (revision 6496) ++++ src/engine/rendergl.cpp (working copy) +@@ -2256,8 +2256,12 @@ + int nextfps[3]; + getfps(nextfps[0], nextfps[1], nextfps[2]); + loopi(3) if(prevfps[i]==curfps[i]) curfps[i] = nextfps[i]; +- if(showfpsrange) draw_textf("fps %d+%d-%d", conw-7*FONTH, conh-FONTH*3/2, curfps[0], curfps[1], curfps[2]); +- else draw_textf("fps %d", conw-5*FONTH, conh-FONTH*3/2, curfps[0]); ++ static string buf; ++ if(showfpsrange) formatstring(buf, "(+%d-%d) %d fps", curfps[1], curfps[2], curfps[0]); ++ else formatstring(buf, "%d fps", curfps[0]); ++ int tw, th; ++ text_bounds(buf, tw, th); ++ draw_text(buf, conw-tw-FONTH, conh-FONTH*3/2); + roffset += FONTH; + } + +@@ -2267,7 +2271,7 @@ + time_t walloffset = walltime + totalmillis/1000; + struct tm *localvals = localtime(&walloffset); + static string buf; +- if(localvals && strftime(buf, sizeof(buf), wallclocksecs ? (wallclock24 ? "%H:%M:%S" : "%I:%M:%S%p") : (wallclock24 ? "%H:%M" : "%I:%M%p"), localvals)) ++ if(localvals && strftime(buf, sizeof(buf), wallclocksecs ? (wallclock24 ? "%H:%M:%S" : "%I:%M:%S %p") : (wallclock24 ? "%H:%M" : "%I:%M %p"), localvals)) + { + // hack because not all platforms (windows) support %P lowercase option + // also strip leading 0 from 12 hour time +@@ -2274,12 +2278,14 @@ + char *dst = buf; + const char *src = &buf[!wallclock24 && buf[0]=='0' ? 1 : 0]; + while(*src) *dst++ = tolower(*src++); +- *dst++ = '\0'; +- draw_text(buf, conw-5*FONTH, conh-FONTH*3/2-roffset); ++ *dst++ = '\0'; ++ int tw, th; ++ text_bounds(buf, tw, th); ++ draw_text(buf, conw-tw-FONTH, conh-FONTH*3/2-roffset); + roffset += FONTH; + } + } +- ++ + if(editmode || showeditstats) + { + static int laststats = 0, prevstats[8] = { 0, 0, 0, 0, 0, 0, 0 }, curstats[8] = { 0, 0, 0, 0, 0, 0, 0 }; +@@ -2325,7 +2331,7 @@ + DELETEA(editinfo); + } + } +- else if(char *gameinfo = execidentstr("gamehud")) ++ else if(char *gameinfo = execidentstr("p1xbratengamehud")) + { + if(gameinfo[0]) + { +@@ -2333,8 +2339,21 @@ + text_bounds(gameinfo, tw, th); + th += FONTH-1; th -= th%FONTH; + roffset += max(th, FONTH); +- draw_text(gameinfo, conw-max(5*FONTH, 2*FONTH+tw), conh-FONTH/2-roffset); ++ int thoffset = 0; ++ char *line = gameinfo, *lineend = line; ++ while(*line && *lineend) ++ { ++ while(*lineend && *lineend!='\n') lineend++; ++ bool atend = !*lineend; ++ *lineend = '\0'; ++ int lw, lh; ++ text_bounds(line, lw, lh); ++ draw_text(line, conw-lw-FONTH, conh-FONTH/2-roffset+thoffset); ++ thoffset += max(lh, FONTH); ++ if(atend) break; ++ line = lineend = lineend+1; + } ++ } + DELETEA(gameinfo); + } + +Index: src/fpsgame/client.cpp +=================================================================== +--- src/fpsgame/client.cpp (revision 6496) ++++ src/fpsgame/client.cpp (working copy) +@@ -332,6 +332,14 @@ + ICOMMAND(getmastermode, "", (), intret(mastermode)); + ICOMMAND(mastermodename, "i", (int *mm), result(server::mastermodename(*mm, ""))); + ++ bool isdead(int cn) ++ { ++ if(player1->state != CS_SPECTATOR) return false; ++ fpsent *d = getclient(cn); ++ return d && d->state==CS_DEAD; ++ } ++ ICOMMAND(isdead, "i", (int *cn), intret(isdead(*cn) ? 1 : 0)); ++ + bool isspectator(int cn) + { + fpsent *d = getclient(cn); +Index: src/fpsgame/fps.cpp +=================================================================== +--- src/fpsgame/fps.cpp (revision 6496) ++++ src/fpsgame/fps.cpp (working copy) +@@ -1056,23 +1056,6 @@ + hudmatrix.scale(h/1800.0f, h/1800.0f, 1); + flushhudmatrix(); + +- if(player1->state==CS_SPECTATOR) +- { +- int pw, ph, tw, th, fw, fh; +- text_bounds(" ", pw, ph); +- text_bounds("SPECTATOR", tw, th); +- th = max(th, ph); +- fpsent *f = followingplayer(); +- text_bounds(f ? colorname(f) : " ", fw, fh); +- fh = max(fh, ph); +- draw_text("SPECTATOR", w*1800/h - tw - pw, 1650 - th - fh); +- if(f) +- { +- int color = statuscolor(f, 0xFFFFFF); +- draw_text(colorname(f), w*1800/h - fw - pw, 1650 - fh, (color>>16)&0xFF, (color>>8)&0xFF, color&0xFF); +- } +- } +- + fpsent *d = hudplayer(); + if(d->state!=CS_EDITING) + { diff --git a/patches/moviehud.patch b/patches/moviehud.patch index 1f8a8f6..9da367f 100644 --- a/patches/moviehud.patch +++ b/patches/moviehud.patch @@ -1,25 +1,3 @@ -Index: src/fpsgame/fps.cpp -=================================================================== ---- src/fpsgame/fps.cpp (revision 6291) -+++ src/fpsgame/fps.cpp (working copy) -@@ -1050,6 +1050,8 @@ - pophudmatrix(); - } - -+ VARP(hidespecfollow, 0, 0, 1); -+ - void gameplayhud(int w, int h) - { - pushhudmatrix(); -@@ -1056,7 +1058,7 @@ - hudmatrix.scale(h/1800.0f, h/1800.0f, 1); - flushhudmatrix(); - -- if(player1->state==CS_SPECTATOR) -+ if(player1->state==CS_SPECTATOR && !hidespecfollow) - { - int pw, ph, tw, th, fw, fh; - text_bounds(" ", pw, ph); Index: src/fpsgame/render.cpp =================================================================== --- src/fpsgame/render.cpp (revision 6291) diff --git a/src/engine/main.cpp b/src/engine/main.cpp index 934686a..d80e9cb 100644 --- a/src/engine/main.cpp +++ b/src/engine/main.cpp @@ -1316,6 +1316,7 @@ int main(int argc, char **argv) execfile(gamecfgname); if(game::savedservers()) execfile(game::savedservers(), false); game::writep1xbratencfgs(); + execfile("data/p1xbraten/gamehud.cfg.gz"); identflags |= IDF_PERSIST; diff --git a/src/engine/rendergl.cpp b/src/engine/rendergl.cpp index 14ac7f6..3647f3f 100644 --- a/src/engine/rendergl.cpp +++ b/src/engine/rendergl.cpp @@ -2277,8 +2277,12 @@ void gl_drawhud() int nextfps[3]; getfps(nextfps[0], nextfps[1], nextfps[2]); loopi(3) if(prevfps[i]==curfps[i]) curfps[i] = nextfps[i]; - if(showfpsrange) draw_textf("fps %d+%d-%d", conw-7*FONTH, conh-FONTH*3/2, curfps[0], curfps[1], curfps[2]); - else draw_textf("fps %d", conw-5*FONTH, conh-FONTH*3/2, curfps[0]); + static string buf; + if(showfpsrange) formatstring(buf, "(+%d-%d) %d fps", curfps[1], curfps[2], curfps[0]); + else formatstring(buf, "%d fps", curfps[0]); + int tw, th; + text_bounds(buf, tw, th); + draw_text(buf, conw-tw-FONTH, conh-FONTH*3/2); roffset += FONTH; } @@ -2288,19 +2292,21 @@ void gl_drawhud() time_t walloffset = walltime + totalmillis/1000; struct tm *localvals = localtime(&walloffset); static string buf; - if(localvals && strftime(buf, sizeof(buf), wallclocksecs ? (wallclock24 ? "%H:%M:%S" : "%I:%M:%S%p") : (wallclock24 ? "%H:%M" : "%I:%M%p"), localvals)) + if(localvals && strftime(buf, sizeof(buf), wallclocksecs ? (wallclock24 ? "%H:%M:%S" : "%I:%M:%S %p") : (wallclock24 ? "%H:%M" : "%I:%M %p"), localvals)) { // hack because not all platforms (windows) support %P lowercase option // also strip leading 0 from 12 hour time char *dst = buf; const char *src = &buf[!wallclock24 && buf[0]=='0' ? 1 : 0]; while(*src) *dst++ = tolower(*src++); - *dst++ = '\0'; - draw_text(buf, conw-5*FONTH, conh-FONTH*3/2-roffset); + *dst++ = '\0'; + int tw, th; + text_bounds(buf, tw, th); + draw_text(buf, conw-tw-FONTH, conh-FONTH*3/2-roffset); roffset += FONTH; } } - + if(editmode || showeditstats) { static int laststats = 0, prevstats[8] = { 0, 0, 0, 0, 0, 0, 0 }, curstats[8] = { 0, 0, 0, 0, 0, 0, 0 }; @@ -2346,7 +2352,7 @@ void gl_drawhud() DELETEA(editinfo); } } - else if(char *gameinfo = execidentstr("gamehud")) + else if(char *gameinfo = execidentstr("p1xbratengamehud")) { if(gameinfo[0]) { @@ -2354,7 +2360,20 @@ void gl_drawhud() text_bounds(gameinfo, tw, th); th += FONTH-1; th -= th%FONTH; roffset += max(th, FONTH); - draw_text(gameinfo, conw-max(5*FONTH, 2*FONTH+tw), conh-FONTH/2-roffset); + int thoffset = 0; + char *line = gameinfo, *lineend = line; + while(*line && *lineend) + { + while(*lineend && *lineend!='\n') lineend++; + bool atend = !*lineend; + *lineend = '\0'; + int lw, lh; + text_bounds(line, lw, lh); + draw_text(line, conw-lw-FONTH, conh-FONTH/2-roffset+thoffset); + thoffset += max(lh, FONTH); + if(atend) break; + line = lineend = lineend+1; + } } DELETEA(gameinfo); } diff --git a/src/fpsgame/client.cpp b/src/fpsgame/client.cpp index aed0f1a..82508c9 100644 --- a/src/fpsgame/client.cpp +++ b/src/fpsgame/client.cpp @@ -334,6 +334,14 @@ namespace game ICOMMAND(getmastermode, "", (), intret(mastermode)); ICOMMAND(mastermodename, "i", (int *mm), result(server::mastermodename(*mm, ""))); + bool isdead(int cn) + { + if(player1->state != CS_SPECTATOR) return false; + fpsent *d = getclient(cn); + return d && d->state==CS_DEAD; + } + ICOMMAND(isdead, "i", (int *cn), intret(isdead(*cn) ? 1 : 0)); + bool isspectator(int cn) { fpsent *d = getclient(cn); diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index a34f110..0f3f03d 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -1070,31 +1070,12 @@ namespace game pophudmatrix(); } - VARP(hidespecfollow, 0, 0, 1); - void gameplayhud(int w, int h) { pushhudmatrix(); hudmatrix.scale(h/1800.0f, h/1800.0f, 1); flushhudmatrix(); - if(player1->state==CS_SPECTATOR && !hidespecfollow) - { - int pw, ph, tw, th, fw, fh; - text_bounds(" ", pw, ph); - text_bounds("SPECTATOR", tw, th); - th = max(th, ph); - fpsent *f = followingplayer(); - text_bounds(f ? colorname(f) : " ", fw, fh); - fh = max(fh, ph); - draw_text("SPECTATOR", w*1800/h - tw - pw, 1650 - th - fh); - if(f) - { - int color = statuscolor(f, 0xFFFFFF); - draw_text(colorname(f), w*1800/h - fw - pw, 1650 - fh, (color>>16)&0xFF, (color>>8)&0xFF, color&0xFF); - } - } - fpsent *d = hudplayer(); if(d->state!=CS_EDITING) { diff --git a/src/fpsgame/p1xbraten_cfgs.cpp b/src/fpsgame/p1xbraten_cfgs.cpp index 5b423de..8ecdbae 100644 --- a/src/fpsgame/p1xbraten_cfgs.cpp +++ b/src/fpsgame/p1xbraten_cfgs.cpp @@ -18,9 +18,9 @@ namespace game { } }; - struct embeddedfile<222> gamehudcfg = { + struct embeddedfile<471> gamehudcfg = { "data/p1xbraten/gamehud.cfg.gz", - 0xac5cc9fd, + 0x1ca6c32a, { #include "../../data/p1xbraten/gamehud.cfg.gz.xxd" }