-
Notifications
You must be signed in to change notification settings - Fork 3
/
chat_highlight_words.patch
72 lines (62 loc) · 2.91 KB
/
chat_highlight_words.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Index: src/engine/main.cpp
===================================================================
--- src/engine/main.cpp (revision 6502)
+++ src/engine/main.cpp (working copy)
@@ -464,7 +464,7 @@
VARNP(relativemouse, userelativemouse, 0, 1, 1);
#endif
-bool shouldgrab = false, grabinput = false, minimized = false, canrelativemouse = true, relativemouse = false;
+bool shouldgrab = false, grabinput = false, minimized = false, hasfocus = true, canrelativemouse = true, relativemouse = false;
#ifdef SDL_VIDEO_DRIVER_X11
VAR(sdl_xgrab_bug, 0, 0, 1);
@@ -951,6 +951,7 @@
case SDL_WINDOWEVENT_FOCUS_GAINED:
shouldgrab = true;
+ hasfocus = true;
break;
case SDL_WINDOWEVENT_ENTER:
shouldgrab = false;
@@ -961,6 +962,7 @@
case SDL_WINDOWEVENT_FOCUS_LOST:
shouldgrab = false;
focused = -1;
+ hasfocus = false;
break;
case SDL_WINDOWEVENT_MINIMIZED:
Index: src/fpsgame/client.cpp
===================================================================
--- src/fpsgame/client.cpp (revision 6502)
+++ src/fpsgame/client.cpp (working copy)
@@ -930,6 +930,10 @@
ICOMMAND(servcmd, "C", (char *cmd), addmsg(N_SERVCMD, "rs", cmd));
+ MOD(SVARP, chathighlightsound, "free/tick");
+ vector<const char *> chathighlightwords;
+ ICOMMAND(addchathighlightword, "s", (char *text), chathighlightwords.add(newstring(text)));
+
static void sendposition(fpsent *d, packetbuf &q)
{
putint(q, N_POS);
@@ -1330,6 +1334,7 @@
if(d->state!=CS_DEAD && d->state!=CS_SPECTATOR)
particle_textcopy(d->abovehead(), text, PART_TEXT, 2000, 0x32FF64, 4.0f, -8);
conoutf(CON_CHAT, "%s:\f0 %s", chatcolorname(d), text);
+ if(!hasfocus) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; }
break;
}
@@ -1343,6 +1348,7 @@
if(t->state!=CS_DEAD && t->state!=CS_SPECTATOR)
particle_textcopy(t->abovehead(), text, PART_TEXT, 2000, 0x6496FF, 4.0f, -8);
conoutf(CON_TEAMCHAT, "\fs\f8[%s]\fr %s: \f8%s", t->state==CS_SPECTATOR ? "spec" : "team", chatcolorname(t), text);
+ if(!hasfocus) loopv(chathighlightwords) if(strstr(text, chathighlightwords[i])) { playsoundname(chathighlightsound); break; }
break;
}
Index: src/shared/iengine.h
===================================================================
--- src/shared/iengine.h (revision 6502)
+++ src/shared/iengine.h (working copy)
@@ -248,6 +248,7 @@
// main
extern void fatal(const char *s, ...) PRINTFARGS(1, 2);
+extern bool hasfocus;
// rendertext
extern bool setfont(const char *name);