]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Use a consistent naming scheme for the centerprint functions
authorterencehill <piuntn@gmail.com>
Thu, 28 May 2020 15:47:43 +0000 (17:47 +0200)
committerterencehill <piuntn@gmail.com>
Thu, 28 May 2020 15:47:43 +0000 (17:47 +0200)
qcsrc/client/announcer.qc
qcsrc/client/commands/cl_cmd.qc
qcsrc/client/hud/panel/centerprint.qc
qcsrc/client/hud/panel/centerprint.qh
qcsrc/client/main.qc
qcsrc/client/main.qh
qcsrc/common/notifications/all.qc

index 4ad25b3fd865618c2027922f6cb6b1d5f009a551..4995f5189a6196d3ea97cc7cb3a32debe1eabfa3 100644 (file)
@@ -4,6 +4,7 @@
 
 #include <common/notifications/all.qh>
 #include <common/stats.qh>
+#include "hud/panel/centerprint.qh"
 
 bool announcer_1min;
 bool announcer_5min;
index f0c1e789ab9407037d383e651e6cfe27f0be6922..0e4dbef9a7fd81ec5c93f7196ece90ccbdc3fbe4 100644 (file)
@@ -358,7 +358,7 @@ void LocalCommand_localprint(int request, int argc)
                {
                        if (argv(1))
                        {
-                               centerprint_hud(argv(1));
+                               centerprint_AddStandard(argv(1));
                                return;
                        }
                }
index 63e69caad868c063e7a770137c4456defe8f6b9b..f2563c741f79ca2a8e03fe5044cc65aecdfb1c71 100644 (file)
@@ -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<CENTERPRINT_MAX_MSGS; ++i)
        {
@@ -148,20 +148,20 @@ void reset_centerprint_messages()
 }
 
 float hud_configure_cp_generation_time;
-void HUD_CenterPrint ()
+void HUD_CenterPrint()
 {
        if(!autocvar__hud_configure)
        {
                if(!autocvar_hud_panel_centerprint) return;
 
                if(hud_configure_prev)
-                       reset_centerprint_messages();
+                       centerprint_KillAll();
        }
        else
        {
                if(!hud_configure_prev)
                {
-                       reset_centerprint_messages();
+                       centerprint_KillAll();
                        hud_configure_cp_generation_time = time; // show a message immediately
                }
                if (time > 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();
        }
 }
index 1bec93efa644c684b35340f4973280742b259925..92339139f0dc963af19cb488cd87c67441e67f53 100644 (file)
@@ -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();
index d6a073a5de91d4798917c424c2f37cc8b3fd70eb..55868e5c79d29b6a692b91a78402682a9b16bae8 100644 (file)
@@ -11,6 +11,7 @@
 #include "commands/cl_cmd.qh"
 #include "mapvoting.qh"
 #include <client/mutators/_mod.qh>
+#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.
index 4dcecb1099ea34bb304ba47d0618d20fb08b5180..50fa49ae962f9576b09d00da780dd8ebb2cc19fe 100644 (file)
@@ -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;
index 663269c93558bac46a733f26d6c70a65e8921db7..371bbebee41e69f05ec092cd9a3cada76937013e 100644 (file)
@@ -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;
     }