From: terencehill Date: Thu, 28 May 2020 15:47:43 +0000 (+0200) Subject: Use a consistent naming scheme for the centerprint functions X-Git-Tag: xonotic-v0.8.5~1015 X-Git-Url: http://git.xonotic.org/?p=xonotic%2Fxonotic-data.pk3dir.git;a=commitdiff_plain;h=f16cb6426d3c7e37316f0d71a42f71e38ed10981 Use a consistent naming scheme for the centerprint functions --- diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index 4ad25b3fd..4995f5189 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -4,6 +4,7 @@ #include #include +#include "hud/panel/centerprint.qh" bool announcer_1min; bool announcer_5min; diff --git a/qcsrc/client/commands/cl_cmd.qc b/qcsrc/client/commands/cl_cmd.qc index f0c1e789a..0e4dbef9a 100644 --- a/qcsrc/client/commands/cl_cmd.qc +++ b/qcsrc/client/commands/cl_cmd.qc @@ -358,7 +358,7 @@ void LocalCommand_localprint(int request, int argc) { if (argv(1)) { - centerprint_hud(argv(1)); + centerprint_AddStandard(argv(1)); return; } } diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index 63e69caad..f2563c741 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -27,8 +27,8 @@ void HUD_CenterPrint_Export(int fh) } // These are the functions that draw the text at the center of the screen (e.g. frag messages and server MOTD). -// centerprint_generic parses a message and puts it in the circular buffer centerprint_messages -// centerprint_generic is usually called by Local_Notification_centerprint_generic, which is called +// centerprint_Add parses a message and puts it in the circular buffer centerprint_messages +// centerprint_Add is usually called by Local_Notification_centerprint_Add, which is called // by Local_Notification. // HUD_CenterPrint draws all the messages on screen @@ -44,10 +44,10 @@ float centerprint_expire_time[CENTERPRINT_MAX_MSGS]; int centerprint_countdown_num[CENTERPRINT_MAX_MSGS]; bool centerprint_showing; -void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num) +void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num) { TC(int, new_id); TC(int, countdown_num); - //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num); + //printf("centerprint_Add(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num); int i, j; if(strMessage == "" && new_id == 0) @@ -127,15 +127,15 @@ void centerprint_generic(int new_id, string strMessage, float duration, int coun void centerprint_kill(int id) { TC(int, id); - centerprint_generic(id, "", 0, 0); + centerprint_Add(id, "", 0, 0); } -void centerprint_hud(string strMessage) +void centerprint_AddStandard(string strMessage) { - centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0); + centerprint_Add(0, strMessage, autocvar_hud_panel_centerprint_time, 0); } -void reset_centerprint_messages() +void centerprint_KillAll() { for (int i=0; i hud_configure_cp_generation_time) @@ -171,16 +171,16 @@ void HUD_CenterPrint () float r; r = random(); if (r > 0.8) - centerprint_generic(floor(r*1000), sprintf(_("^3Countdown message at time %s, seconds left: ^COUNT"), seconds_tostring(time)), 1, 10); + centerprint_Add(floor(r*1000), sprintf(_("^3Countdown message at time %s, seconds left: ^COUNT"), seconds_tostring(time)), 1, 10); else if (r > 0.55) - centerprint_generic(0, sprintf(_("^1Multiline message at time %s that\n^1lasts longer than normal"), seconds_tostring(time)), 20, 0); + centerprint_Add(0, sprintf(_("^1Multiline message at time %s that\n^1lasts longer than normal"), seconds_tostring(time)), 20, 0); else - centerprint_hud(sprintf(_("Message at time %s"), seconds_tostring(time))); + centerprint_AddStandard(sprintf(_("Message at time %s"), seconds_tostring(time))); hud_configure_cp_generation_time = time + 1 + random()*4; } else { - centerprint_generic(0, _("Generic message"), 10, 0); + centerprint_Add(0, _("Generic message"), 10, 0); hud_configure_cp_generation_time = time + 10 - random()*3; } } @@ -274,7 +274,7 @@ void HUD_CenterPrint () all_messages_expired = false; - // fade the centerprint_hud in/out + // fade if(centerprint_time[j] < 0) // Expired but forced. Expire time is the fade-in time. a = (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in); else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) // Regularily printed. Not fading out yet. @@ -386,6 +386,6 @@ void HUD_CenterPrint () if (all_messages_expired) { centerprint_showing = false; - reset_centerprint_messages(); + centerprint_KillAll(); } } diff --git a/qcsrc/client/hud/panel/centerprint.qh b/qcsrc/client/hud/panel/centerprint.qh index 1bec93efa..92339139f 100644 --- a/qcsrc/client/hud/panel/centerprint.qh +++ b/qcsrc/client/hud/panel/centerprint.qh @@ -1,4 +1,7 @@ #pragma once #include "../panel.qh" -void reset_centerprint_messages(); +void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num); +void centerprint_AddStandard(string strMessage); +void centerprint_kill(int id); +void centerprint_KillAll(); diff --git a/qcsrc/client/main.qc b/qcsrc/client/main.qc index d6a073a5d..55868e5c7 100644 --- a/qcsrc/client/main.qc +++ b/qcsrc/client/main.qc @@ -11,6 +11,7 @@ #include "commands/cl_cmd.qh" #include "mapvoting.qh" #include +#include "hud/panel/centerprint.qh" #include "hud/panel/scoreboard.qh" #include "hud/panel/quickmenu.qh" #include "shownames.qh" @@ -920,11 +921,11 @@ void CSQC_Parse_Print(string strMessage) print(ColorTranslateRGB(strMessage)); } -// CSQC_Parse_CenterPrint : Provides the centerprint_hud string in the first parameter that the server provided. +// CSQC_Parse_CenterPrint : Provides the centerprint_AddStandard string in the first parameter that the server provided. void CSQC_Parse_CenterPrint(string strMessage) { if (autocvar_developer_csqcentities) LOG_INFOF("CSQC_Parse_CenterPrint(\"%s\")", strMessage); - centerprint_hud(strMessage); + centerprint_AddStandard(strMessage); } // CSQC_Parse_TempEntity : Handles all temporary entity network data in the CSQC layer. diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 4dcecb109..50fa49ae9 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -95,10 +95,6 @@ float chase_active_backup; float camera_roll; vector camera_direction; -void centerprint_hud(string strMessage); -void centerprint_kill(int id); -void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num); - const float ALPHA_MIN_VISIBLE = 0.003; float armorblockpercent; diff --git a/qcsrc/common/notifications/all.qc b/qcsrc/common/notifications/all.qc index 663269c93..371bbebee 100644 --- a/qcsrc/common/notifications/all.qc +++ b/qcsrc/common/notifications/all.qc @@ -159,7 +159,7 @@ void Destroy_All_Notifications() #ifdef SVQC Kill_Notification(NOTIF_ALL, NULL, MSG_Null, CPID_Null); #else - reset_centerprint_messages(); + centerprint_KillAll(); #endif // kill all real notification entities @@ -1130,7 +1130,7 @@ void Local_Notification_HUD_Notify_Push( HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]); } -void Local_Notification_centerprint_generic( +void Local_Notification_centerprint_Add( string input, string durcnt, CPID cpid, float f1, float f2) { @@ -1139,7 +1139,7 @@ void Local_Notification_centerprint_generic( for (int sel_num = 0; (durcnt != ""); ) { string selected = car(durcnt); durcnt = cdr(durcnt); - NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic"); + NOTIF_HIT_MAX(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_Add"); switch (strtolower(selected)) { #define ARG_CASE_ARG_CS_SV_HA(selected, result) @@ -1160,14 +1160,14 @@ void Local_Notification_centerprint_generic( default: { if (/* wtf */ ftos(stof(selected)) != "") { arg_slot[sel_num++] = selected; } - else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_generic") } + else { NOTIF_HIT_UNKNOWN(NOTIF_MAX_DURCNT, "Local_Notification_centerprint_Add") } break; } } } #ifdef NOTIFICATIONS_DEBUG Debug_Notification(sprintf( - "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n", + "Local_Notification_centerprint_Add('%s^7', '%s', %d, %d, %d, %d);\n", MakeConsoleSafe(input), durcnt, f1, f2, @@ -1175,7 +1175,7 @@ void Local_Notification_centerprint_generic( stof(arg_slot[1]) )); #endif - centerprint_generic(ORDINAL(cpid), input, stof(arg_slot[0]), stof(arg_slot[1])); + centerprint_Add(ORDINAL(cpid), input, stof(arg_slot[0]), stof(arg_slot[1])); } #endif @@ -1289,7 +1289,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count) #ifdef CSQC case MSG_CENTER: { - Local_Notification_centerprint_generic( + Local_Notification_centerprint_Add( Local_Notification_sprintf( notif.nent_string, notif.nent_args, @@ -1408,11 +1408,9 @@ NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new) int _net_name = net_name; CPID net_name = ENUMCAST(CPID, _net_name); if (net_name == CPID_Null) { - // kill all - reset_centerprint_messages(); + centerprint_KillAll(); } else { - // kill group - centerprint_generic(ORDINAL(net_name), "", 0, 0); + centerprint_kill(ORDINAL(net_name));// kill group } return; }