]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
It begins TimePath/experiments/csqc_chat
authorTimePath <andrew.hardaker1995@gmail.com>
Wed, 28 Oct 2015 01:49:46 +0000 (12:49 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Wed, 28 Oct 2015 01:49:46 +0000 (12:49 +1100)
qcsrc/client/hud.qc
qcsrc/client/main.qc
qcsrc/common/notifications.qc
qcsrc/common/sounds/all.inc

index 7403d283582c97e4b68677a73ba94c377f8c3d08..b1fa777a474bc78e8279170fd94dca82f1680d87 100644 (file)
@@ -3688,6 +3688,12 @@ void HUD_PressedKeys(void)
        drawpic_aspect_skin(pos + eX * keysize.x * 2, ((pressedkeys & KEY_RIGHT) ? "key_right_inv.tga" : "key_right.tga"), keysize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
 }
 
+entity chatlines;
+STATIC_INIT(chatlines) { chatlines = LL_NEW(); }
+CLASS(ChatEntry, Object)
+       ATTRIB(ChatEntry, m_text, string, string_null)
+ENDCLASS(ChatEntry)
+
 // Handle chat as a panel (#12)
 //
 void HUD_Chat(void)
@@ -3761,14 +3767,26 @@ void HUD_Chat(void)
        cvar_set("con_chatwidth", ftos(mySize.x/vid_conwidth));
        cvar_set("con_chat", ftos(floor(mySize.y/autocvar_con_chatsize - 0.5)));
 
+       vector chatsize = '1 1 0' * autocvar_con_chatsize;
+
+       int n = 0;
+       int oldy = pos.y;
+       LL_EACH(chatlines, true, LAMBDA(
+               float a = 1;
+               string s = textShortenToWidth(it.m_text, mySize.x, chatsize, stringwidth_colors);
+               drawcolorcodedstring(pos, s, chatsize, a, DRAWFLAG_NORMAL);
+               pos.y += chatsize.y;
+               n = i;
+       ));
+       drawcolorcodedstring(pos, ftos(n), chatsize, 1, DRAWFLAG_NORMAL);
+       pos.y = oldy;
+
        if(autocvar__hud_configure)
        {
-               vector chatsize;
-               chatsize = '1 1 0' * autocvar_con_chatsize;
                cvar_set("con_chatrect_x", "9001"); // over 9000, we'll fake it instead for more control over theAlpha and such
-               float i, a;
-               for(i = 0; i < autocvar_con_chat; ++i)
+               for(int i = 0; i < autocvar_con_chat; ++i)
                {
+                       float a;
                        if(i == autocvar_con_chat - 1)
                                a = panel_fg_alpha;
                        else
index 0f84b7fd8258d06c846d2efa772e5eb8dbb4f61d..8062d8e758f97ab2c2135a0d4cd1b8a99ca60c92 100644 (file)
@@ -950,7 +950,32 @@ void CSQC_Parse_Print(string strMessage)
        if(autocvar_developer_csqcentities)
                LOG_INFOF("CSQC_Parse_Print(\"%s\")\n", strMessage);
 
-       print(ColorTranslateRGB(strMessage));
+       for (int i = 0, n = tokenizebyseparator(strMessage, "\n"); i < n; ++i)
+       {
+               string s = ColorTranslateRGB(argv(i));
+               int c = str2chr(s, 0);
+               if (c == 1 || c == 3) {
+                       s = substring(s, 1, -1);
+                       if (c == 1) {
+                               entity snd;
+                               if (str2chr(s, 0) == '\r') {
+                                       s = substring(s, 1, -1);
+                                       snd = SND_TALK2;
+                               } else {
+                                       snd = SND_TALK;
+                               }
+                               sound(self, CH_INFO, snd, VOL_BASE, ATTEN_NONE);
+                       }
+                       s = strcat("^3", s);
+                       ChatEntry e = NEW(ChatEntry);
+                       e.m_text = strzone(s);
+                       LL_PUSH(chatlines, e);
+                       print(s, "\n");
+               } else {
+                       s = strcat("^7", s);
+                       print(s, "\n");
+               }
+       }
 }
 
 // CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided.
index 811e7007c63e21b69548a607de73d3918698efa2..1eaba969440f62263694ce154dbfa9c5d3041c4c 100644 (file)
@@ -1548,7 +1548,12 @@ void Local_Notification(int net_type, int net_name, ...count)
 
                case MSG_INFO:
                {
-                       print(
+                       #ifdef CSQC
+                       void(string) echo = CSQC_Parse_Print;
+                       #else
+                       void(string, ...) echo = print;
+                       #endif
+                       echo(
                                Local_Notification_sprintf(
                                        notif.nent_string,
                                        notif.nent_args,
index 8a7dbbca37fafc2c155ba5b0fb2d40a3bc7b7456..a18aff55ea1d16ede96610308d983f43314a9a7e 100644 (file)
@@ -269,6 +269,7 @@ SOUND(TYPEHIT, "misc/typehit.wav");
 SOUND(SPAWN, "misc/spawn.ogg");
 
 SOUND(TALK, "misc/talk.wav");
+SOUND(TALK2, "misc/talk2.wav");
 
 SOUND(TELEPORT, "misc/teleport.ogg");