]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
* Makes frag messages ("you fragged XXX") bigger (1.8x the size of normal centerprint...
authorJeremy Potter <gitlab@stormdesign.us>
Thu, 16 Apr 2020 12:11:26 +0000 (12:11 +0000)
committerterencehill <piuntn@gmail.com>
Thu, 16 Apr 2020 12:11:26 +0000 (12:11 +0000)
* Does this by implementing a new operator in `HUD_CenterPrint` - "`^BOLD`." Put `^BOLD` at the beginning of a centerprint notification to make it bold.

12 files changed:
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/autocvars.qh
qcsrc/client/hud/hud_config.qc
qcsrc/client/hud/panel/centerprint.qc
qcsrc/common/notifications/all.inc
qcsrc/common/notifications/all.qh

index 9bb1b84a620f61cc2672d4d85a52817d384b21a1..3f0355b5fd79cae5ecf2db48b96a386d38e4a36d 100644 (file)
@@ -275,6 +275,7 @@ seta hud_panel_centerprint_bg_padding "" "if set to something else than \"\" = o
 seta hud_panel_centerprint_align "" "text alignment: 0 left, 0.5 center, 1 right"
 seta hud_panel_centerprint_flip "" "invert messages order"
 seta hud_panel_centerprint_fontscale "" "scale the text font by this amount"
+seta hud_panel_centerprint_fontscale_bold "" "scale the bold text font by this amount"
 seta hud_panel_centerprint_time "" "message duration (NOTE: certain messages have a fixed duration)"
 seta hud_panel_centerprint_fade_in "" "how long a message takes to fade in"
 seta hud_panel_centerprint_fade_out "" "how long a message takes to fade out (this time is included in the message duration and can't be > 5)"
index 84e73404d078d1daef56af39b2bbb46661081975..7b83618169ce12dc6176bf97f9ecfdc14ea177e7 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index 2b0d14a2735052c1d61a690b9a72963dc460a947..a7e95f56f32ea1909493a71f5416c8b262e5ed36 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index be4a87ae29967cb03d7ed11664abb48f161617a4..646b149d6ca8773132503d938b87323917eb983d 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index db0fc51c6e18bbd47eb8d8ccab963150668b1cdd..f8716369d3b9541d295f4d2051743d1aa6d2891e 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index 4baea48523d4579afcd2cd94f39afb06f14ceefe..16b498a75a059d31b6720e803e5441dfa8b9014e 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index 726620501f0635cca1e0384257bac0bf274069dd..0e0f079e8e25d214aa6553a8b7589dc3b3eb1854 100644 (file)
@@ -276,6 +276,7 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
+seta hud_panel_centerprint_fontscale_bold "1.8"
 seta hud_panel_centerprint_time "3"
 seta hud_panel_centerprint_fade_in "0.2"
 seta hud_panel_centerprint_fade_out "0.5"
index 234f9b0a9a4d9c2883fc8ec124955a9104a6d364..d125ae8a69aab4a2ec745e86a97f54283913a4a8 100644 (file)
@@ -243,6 +243,7 @@ float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75;
 float autocvar_hud_panel_centerprint_fade_minfontsize = 0;
 bool autocvar_hud_panel_centerprint_flip;
 float autocvar_hud_panel_centerprint_fontscale;
+float autocvar_hud_panel_centerprint_fontscale_bold;
 float autocvar_hud_panel_centerprint_time;
 bool autocvar_hud_panel_chat;
 bool autocvar_hud_panel_engineinfo;
index 27a33c408b50de484b40dbbd9722b47972756e4e..4b5963cc47f042f7741c6dc42e0c71970fcc3dd6 100644 (file)
@@ -194,6 +194,7 @@ void HUD_Panel_ExportCfg(string cfgname)
                                        HUD_Write_Cvar("hud_panel_centerprint_align");
                                        HUD_Write_Cvar("hud_panel_centerprint_flip");
                                        HUD_Write_Cvar("hud_panel_centerprint_fontscale");
+                                       HUD_Write_Cvar("hud_panel_centerprint_fontscale_bold");
                                        HUD_Write_Cvar("hud_panel_centerprint_time");
                                        HUD_Write_Cvar("hud_panel_centerprint_fade_in");
                                        HUD_Write_Cvar("hud_panel_centerprint_fade_out");
index d5601e5a34f86387a532baef847a42e52f903793..5d47ed85a06ade00a35caa5770d7ab4cbd0ef71d 100644 (file)
@@ -6,6 +6,9 @@
 #include <client/miscfunctions.qh>
 
 // CenterPrint (#16)
+// These are the functions that draw the text at the center of the screen (e.g. frag messages and server MOTDs).
+// Usually local_notification_centerprint_generic() is called, which in turn calls centerprint_generic(), which
+// uses some kind of macro magic to call HUD_CenterPrint, which draws them on screen using drawcolorcodedstring().
 
 const int CENTERPRINT_MAX_MSGS = 10;
 const int CENTERPRINT_MAX_ENTRIES = 50;
@@ -113,6 +116,7 @@ void reset_centerprint_messages()
                strfree(centerprint_messages[i]);
        }
 }
