X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnotifications%2Fall.qh;h=4bd827a6e8fe8f80f8ff6d2ef8142af8ba1964e4;hb=238d04f302418c0b644c68d45e64eb05b3583f09;hp=7dcfec3534549fa9462be965e25abe06795d6f04;hpb=3220cab5a7b69ced4a641504a6a5f4eccf2d3bfc;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 7dcfec353..4bd827a6e 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -1,7 +1,6 @@ -#ifndef NOTIFICATIONS_H -#define NOTIFICATIONS_H +#pragma once -#include +#include #include #include @@ -33,7 +32,7 @@ string Get_Notif_TypeName(MSG net_type) case MSG_MULTI: return "MSG_MULTI"; case MSG_CHOICE: return "MSG_CHOICE"; } - LOG_WARNINGF("Get_Notif_TypeName(%d): Improper net type!\n", ORDINAL(net_type)); + LOG_WARNF("Get_Notif_TypeName(%d): Improper net type!", ORDINAL(net_type)); return ""; } @@ -66,6 +65,7 @@ ENUMCLASS(CPID) CASE(CPID, RACE_FINISHLAP) CASE(CPID, TEAMCHANGE) CASE(CPID, TIMEOUT) + CASE(CPID, TIMEIN) CASE(CPID, VEHICLES) CASE(CPID, VEHICLES_OTHER) /** always last */ @@ -76,8 +76,7 @@ USING(Notification, entity); // used for notification system multi-team identifiers #define APP_TEAM_NUM(num, prefix) ((num == NUM_TEAM_1) ? prefix##_RED : ((num == NUM_TEAM_2) ? prefix##_BLUE : ((num == NUM_TEAM_3) ? prefix##_YELLOW : prefix##_PINK))) -/** @deprecated use APP_TEAM_NUM */ -#define APP_TEAM_ENT(ent, prefix) APP_TEAM_NUM(ent.team, prefix) +#define APP_NUM(num, prefix) ((num) ? APP_TEAM_NUM(num, prefix) : prefix##_NEUTRAL) #define EIGHT_VARS_TO_VARARGS_VARLIST \ VARITEM(1, 0, s1) \ @@ -110,7 +109,8 @@ void Create_Notification_Entity(entity notif, float var_default, float var_cvar, MSG typeId, - string namestring); + string namestring, + int teamnum); void Create_Notification_Entity_Annce(entity notif, float var_cvar, string namestring, @@ -160,7 +160,7 @@ GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt" { case CMD_REQUEST_COMMAND: { - #ifndef MENUQC + #ifdef GAMEQC string filename = argv(1); bool alsoprint = false; if (filename == "") @@ -201,8 +201,8 @@ GENERIC_COMMAND(dumpnotifs, "Dump all notifications into notifications_dump.txt" } } -float autocvar_notification_debug = false; #ifdef NOTIFICATIONS_DEBUG +bool autocvar_notification_debug = false; void Debug_Notification(string input) { switch (autocvar_notification_debug) @@ -226,6 +226,11 @@ string prev_soundfile; float prev_soundtime; #endif +#ifdef SVQC +IntrusiveList g_notifications; +STATIC_INIT(g_notifications) { g_notifications = IL_NEW(); } +#endif + #ifdef SVQC ENUMCLASS(NOTIF) /** send to one client and their spectators */ @@ -253,7 +258,7 @@ string Get_Notif_BroadcastName(NOTIF broadcast) case NOTIF_TEAM: return "NOTIF_TEAM"; case NOTIF_TEAM_EXCEPT: return "NOTIF_TEAM_EXCEPT"; } - LOG_WARNINGF("Get_Notif_BroadcastName(%d): Improper broadcast!\n", broadcast); + LOG_WARNF("Get_Notif_BroadcastName(%d): Improper broadcast!", broadcast); return ""; } @@ -293,8 +298,10 @@ float autocvar_notification_show_sprees_info = 3; // 0 = off, 1 = target only, 2 float autocvar_notification_show_sprees_info_newline = true; float autocvar_notification_show_sprees_info_specialonly = true; float autocvar_notification_errors_are_fatal = true; +#ifdef SVQC float autocvar_notification_lifetime_runtime = 0.5; float autocvar_notification_lifetime_mapload = 10; +#endif #ifdef SVQC .float FRAG_VERBOSE; @@ -349,6 +356,7 @@ float autocvar_notification_show_sprees_center_specialonly = true; race_diff: show time difference between f2 and f3 missing_teams: show which teams still need players pass_key: find the keybind for "passing" or "dropping" in CTF game mode + nade_key: find the keybind for nade throwing frag_ping: show the ping of a player frag_stats: show health/armor/ping of a player frag_pos: show score status and position in the match of a player @@ -401,14 +409,15 @@ string BUFF_NAME(int i); ARG_CASE(ARG_CS, "f1secs", count_seconds(f1)) \ ARG_CASE(ARG_CS, "f1points", (f1 == 1 ? _("point") : _("points"))) \ ARG_CASE(ARG_CS_SV, "f1ord", count_ordinal(f1)) \ - ARG_CASE(ARG_CS, "f1time", process_time(2, f1)) \ + ARG_CASE(ARG_CS_SV, "f1time", process_time(2, f1)) \ ARG_CASE(ARG_CS_SV_HA, "f1race_time", mmssss(f1)) \ ARG_CASE(ARG_CS_SV_HA, "f2race_time", mmssss(f2)) \ ARG_CASE(ARG_CS_SV_HA, "f3race_time", mmssss(f3)) \ ARG_CASE(ARG_CS_SV, "race_col", CCR(((f1 == 1) ? "^F1" : "^F2"))) \ ARG_CASE(ARG_CS_SV, "race_diff", ((f2 > f3) ? sprintf(CCR("^1[+%s]"), mmssss(f2 - f3)) : sprintf(CCR("^2[-%s]"), mmssss(f3 - f2)))) \ ARG_CASE(ARG_CS, "missing_teams", notif_arg_missing_teams(f1)) \ - ARG_CASE(ARG_CS, "pass_key", ((((tmp_s = getcommandkey("pass", "+use")) != "pass") && !(strstrofs(tmp_s, "not bound", 0) >= 0)) ? sprintf(CCR(_(" ^F1(Press %s)")), tmp_s) : "")) \ + ARG_CASE(ARG_CS, "pass_key", getcommandkey(_("drop flag"), "+use")) \ + ARG_CASE(ARG_CS, "nade_key", getcommandkey(_("throw nade"), "dropweapon")) \ ARG_CASE(ARG_CS, "frag_ping", notif_arg_frag_ping(true, f2)) \ ARG_CASE(ARG_CS, "frag_stats", notif_arg_frag_stats(f2, f3, f4)) \ /*ARG_CASE(ARG_CS, "frag_pos", ((Should_Print_Score_Pos(f1)) ? sprintf("\n^BG%s", Read_Score_Pos(f1)) : ""))*/ \ @@ -461,11 +470,11 @@ string notif_arg_frag_stats(float fhealth, float farmor, float fping) string notif_arg_missing_teams(float f1) { - return sprintf("%s%s%s%s", - ((f1 & BIT(0)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_1), (f1 & (BIT(1) | BIT(2) | BIT(3)) ? ", " : "")) : ""), - ((f1 & BIT(1)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_2), (f1 & ( BIT(2) | BIT(3)) ? ", " : "")) : ""), - ((f1 & BIT(2)) ? sprintf("%s%s", Team_ColoredFullName(NUM_TEAM_3), (f1 & ( BIT(3)) ? ", " : "")) : ""), - ((f1 & BIT(3)) ? Team_ColoredFullName(NUM_TEAM_4) : "") + return strcat( + ((f1 & BIT(0)) ? strcat(Team_ColoredFullName(NUM_TEAM_1), (f1 >> 1) ? ", " : "") : ""), + ((f1 & BIT(1)) ? strcat(Team_ColoredFullName(NUM_TEAM_2), (f1 >> 2) ? ", " : "") : ""), + ((f1 & BIT(2)) ? strcat(Team_ColoredFullName(NUM_TEAM_3), (f1 >> 3) ? ", " : "") : ""), + ((f1 & BIT(3)) ? Team_ColoredFullName(NUM_TEAM_4) : "") ); } @@ -622,6 +631,7 @@ string notif_arg_spree_inf(float type, string input, string player, float spree) .string nent_name; .int nent_stringcount; .int nent_floatcount; +.int nent_teamnum; // MSG_ANNCE entity values .int nent_channel; @@ -681,11 +691,18 @@ STATIC_INIT_LATE(Notif_Choices) { } } +string Get_Notif_CvarName(Notification notif) +{ + if(!notif.nent_teamnum) + return notif.nent_name; + return substring(notif.nent_name, 0, -strlen(Static_Team_ColorName(notif.nent_teamnum)) - 2); +} + Notification Get_Notif_Ent(MSG net_type, int net_name) { Notification it = _Notifications_from(net_name, NULL); if (it.nent_type != net_type) { - LOG_WARNINGF("Get_Notif_Ent(%s (%d), %s (%d)): Improper net type '%s'!\n", + LOG_WARNF("Get_Notif_Ent(%s (%d), %s (%d)): Improper net type '%s'!", Get_Notif_TypeName(net_type), net_type, it.registered_id, net_name, Get_Notif_TypeName(it.nent_type) @@ -695,26 +712,34 @@ Notification Get_Notif_Ent(MSG net_type, int net_name) return it; } +#define MSG_ANNCE_NOTIF_TEAM(teamnum, name, cvarname, default, sound, channel, volume, position) \ + MSG_ANNCE_NOTIF_(teamnum, ANNCE_##name, ANNCE_##cvarname, default, sound, channel, volume, position) + #define MSG_ANNCE_NOTIF(name, default, sound, channel, volume, position) \ - MSG_ANNCE_NOTIF_(ANNCE_##name, default, sound, channel, volume, position) -#define MSG_ANNCE_NOTIF_(name, default, sound, channel, volume, position) \ - NOTIF_ADD_AUTOCVAR(name, default) \ + NOTIF_ADD_AUTOCVAR(ANNCE_##name, default) \ + MSG_ANNCE_NOTIF_(0, ANNCE_##name, ANNCE_##name, default, sound, channel, volume, position) + +#define MSG_ANNCE_NOTIF_(teamnum, name, cvarname, default, sound, channel, volume, position) \ REGISTER(Notifications, name, m_id, new_pure(msg_annce_notification)) { \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_ANNCE, strtoupper(#name)); \ - Create_Notification_Entity_Annce(this, ACVNN(name), strtoupper(#name), \ + Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_ANNCE, strtoupper(#name), teamnum); \ + Create_Notification_Entity_Annce(this, ACVNN(cvarname), strtoupper(#name), \ channel, /* channel */ \ sound, /* snd */ \ volume, /* vol */ \ position); /* position */ \ } +#define MSG_INFO_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ + MSG_INFO_NOTIF_(teamnum, INFO_##name, INFO_##cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) + #define MSG_INFO_NOTIF(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ - MSG_INFO_NOTIF_(INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle) -#define MSG_INFO_NOTIF_(name, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ - NOTIF_ADD_AUTOCVAR(name, default) \ + NOTIF_ADD_AUTOCVAR(INFO_##name, default) \ + MSG_INFO_NOTIF_(0, INFO_##name, INFO_##name, default, strnum, flnum, args, hudargs, icon, normal, gentle) + +#define MSG_INFO_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, hudargs, icon, normal, gentle) \ REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name)); \ - Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ + Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_INFO, strtoupper(#name), teamnum); \ + Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \ args, /* args */ \ hudargs, /* hudargs */ \ icon, /* icon */ \ @@ -730,7 +755,7 @@ Notification Get_Notif_Ent(MSG net_type, int net_name) #define MULTIICON_INFO_(name, default, strnum, flnum, args, hudargs, iconargs, icon, normal, gentle) \ NOTIF_ADD_AUTOCVAR(name, default) \ REGISTER(Notifications, name, m_id, new_pure(msg_info_notification)) { \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name)); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_INFO, strtoupper(#name), 0); \ Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ args, /* args */ \ hudargs, /* hudargs */ \ @@ -742,13 +767,17 @@ Notification Get_Notif_Ent(MSG net_type, int net_name) this.nent_iconargs = iconargs; \ } +#define MSG_CENTER_NOTIF_TEAM(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ + MSG_CENTER_NOTIF_(teamnum, CENTER_##name, CENTER_##cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) + #define MSG_CENTER_NOTIF(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ - MSG_CENTER_NOTIF_(CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) -#define MSG_CENTER_NOTIF_(name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ - NOTIF_ADD_AUTOCVAR(name, default) \ + NOTIF_ADD_AUTOCVAR(CENTER_##name, default) \ + MSG_CENTER_NOTIF_(0, CENTER_##name, CENTER_##name, default, strnum, flnum, args, cpid, durcnt, normal, gentle) + +#define MSG_CENTER_NOTIF_(teamnum, name, cvarname, default, strnum, flnum, args, cpid, durcnt, normal, gentle) \ REGISTER(Notifications, name, m_id, new_pure(msg_center_notification)) { \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_CENTER, strtoupper(#name)); \ - Create_Notification_Entity_InfoCenter(this, ACVNN(name), strtoupper(#name), strnum, flnum, \ + Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CENTER, strtoupper(#name), teamnum); \ + Create_Notification_Entity_InfoCenter(this, ACVNN(cvarname), strtoupper(#name), strnum, flnum, \ args, /* args */ \ "", /* hudargs */ \ "", /* icon */ \ @@ -761,24 +790,28 @@ Notification Get_Notif_Ent(MSG net_type, int net_name) #define MSG_MULTI_NOTIF(name, default, anncename, infoname, centername) \ NOTIF_ADD_AUTOCVAR(name, default) \ REGISTER(Notifications, name, m_id, new_pure(msg_multi_notification)) { \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name)); \ + Create_Notification_Entity (this, default, ACVNN(name), MSG_MULTI, strtoupper(#name), 0); \ Create_Notification_Entity_Multi(this, ACVNN(name), strtoupper(#name), \ anncename, /* anncename */ \ infoname, /* infoname */ \ centername); /* centername */ \ } +#define MSG_CHOICE_NOTIF_TEAM(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \ + MSG_CHOICE_NOTIF_(teamnum, CHOICE_##name, CHOICE_##cvarname, default, challow, chtype, optiona, optionb) + #define MSG_CHOICE_NOTIF(name, default, challow, chtype, optiona, optionb) \ - MSG_CHOICE_NOTIF_(CHOICE_##name, default, challow, chtype, optiona, optionb) -#define MSG_CHOICE_NOTIF_(name, default, challow, chtype, optiona, optionb) \ - NOTIF_ADD_AUTOCVAR(name, default) \ - NOTIF_ADD_AUTOCVAR(name##_ALLOWED, challow) \ + NOTIF_ADD_AUTOCVAR(CHOICE_##name, default) \ + NOTIF_ADD_AUTOCVAR(CHOICE_##name##_ALLOWED, challow) \ + MSG_CHOICE_NOTIF_(0, CHOICE_##name, CHOICE_##name, default, challow, chtype, optiona, optionb) + +#define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \ REGISTER(Notifications, name, m_id, new_pure(msg_choice_notification)) { \ this.nent_choice_idx = nent_choice_count++; \ - Create_Notification_Entity (this, default, ACVNN(name), MSG_CHOICE, strtoupper(#name)); \ - Create_Notification_Entity_Choice(this, ACVNN(name), strtoupper(#name), \ + Create_Notification_Entity (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), teamnum); \ + Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \ challow, /* challow_def */ \ - autocvar_notification_##name##_ALLOWED, /* challow_var */ \ + autocvar_notification_##cvarname##_ALLOWED, /* challow_var */ \ chtype, /* chtype */ \ optiona, /* optiona */ \ optionb); /* optionb */ \ @@ -800,5 +833,3 @@ REGISTRY_END(Notifications) } #include "all.inc" - -#endif