Skip to content

Commit

Permalink
add hudfragmessagecolors var
Browse files Browse the repository at this point in the history
  • Loading branch information
sauerbraten committed Mar 11, 2021
1 parent 2f18b5f commit b38a16b
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 9 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,12 @@ a.k.a. Features
- `hudfragmessagescale`: size of the messages, between 0.0 and 1.0
- `hudfragmessagestackdir`: direction in which to stack old messages: -1 to stack upwards, 1 to stack downwards, 0 to stack towards the closes edge of the screen depending on `hudfragmessagey`
- `hudfragmessagefilter`: bitfield filter var (like confilter), e.g. 0x3800 shows all players' frags, suicides, and teamkills
- `hudfragmessagecolors`: when 1 (default), uses colored names, even in non-team modes:
- yellow: you (while playing)
- blue: your team or the player you're spectating
- red: anyone else

You can easily configure the hud frag messages using the [improved menu](#menu) (options -> hud -> adjust hud frag messages).
You can easily configure the hud frag messages using the [improved menu](#menu) (options hud adjust hud frag messages).

### [fullconsole.patch](./patches/fullconsole.patch)

Expand Down
19 changes: 13 additions & 6 deletions patches/hudfragmessages.patch
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,23 @@ Index: src/fpsgame/fps.cpp
conoutf("follow off");
}

@@ -496,6 +500,10 @@
@@ -496,6 +500,15 @@
if(d==player1) conoutf(contype, "\f2%s got fragged by %s", dname, aname);
else conoutf(contype, "\f2%s fragged %s", aname, dname);
}
+ if(actor==player1) aname = "\f2you";
+ if(d==player1) dname = "\f2you";
+ if(hudfragmessagecolors)
+ {
+ if(h==player1 && actor==player1) aname = "\fs\f2you\fr";
+ else aname = colorname(actor, aname, actor==h ? "\fs\f1" : "\fs\f3", "\fr", NULL);
+ if(h==player1 && d==player1) dname = "\fs\f2you\fr";
+ else dname = colorname(d, dname, d==h ? "\fs\f1" : "\fs\f3", "\fr", NULL);
+ }
+ if(d==actor) addfragmessage(contype, NULL, dname, HICON_TOKEN-HICON_FIST);
+ else addfragmessage(contype, aname, dname, d->lasthitpushgun);
deathstate(d);
ai::killed(d, actor);
}
@@ -1091,6 +1099,7 @@
@@ -1091,6 +1104,7 @@
{
if(gameclock) drawgameclock(w, h);
if(hudscore) drawhudscore(w, h);
Expand All @@ -75,7 +80,7 @@ Index: src/fpsgame/fragmessages.cpp
===================================================================
--- src/fpsgame/fragmessages.cpp (nonexistent)
+++ src/fpsgame/fragmessages.cpp (working copy)
@@ -0,0 +1,76 @@
@@ -0,0 +1,77 @@
+#include "game.h"
+
+namespace game {
Expand All @@ -90,6 +95,7 @@ Index: src/fpsgame/fragmessages.cpp
+ FVARP(hudfragmessagescale, 0.1f, 0.5f, 1.0f);
+ VARP(hudfragmessagestackdir, -1, 0, 1); // -1 = upwards, 1 = downwards
+ HVARP(hudfragmessagefilter, 0, 0x2800, 0x7FFFFFF); // default: own frags + teamkills
+ VARP(hudfragmessagecolors, 0, 1, 1);
+
+ void addfragmessage(int contype, const char *aname, const char *vname, int gun)
+ {
Expand Down Expand Up @@ -156,7 +162,7 @@ Index: src/fpsgame/fragmessages.h
===================================================================
--- src/fpsgame/fragmessages.h (nonexistent)
+++ src/fpsgame/fragmessages.h (working copy)
@@ -0,0 +1,28 @@
@@ -0,0 +1,29 @@
+#ifndef __FRAGMESSAGES_H__
+#define __FRAGMESSAGES_H__
+
Expand All @@ -179,6 +185,7 @@ Index: src/fpsgame/fragmessages.h
+
+ extern vector<fragmessage> fragmessages;
+ extern int hudfragmessages;
+ extern int hudfragmessagecolors;
+ extern void addfragmessage(int contype, const char *aname, const char *vname, int gun);
+ extern void clearfragmessages();
+ extern void drawfragmessages(int w, int h);
Expand Down
9 changes: 7 additions & 2 deletions src/fpsgame/fps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -506,8 +506,13 @@ namespace game
if(d==player1) conoutf(contype, "\f2%s got fragged by %s", dname, aname);
else conoutf(contype, "\f2%s fragged %s", aname, dname);
}
if(actor==player1) aname = "\f2you";
if(d==player1) dname = "\f2you";
if(hudfragmessagecolors)
{
if(h==player1 && actor==player1) aname = "\fs\f2you\fr";
else aname = colorname(actor, aname, actor==h ? "\fs\f1" : "\fs\f3", "\fr", NULL);
if(h==player1 && d==player1) dname = "\fs\f2you\fr";
else dname = colorname(d, dname, d==h ? "\fs\f1" : "\fs\f3", "\fr", NULL);
}
if(d==actor) addfragmessage(contype, NULL, dname, HICON_TOKEN-HICON_FIST);
else addfragmessage(contype, aname, dname, d->lasthitpushgun);
deathstate(d);
Expand Down
1 change: 1 addition & 0 deletions src/fpsgame/fragmessages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace game {
FVARP(hudfragmessagescale, 0.1f, 0.5f, 1.0f);
VARP(hudfragmessagestackdir, -1, 0, 1); // -1 = upwards, 1 = downwards
HVARP(hudfragmessagefilter, 0, 0x2800, 0x7FFFFFF); // default: own frags + teamkills
VARP(hudfragmessagecolors, 0, 1, 1);

void addfragmessage(int contype, const char *aname, const char *vname, int gun)
{
Expand Down
1 change: 1 addition & 0 deletions src/fpsgame/fragmessages.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace game {

extern vector<fragmessage> fragmessages;
extern int hudfragmessages;
extern int hudfragmessagecolors;
extern void addfragmessage(int contype, const char *aname, const char *vname, int gun);
extern void clearfragmessages();
extern void drawfragmessages(int w, int h);
Expand Down

0 comments on commit b38a16b

Please sign in to comment.