+
 float hud_configure_cp_generation_time;
 void HUD_CenterPrint ()
 {
@@ -191,15 +195,11 @@ void HUD_CenterPrint ()
                panel_size -= '2 2 0' * panel_bg_padding;
        }
 
+       bool is_bold;
+       string centerprint_message;
        int entries;
        float height;
        vector fontsize;
-       // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
-       // height = panel_size_y/entries;
-       // fontsize = '1 1 0' * height;
-       height = vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
-       fontsize = '1 1 0' * height;
-       entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
 
        int i, j, k, n, g;
        float a, sz, align, current_msg_posY = 0, msg_size;
@@ -213,6 +213,18 @@ void HUD_CenterPrint ()
        align = bound(0, autocvar_hud_panel_centerprint_align, 1);
        for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
+               // if the notification starts with ^BOLD make it bold (e.g. frag messages);
+               is_bold = (substring(centerprint_messages[j], 0, 5) == BOLD_OPERATOR);
+               // remove ^BOLD so it doesn't get printed onscreen
+               centerprint_message = is_bold ? strzone(substring(centerprint_messages[j], 5, -1)) : strzone(centerprint_messages[j]);
+
+               // entries = bound(1, floor(CENTERPRINT_MAX_ENTRIES * 4 * panel_size_y/panel_size_x), CENTERPRINT_MAX_ENTRIES);
+               // height = panel_size_y/entries;
+               // fontsize = '1 1 0' * height;
+               height = (is_bold) ? vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale_bold : vid_conheight/50 * autocvar_hud_panel_centerprint_fontscale;
+               fontsize = '1 1 0' * height;
+               entries = bound(1, floor(panel_size.y/height), CENTERPRINT_MAX_ENTRIES);
+
                if (j == CENTERPRINT_MAX_MSGS)
                        j = 0;
                if (centerprint_expire_time[j] == -1)
@@ -272,9 +284,9 @@ void HUD_CenterPrint ()
                drawfontscale = hud_scale * sz;
 
                if (centerprint_countdown_num[j])
-                       n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
+                       n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_message), "\n");
                else
-                       n = tokenizebyseparator(centerprint_messages[j], "\n");
+                       n = tokenizebyseparator(centerprint_message, "\n");
 
                if (autocvar_hud_panel_centerprint_flip)
                {
@@ -306,7 +318,9 @@ void HUD_CenterPrint ()
                                        if (align)
                                                pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize) * sz) * align;
                                        if (a > 0.5/255.0)  // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker.
+                                               if (is_bold) draw_beginBoldFont();
                                                drawcolorcodedstring(pos + eY * 0.5 * (1 - sz * hud_scale.x) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
+                                               if (is_bold) draw_endBoldFont();
                                        pos.y += fontsize.y;
                                }
                                else
@@ -341,6 +355,9 @@ void HUD_CenterPrint ()
                                return;
                        }
                }
+
+               // free up memory
+               strunzone(centerprint_message);
        }
        drawfontscale = hud_scale;
        if (all_messages_expired)
index ca63d9f1bb721da9940f9521fe855a863d12e0b4..9b1be824eccf340ff7a1a15ead0b8c59c9fc8a2d 100644 (file)
 
     #define VERBOSE_MURDER(type) strcat(MURDER_##type, "^BG%s")
 
-    #define MURDER_FRAG             _("^K3%sYou fragged ^BG%s")
-    #define MURDER_FRAG2            _("^K3%sYou scored against ^BG%s")
+    #define MURDER_FRAG             strcat(BOLD_OPERATOR, _("^K3%sYou fragged ^BG%s"))
+    #define MURDER_FRAG2            strcat(BOLD_OPERATOR, _("^K3%sYou scored against ^BG%s"))
     #define MURDER_FRAGGED          _("^K1%sYou were fragged by ^BG%s")
     #define MURDER_FRAGGED2         _("^K1%sYou were scored against by ^BG%s")
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG,                   N_ENABLE,  1, 1, "spree_cen s1",               CPID_Null,  "0 0",  MURDER_FRAG,                    MURDER_FRAG2                   )
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAGGED_VERBOSE,        N_ENABLE,  1, 4, "spree_cen s1 frag_stats",    CPID_Null,  "0 0",  VERBOSE_MURDER(FRAGGED),        VERBOSE_MURDER(FRAGGED2)       )
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_VERBOSE,           N_ENABLE,  1, 2, "spree_cen s1 frag_ping",     CPID_Null,  "0 0",  VERBOSE_MURDER(FRAG),           VERBOSE_MURDER(FRAG2)          )
 
