From 53a364120b21fe615caba4dd16bb0f90623c0a1e Mon Sep 17 00:00:00 2001 From: Jeremy Potter Date: Thu, 16 Apr 2020 12:11:26 +0000 Subject: [PATCH] * Makes frag messages ("you fragged XXX") bigger (1.8x the size of normal centerprint messages) and makes them bold. * Does this by implementing a new operator in `HUD_CenterPrint` - "`^BOLD`." Put `^BOLD` at the beginning of a centerprint notification to make it bold. --- _hud_descriptions.cfg | 1 + hud_luma.cfg | 1 + hud_luminos.cfg | 1 + hud_luminos_minimal.cfg | 1 + hud_luminos_minimal_xhair.cfg | 1 + hud_luminos_old.cfg | 1 + hud_nexuiz.cfg | 1 + qcsrc/client/autocvars.qh | 1 + qcsrc/client/hud/hud_config.qc | 1 + qcsrc/client/hud/panel/centerprint.qc | 33 ++++++++++++++++++++------- qcsrc/common/notifications/all.inc | 16 ++++++------- qcsrc/common/notifications/all.qh | 3 +++ 12 files changed, 45 insertions(+), 16 deletions(-) diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg index 9bb1b84a6..3f0355b5f 100644 --- a/_hud_descriptions.cfg +++ b/_hud_descriptions.cfg @@ -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)" diff --git a/hud_luma.cfg b/hud_luma.cfg index 84e73404d..7b8361816 100644 --- a/hud_luma.cfg +++ b/hud_luma.cfg @@ -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" diff --git a/hud_luminos.cfg b/hud_luminos.cfg index 2b0d14a27..a7e95f56f 100644 --- a/hud_luminos.cfg +++ b/hud_luminos.cfg @@ -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" diff --git a/hud_luminos_minimal.cfg b/hud_luminos_minimal.cfg index be4a87ae2..646b149d6 100644 --- a/hud_luminos_minimal.cfg +++ b/hud_luminos_minimal.cfg @@ -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" diff --git a/hud_luminos_minimal_xhair.cfg b/hud_luminos_minimal_xhair.cfg index db0fc51c6..f8716369d 100644 --- a/hud_luminos_minimal_xhair.cfg +++ b/hud_luminos_minimal_xhair.cfg @@ -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" diff --git a/hud_luminos_old.cfg b/hud_luminos_old.cfg index 4baea4852..16b498a75 100644 --- a/hud_luminos_old.cfg +++ b/hud_luminos_old.cfg @@ -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" diff --git a/hud_nexuiz.cfg b/hud_nexuiz.cfg index 726620501..0e0f079e8 100644 --- a/hud_nexuiz.cfg +++ b/hud_nexuiz.cfg @@ -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" diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 234f9b0a9..d125ae8a6 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -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; diff --git a/qcsrc/client/hud/hud_config.qc b/qcsrc/client/hud/hud_config.qc index 27a33c408..4b5963cc4 100644 --- a/qcsrc/client/hud/hud_config.qc +++ b/qcsrc/client/hud/hud_config.qc @@ -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"); diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index d5601e5a3..5d47ed85a 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -6,6 +6,9 @@ #include // 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 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) diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc index ca63d9f1b..9b1be824e 100644 --- a/qcsrc/common/notifications/all.inc +++ b/qcsrc/common/notifications/all.inc @@ -575,8 +575,8 @@ #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 ) @@ -584,8 +584,8 @@ 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 ) @@ -593,8 +593,8 @@ 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 ) @@ -602,8 +602,8 @@ 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 ) diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 192c22432..3b009b256 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -12,6 +12,9 @@ #include #endif +// Operator for bold notifications +#define BOLD_OPERATOR "^BOLD" + /** main types/groups of notifications */ ENUMCLASS(MSG) /** "Global" AND "personal" announcer messages */ -- 2.39.2