From: Samual Lenks Date: Tue, 25 Sep 2012 18:20:30 +0000 (-0400) Subject: Working on a whole new system using ACCUMULATE_FUNCTION X-Git-Tag: xonotic-v0.7.0~62^2~23^2~426 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=9514c6bf21b0af01d47f95f03c37895cbfb85b91;p=xonotic%2Fxonotic-data.pk3dir.git Working on a whole new system using ACCUMULATE_FUNCTION --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 234dee49d..da4f4f5b9 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -8,13 +8,59 @@ #define MSG_WEAPON 4 // weapon messages (like "You got the Nex", sent to weapon notify panel) // collapse multiple arguments into one argument +#define CLPS4(arg1,arg2,arg3,arg4) arg1, arg2, arg3, arg4 #define CLPS3(arg1,arg2,arg3) arg1, arg2, arg3 #define CLPS2(arg1,arg2) arg1, arg2 +// accumulate functions for declarations +#define NOTIF_FIRST 1 +float NOTIF_INFO_COUNT; +float NOTIF_NOTIFY_COUNT; +float NOTIF_CENTER_COUNT; +float NOTIF_WEAPON_COUNT; +float NOTIF_CPID_COUNT; + +#define MSG_INFO_NOTIF(name,args,normal,gentle) \ + float name; \ + void DecNotif_##name() { \ + if(!name) { \ + name = (NOTIF_FIRST + NOTIF_INFO_COUNT); \ + ++NOTIF_INFO_COUNT; } } \ + ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) + +#define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \ + float name; \ + void DecNotif_##name() { \ + if(!name) { \ + name = (NOTIF_FIRST + NOTIF_NOTIFY_COUNT); \ + ++NOTIF_NOTIFY_COUNT; } } \ + ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) + +#define MSG_CENTER_NOTIF(name,args,cpid,normal,gentle) \ + float name; \ + float cpid; \ + void DecNotif_##name() { \ + if(!name) { \ + name = (NOTIF_FIRST + NOTIF_CENTER_COUNT); \ + ++NOTIF_CENTER_COUNT; } \ + if(!cpid) { \ + cpid = (NOTIF_FIRST + NOTIF_CPID_COUNT); \ + ++NOTIF_CPID_COUNT; } } \ + ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) + +#define MSG_WEAPON_NOTIF(name,args,normal,gentle) \ + float name; \ + void DecNotif_##name() { \ + if(!name) { \ + name = (NOTIF_FIRST + NOTIF_WEAPON_COUNT); \ + ++NOTIF_WEAPON_COUNT; } } \ + ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) + // =================== // Notification List // =================== + // List of all notifications (including identifiers and display information) // Format: name, number, args, special, normal, gentle // Specifications: @@ -24,53 +70,94 @@ // Special: // MSG_INFO: NULL/FLOAT: leave as FALSE // MSG_NOTIFY: STRING: icon string name for the hud notify panel, "" if no icon is used -// MSG_CENTER: FLOAT: centerprint ID number (CPID_*), FALSE if no CPID is needed +// MSG_CENTER: FLOAT: centerprint ID number (CPID_*), NO_CPID if no CPID is needed // MSG_WEAPON: NULL/FLOAT: leave as FALSE // Normal message (string for sprintf when gentle messages are NOT enabled) // Gentle message (string for sprintf when gentle messages ARE enabled) // -// Messages have ^FG1, ^FG2, and ^BG in them-- these are replaced +// Messages have ^F1, ^F2, and ^BG in them-- these are replaced // with colors according to the cvars the user has chosen. -// ^FG1 = highest priority, "primary" -// ^FG2 = next highest priority, "secondary" -// ^BG = less important information, "tertiary" +// ^F1 = highest priority, "primary" +// ^F2 = next highest priority, "secondary" +// ^BG = normal/less important priority, "tertiary" +// Guidlines: +// ALWAYS start the string with a color, preferably background +// ALWAYS end messages with a new line +// ARIRE unir frk jvgu lbhe bja zbgure (gvc sbe zvxrrhfn) #define MSG_INFO_NOTIFICATIONS \ - NOTIFICATION(DEATH_MARBLES_LOST, 1, CLPS3(s1, s2, s3), "notify_death", _("^FG1%s^BG lost their marbles against ^FG1%s^BG using the ^FG2%s^BG\n"), "") \ + MSG_INFO_NOTIF(DEATH_MARBLES_LOST, CLPS3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ /* nothing */ #define MSG_NOTIFY_NOTIFICATIONS \ - NOTIFICATION(DEATH_MARBLES_LOST2, 1, CLPS3(s1, s2, s3), "notify_death", _("^FG1%s^BG lost their marbles against ^FG1%s^BG using the ^FG2%s^BG\n"), "") \ + MSG_NOTIFY_NOTIF(DEATH_MARBLES_LOST2, CLPS3(s1, s2, s3), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ /* nothing */ #define MSG_CENTER_NOTIFICATIONS \ - NOTIFICATION(CENTER_CTF_CAPTURESHIELD_SHIELDED, 1, "", xCPID_CTF_CAPTURESHIELD, _("^BGYou are now ^FG1shielded^BG from the flag\n^BGfor ^FG2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \ - NOTIFICATION(CENTER_CTF_CAPTURESHIELD_FREE, 2, "", xCPID_CTF_CAPTURESHIELD, _("^BGYou are now free.\n^BGFeel free to ^FG2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \ - NOTIFICATION(CENTER_CTF_EVENT_RETURN, 11, s1, CPID_CTF_LOWPRIO, _("^BGYou returned the ^FG1%s"), "") \ - NOTIFICATION(CENTER_CTF_EVENT_CAPTURE, 11, s1, FALSE, _("^BGYou captured the ^FG1%s"), "") \ - NOTIFICATION(CENTER_CTF_EVENT_PASS, 10, CLPS2(s1, s2, s3), CPID_CTF_PASS, _("^BG%s passed the ^FG1%s^BG to %s"), "") \ - NOTIFICATION(CENTER_CTF_EVENT_PASS_SENT, 11, CLPS2(s1, s2), CPID_CTF_PASS, _("^BGYou passed the ^FG1%s^BG to %s"), "") \ - NOTIFICATION(CENTER_CTF_EVENT_PASS_RECEIVED, 12, CLPS2(s1, s2), CPID_CTF_PASS, _("^BGYou received the ^FG1%s^BG from %s"), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_SHIELDED, "", CPID_CTF_CAPTURESHIELD, _("^BGYou are now ^F1shielded^BG from the flag\n^BGfor ^F2too many unsuccessful attempts^BG to capture.\n^BGMake some defensive scores before trying again."), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_CAPTURESHIELD_FREE, "", CPID_CTF_CAPTURESHIELD, _("^BGYou are now free.\n^BGFeel free to ^F2try to capture^BG the flag again\n^BGif you think you will succeed."), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS, CLPS2(s1, s2, s3), CPID_CTF_PASS, _("^BG%s passed the ^F1%s^BG to %s"), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_SENT, CLPS2(s1, s2), CPID_CTF_PASS, _("^BGYou passed the ^F1%s^BG to %s"), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_EVENT_PASS_RECEIVED, CLPS2(s1, s2), CPID_CTF_PASS, _("^BGYou received the ^F1%s^BG from %s"), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_EVENT_RETURN, s1, CPID_CTF_LOWPRIO, _("^BGYou returned the ^F1%s"), "") \ + MSG_CENTER_NOTIF(CENTER_CTF_EVENT_CAPTURE, s1, NO_CPID, _("^BGYou captured the ^F1%s"), "") \ /* nothing */ #define MSG_WEAPON_NOTIFICATIONS \ - NOTIFICATION(DEATH_MARBLES_LOST3, 1, CLPS3(s1, s2, s3), "notify_death", _("^FG1%s^BG lost their marbles against ^FG1%s^BG using the ^FG2%s^BG\n"), "") \ + MSG_WEAPON_NOTIF(DEATH_MARBLES_LOST3, CLPS3(s1, s2, s3), _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ /* nothing */ -// declare notifications -#define NOTIFICATION(name,num,args,special,normal,gentle) float name = num; +// NOW we actually activate the declarations MSG_INFO_NOTIFICATIONS MSG_NOTIFY_NOTIFICATIONS MSG_CENTER_NOTIFICATIONS MSG_WEAPON_NOTIFICATIONS -#undef NOTIFICATION +// finally, since that's done... undeclare the handlers so that we can use the list in other ways. +#undef MSG_INFO_NOTIF +#undef MSG_NOTIFY_NOTIF +#undef MSG_CENTER_NOTIF +#undef MSG_WEAPON_NOTIF + +/* +#define MSG_WEAPON_NOTIFICATIONS \ + NOTIFICATION(DEATH_MARBLES_LOST3, 1, CLPS3(s1, s2, s3), "notify_death", _("^F1%s^BG lost their marbles against ^F1%s^BG using the ^F2%s^BG\n"), "") \ + /* nothing */ + +/*#define NOTIFICATION(name,num,args,special,normal,gentle) \ + #ifndef name \ + #define name num \ + #endif +MSG_INFO_NOTIFICATIONS +MSG_NOTIFY_NOTIFICATIONS +MSG_CENTER_NOTIFICATIONS +MSG_WEAPON_NOTIFICATIONS +#undef NOTIFICATION -#ifdef CSQC // declare centerprint priorities -#define NOTIFICATION(name,num,args,special,normal,gentle) float special = num; +#ifdef CSQC +#define NOTIFICATION(name,num,args,special,normal,gentle) \ + #ifndef special \ + #define special num \ + #endif MSG_CENTER_NOTIFICATIONS -#undef +#undef NOTIFICATION +#endif */ + + +string CCR(string input) // color code replace, place inside of sprintf and parse the string +{ + input = strreplace("^F1", "^3", input); + input = strreplace("^F2", "^2", input); + input = strreplace("^BG", "^7", input); + + input = strreplace("^N", "^7", input); // "none"-- reset to white + + return input; +} + + +#ifdef CSQC void readnotificationorwhatever() {