-    #define MURDER_FRAG_FIRE        _("^K3%sYou burned ^BG%s")
-    #define MURDER_FRAG_FIRE2       _("^K3%sYou scored against ^BG%s")
+    #define MURDER_FRAG_FIRE        strcat(BOLD_OPERATOR, _("^K3%sYou burned ^BG%s"))
+    #define MURDER_FRAG_FIRE2       strcat(BOLD_OPERATOR, _("^K3%sYou scored against ^BG%s"))
     #define MURDER_FRAGGED_FIRE     _("^K1%sYou were burned by ^BG%s")
     #define MURDER_FRAGGED_FIRE2    _("^K1%sYou were scored against by ^BG%s")
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_FIRE,              N_ENABLE,  1, 1, "spree_cen s1",               CPID_Null,  "0 0",  MURDER_FRAG_FIRE,               MURDER_FRAG_FIRE2              )
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAGGED_FIRE_VERBOSE,   N_ENABLE,  1, 4, "spree_cen s1 frag_stats",    CPID_Null,  "0 0",  VERBOSE_MURDER(FRAGGED_FIRE),   VERBOSE_MURDER(FRAGGED_FIRE2)  )
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_FIRE_VERBOSE,      N_ENABLE,  1, 2, "spree_cen s1 frag_ping",     CPID_Null,  "0 0",  VERBOSE_MURDER(FRAG_FIRE),      VERBOSE_MURDER(FRAG_FIRE2)     )
 
-    #define MURDER_FRAG_FREEZE      _("^K3%sYou froze ^BG%s")
-    #define MURDER_FRAG_FREEZE2     _("^K3%sYou scored against ^BG%s")
+    #define MURDER_FRAG_FREEZE      strcat(BOLD_OPERATOR, _("^K3%sYou froze ^BG%s"))
+    #define MURDER_FRAG_FREEZE2     strcat(BOLD_OPERATOR, _("^K3%sYou scored against ^BG%s"))
     #define MURDER_FRAGGED_FREEZE   _("^K1%sYou were frozen by ^BG%s")
     #define MURDER_FRAGGED_FREEZE2  _("^K1%sYou were scored against by ^BG%s")
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_FREEZE,            N_ENABLE,  1, 1, "spree_cen s1",               CPID_Null,  "0 0",  MURDER_FRAG_FREEZE,             MURDER_FRAG_FREEZE2            )
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAGGED_FREEZE_VERBOSE, N_ENABLE,  1, 4, "spree_cen s1 frag_stats",    CPID_Null,  "0 0",  VERBOSE_MURDER(FRAGGED_FREEZE), VERBOSE_MURDER(FRAGGED_FREEZE2))
     MSG_CENTER_NOTIF(DEATH_MURDER_FRAG_FREEZE_VERBOSE,    N_ENABLE,  1, 2, "spree_cen s1 frag_ping",     CPID_Null,  "0 0",  VERBOSE_MURDER(FRAG_FREEZE),    VERBOSE_MURDER(FRAG_FREEZE2)   )
 
-    #define MURDER_TYPEFRAG         _("^K1%sYou typefragged ^BG%s")
-    #define MURDER_TYPEFRAG2        _("^K1%sYou scored against ^BG%s^K1 while they were typing")
+    #define MURDER_TYPEFRAG         strcat(BOLD_OPERATOR, _("^K1%sYou typefragged ^BG%s"))
+    #define MURDER_TYPEFRAG2        strcat(BOLD_OPERATOR, _("^K1%sYou scored against ^BG%s^K1 while they were typing"))
     #define MURDER_TYPEFRAGGED      _("^K1%sYou were typefragged by ^BG%s")
     #define MURDER_TYPEFRAGGED2     _("^K1%sYou were scored against by ^BG%s^K1 while typing")
     MSG_CENTER_NOTIF(DEATH_MURDER_TYPEFRAG,               N_ENABLE,  1, 1, "spree_cen s1",               CPID_Null,  "0 0",  MURDER_TYPEFRAG,                MURDER_TYPEFRAG2               )
index 192c2243252650ecd02a1936660781a9f09c8b69..3b009b25637a296b28cf93d2978e858df993cf73 100644 (file)
@@ -12,6 +12,9 @@
 #include <client/autocvars.qh>
 #endif
 
+// Operator for bold notifications
+#define BOLD_OPERATOR "^BOLD"
+
 /** main types/groups of notifications */
 ENUMCLASS(MSG)
        /** "Global" AND "personal" announcer messages */