]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications.qh
Fix watermark coloring
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications.qh
index 9aa7e88fa7af788f591649340d15e3edf3ce70a6..a2ac1b95f74a05e10a2ec3039dddf660c82f719b 100644 (file)
@@ -86,8 +86,12 @@ string got_commandkey;
 #define WEAPON_NAME f1 // weaponorder[f1].netname
 #endif
 
-#define ADD_AUTOCVAR(name) var float autocvar_notification_##name = TRUE;
-#define CHECK_AUTOCVAR(name) if(autocvar_notification_##name)
+#define NOTIF_SWITCH_LIST(net_type,net_name,returnv) \
+       switch(net_name) \
+       { \
+               ##net_type##_NOTIFICATIONS \
+               default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = ##net_type##, net_name = ", ftos(net_name), ".\n")); returnv; } \
+       }
 
 string Get_Field_Value(float field, float net_type, float net_name); // get the actual name of a notification and return it as a string
 void Local_Notification(float net_type, float net_name, ...count);
@@ -125,7 +129,7 @@ void Read_Notification(float is_new);
 .string nent_strings[4];
 .float nent_floats[4];
 
-#define IFSTR(num) ((num <= (stringcount-1)) ? ...(num, string) : NO_STR_ARG)
+#define IFSTR(num) ((num < stringcount) ? ...(num, string) : NO_STR_ARG)
 #define IFFL(num) ((((stringcount-1) + num) < count) ? ...(((stringcount-1) + num), float) : NO_FL_ARG)
 
 void Send_Notification(float broadcast, entity client, float net_type, float net_name, ...count);
@@ -177,8 +181,8 @@ void Dump_Notifications(float fh, float alsoprint);
  users to create unique color profiles for their HUD, giving more customization
  options to HUD designers and end users who want such a feature.
 
- Check out the function calls for string CCR(...) and
- string TCR(...) to better understand how these codes work.
+ Check out the definitions in util.qc/util.qh/teams.qh for string CCR(...) and
+ string TCR(...) to better understand how these code replacements work.
 
  Guidlines for notification declaration (please try and follow these):
   Specific rules:
@@ -309,7 +313,7 @@ void Dump_Notifications(float fh, float alsoprint);
        MSG_INFO_NOTIF(INFO_VERSION_BETA,                                       2, 0, XPD(s1, s2), XPD("", ""),                                         "",                                             _("\{1}^F4NOTE: ^BGThe server is running ^F1Xonotic %s (beta)^BG, you have ^F2Xonotic %s\n"), "") \
        MSG_INFO_NOTIF(INFO_VERSION_OLD,                                        2, 0, XPD(s1, s2), XPD("", ""),                                         "",                                             _("\{1}^F4NOTE: ^BGThe server is running ^F1Xonotic %s^BG, you have ^F2Xonotic %s\n"), "") \
        MSG_INFO_NOTIF(INFO_VERSION_OUTDATED,                           2, 0, XPD(s1, s2), XPD("", ""),                                         "",                                             _("\{1}^F4NOTE: ^F1Xonotic %s^BG is out, and you still have ^F2Xonotic %s^BG - get the update from ^F3http://www.xonotic.org/^BG!\n"), "") \
-       MSG_INFO_NOTIF(INFO_WATERMARK,                                          1, 0, s1, XPD("", ""),                                                          "",                                             _("^F4SVQC Build information: ^BG%s\n"), "") \
+       MSG_INFO_NOTIF(INFO_WATERMARK,                                          1, 0, s1, XPD("", ""),                                                          "",                                             _("^F3SVQC Build information: ^F4%s\n"), "") \
        MSG_INFO_NOTIF(INFO_WEAPON_THINKING_WITH_PORTALS,                       1, 1, XPD(s1, SPREE_LOST), XPD(s1, ""),         "notify_selfkill", _("^BG%s^K1 is now thinking with portals%s\n"), "") \
        MSG_INFO_NOTIF(INFO_WEAPON_CRYLINK_SUICIDE,                             1, 1, XPD(s1, SPREE_LOST), XPD(s1, ""),         "weaponcrylink", _("^BG%s^K1 felt the strong pull of their Crylink%s\n"), "") \
        MSG_INFO_NOTIF(INFO_WEAPON_CRYLINK_MURDER,                                      2, 1, XPD(s1, s2, SPREE_END), XPD(s2, s1),      "weaponcrylink", _("^BG%s^K1 felt the strong pull of ^BG%s^K1's Crylink%s\n"), "") \
@@ -571,9 +575,14 @@ void Dump_Notifications(float fh, float alsoprint);
 //  Initialization/Create Declarations
 // ====================================
 
+#ifndef MENUQC // Menu doesn't need init
+
 #define NOTIF_FIRST 1
 #define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION
 
+#define ADD_AUTOCVAR(name) var float autocvar_notification_##name = TRUE;
+#define CHECK_AUTOCVAR(name) if(autocvar_notification_##name)
+
 #define CHECK_NOTIFICATION_1(net_type,net_name,check_newline,normal,gentle) \
        if((normal == "") || ((normal == "") && (gentle == ""))) { print(strcat("^1EMPTY NOTIFICATION: ^7net_type = ", net_type, ", net_name = ", VAR_TO_TEXT(net_name), ".\n")); } \
        #if check_newline \
@@ -598,9 +607,7 @@ float NOTIF_DEATH_COUNT;
 float NOTIF_CPID_COUNT;
 
 #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) \
-       #ifndef MENUQC \
-               ADD_AUTOCVAR(name) \
-       #endif \
+       ADD_AUTOCVAR(name) \
        float name; \
        void RegisterNotification_##name() \
        { \
@@ -611,9 +618,7 @@ float NOTIF_CPID_COUNT;
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_CENTER_NOTIF(name,strnum,flnum,args,cpid,durcnt,normal,gentle) \
-       #ifndef MENUQC \
-               ADD_AUTOCVAR(name) \
-       #endif \
+       ADD_AUTOCVAR(name) \
        float name; \
        float cpid; \
        void RegisterNotification_##name() \
@@ -626,9 +631,7 @@ float NOTIF_CPID_COUNT;
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_WEAPON_NOTIF(name,infoname,centername) \
-       #ifndef MENUQC \
-               ADD_AUTOCVAR(name) \
-       #endif \
+       ADD_AUTOCVAR(name) \
        float name; \
        void RegisterNotification_##name() \
        { \
@@ -639,9 +642,7 @@ float NOTIF_CPID_COUNT;
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
 #define MSG_DEATH_NOTIF(name,infoname,centername) \
-       #ifndef MENUQC \
-               ADD_AUTOCVAR(name) \
-       #endif \
+       ADD_AUTOCVAR(name) \
        float name; \
        void RegisterNotification_##name() \
        { \
@@ -660,3 +661,7 @@ MSG_DEATH_NOTIFICATIONS
 #undef MSG_CENTER_NOTIF
 #undef MSG_WEAPON_NOTIF
 #undef MSG_DEATH_NOTIF
+
+#undef ADD_AUTOCVAR
+
+#endif // ifndef MENUQC