Commit fa4d71af authored by Mario's avatar Mario

Merge branch 'terencehill/notification_cvars' into 'master'

Reduce number of notification cvars

See merge request !403
parents 93774bce 6b680671
Pipeline #5756106 passed with stages
in 18 minutes and 21 seconds
This diff is collapsed.
......@@ -553,7 +553,7 @@ void ons_ControlPoint_Icon_BuildThink(entity this)
if(IS_PLAYER(this.owner.ons_toucher))
{
Send_Notification(NOTIF_ALL, NULL, MSG_INFO, INFO_ONSLAUGHT_CAPTURE, this.owner.ons_toucher.netname, this.owner.message);
Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE), this.owner.message);
Send_Notification(NOTIF_ALL_EXCEPT, this.owner.ons_toucher, MSG_CENTER, APP_TEAM_NUM(this.owner.ons_toucher.team, CENTER_ONS_CAPTURE_TEAM), this.owner.message);
Send_Notification(NOTIF_ONE, this.owner.ons_toucher, MSG_CENTER, CENTER_ONS_CAPTURE, this.owner.message);
PlayerScore_Add(this.owner.ons_toucher, SP_ONS_CAPS, 1);
PlayerTeamScore_AddScore(this.owner.ons_toucher, 10);
......
This diff is collapsed.
......@@ -398,7 +398,8 @@ void Create_Notification_Entity(entity notif,
float var_default,
float var_cvar,
MSG typeId,
string namestring)
string namestring,
int teamnum)
{
// =====================
// Global Entity Setup
......@@ -407,6 +408,7 @@ void Create_Notification_Entity(entity notif,
notif.nent_enabled = (var_cvar >= 1);
notif.nent_type = typeId;
notif.nent_name = strzone(namestring);
notif.nent_teamnum = teamnum;
// Other pre-notif-setup requisites
notif_error = false;
......@@ -761,13 +763,13 @@ void Create_Notification_Entity_Choice(entity notif,
#ifdef SVQC
void Notification_GetCvars(entity this)
{
FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
GetCvars_handleFloat(
this,
get_cvars_s,
get_cvars_f,
msg_choice_choices[it.nent_choice_idx],
sprintf("notification_%s", it.nent_name)
sprintf("notification_%s", Get_Notif_CvarName(it))
);
});
}
......@@ -784,7 +786,7 @@ void Dump_Notifications(int fh, bool alsoprint)
#define NOTIF_WRITE_ENTITY(e, description) MACRO_BEGIN { \
string notif_msg = sprintf( \
"seta notification_%s \"%d\" \"%s\"\n", \
e.nent_name, e.nent_default, description \
Get_Notif_CvarName(e), e.nent_default, description \
); \
NOTIF_WRITE(notif_msg); \
} MACRO_END
......@@ -793,8 +795,8 @@ void Dump_Notifications(int fh, bool alsoprint)
string notif_msg = sprintf( \
"seta notification_%s \"%d\" \"%s\"\n" \
"seta notification_%s_ALLOWED \"%d\" \"%s\"\n", \
e.nent_name, e.nent_default, descriptiona, \
e.nent_name, e.nent_challow_def, descriptionb \
Get_Notif_CvarName(e), e.nent_default, descriptiona, \
Get_Notif_CvarName(e), e.nent_challow_def, descriptionb \
); \
NOTIF_WRITE(notif_msg); \
} MACRO_END
......@@ -831,7 +833,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_ANNCE_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_ANNCE, { ++NOTIF_ANNCE_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
FOREACH(Notifications, it.nent_type == MSG_ANNCE, {
FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
);
......@@ -839,7 +841,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_INFO_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_INFO, { ++NOTIF_INFO_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
FOREACH(Notifications, it.nent_type == MSG_INFO, {
FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = print to console, "
"2 = print to console and chatbox (if notification_allow_chatboxprint is enabled)"
......@@ -848,7 +850,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_CENTER_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_CENTER, { ++NOTIF_CENTER_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
FOREACH(Notifications, it.nent_type == MSG_CENTER, {
FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"0 = off, 1 = centerprint"
);
......@@ -856,7 +858,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_MULTI_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_MULTI, { ++NOTIF_MULTI_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
FOREACH(Notifications, it.nent_type == MSG_MULTI, {
FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY(it,
"Enable this multiple notification"
);
......@@ -864,7 +866,7 @@ void Dump_Notifications(int fh, bool alsoprint)
int NOTIF_CHOICE_COUNT = 0; FOREACH(Notifications, it.nent_type == MSG_CHOICE, { ++NOTIF_CHOICE_COUNT; });
NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
NOTIF_WRITE_ENTITY_CHOICE(it,
"Choice for this notification 0 = off, 1 = default message, 2 = verbose message",
"Allow choice for this notification 0 = off, 1 = only in warmup mode, 2 = always"
......@@ -876,7 +878,7 @@ void Dump_Notifications(int fh, bool alsoprint)
NOTIF_WRITE_HARDCODED(
"allow_chatboxprint", "1",
"Allow INFO notifications to be printed to chat box"
"Allow INFO notifications to be printed to chat box "
"0 = do not allow, "
"1 = allow only if allowed by individual notification_INFO* cvars, "
"2 = force all INFO notifications to be printed to the chatbox"
......@@ -1367,7 +1369,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
{
entity found_choice = notif.nent_optiona;
if (notif.nent_challow_var && (warmup_stage || (notif.nent_challow_var == 2))) {
switch (cvar(sprintf("notification_%s", notif.nent_name)))
switch (cvar(sprintf("notification_%s", Get_Notif_CvarName(notif))))
{
case 1: break;
case 2: found_choice = notif.nent_optionb; break;
......
......@@ -109,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,
......@@ -630,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;
......@@ -689,6 +691,13 @@ 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);
......@@ -703,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 */ \
......@@ -738,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 */ \
......@@ -750,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 */ \
......@@ -769,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 */ \
......
......@@ -64,8 +64,8 @@ void XonoticGameMessageSettingsTab_fill(entity me)
me.gotoRC(me, 9, 0); me.setFirstColumn(me, me.currentColumn);
me.TD(me, 1, 3, e = makeXonoticHeaderLabel(_("Gamemode Settings")));
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_CAPTURE_TIME_RED", _("Display capture times in Capture The Flag"), "-"));
makeMulti(e, "notification_CHOICE_CTF_CAPTURE_TIME_BLUE notification_CHOICE_CTF_CAPTURE_TIME_YELLOW notification_CHOICE_CTF_CAPTURE_TIME_PINK notification_CHOICE_CTF_CAPTURE_BROKEN_RED notification_CHOICE_CTF_CAPTURE_BROKEN_BLUE notification_CHOICE_CTF_CAPTURE_BROKEN_YELLOW notification_CHOICE_CTF_CAPTURE_BROKEN_PINK notification_CHOICE_CTF_CAPTURE_UNBROKEN_RED notification_CHOICE_CTF_CAPTURE_UNBROKEN_BLUE notification_CHOICE_CTF_CAPTURE_UNBROKEN_YELLOW notification_CHOICE_CTF_CAPTURE_UNBROKEN_PINK");
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_CAPTURE_TIME", _("Display capture times in Capture The Flag"), "-"));
makeMulti(e, "notification_CHOICE_CTF_CAPTURE_BROKEN notification_CHOICE_CTF_CAPTURE_UNBROKEN");
e.sendCvars = true;
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_CHOICE_CTF_PICKUP_ENEMY", _("Display name of flag stealer in Capture The Flag"), "-"));
......@@ -80,7 +80,7 @@ void XonoticGameMessageSettingsTab_fill(entity me)
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_allow_chatboxprint", _("Display all info messages in the chatbox"), "-"));
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBoxEx_T(2, 1, "notification_INFO_QUIT_DISCONNECT", _("Display player statuses in the chatbox"), "-"));
makeMulti(e, "notification_INFO_QUIT_KICK_IDLING notification_INFO_JOIN_CONNECT_TEAM_BLUE notification_INFO_JOIN_CONNECT_TEAM_PINK notification_INFO_JOIN_CONNECT_TEAM_RED notification_INFO_JOIN_CONNECT_TEAM_YELLOW");
makeMulti(e, "notification_INFO_QUIT_KICK_IDLING notification_INFO_JOIN_CONNECT_TEAM");
me.TR(me);
me.TR(me);
me.TD(me, 1, 3, e = makeXonoticCheckBox_T(0, "notification_CENTER_POWERUP_INVISIBILITY", _("Powerup notifications"), "-"));
......
......@@ -703,7 +703,7 @@ void ctf_Handle_Pickup(entity flag, entity player, int pickuptype)
else if(CTF_DIFFTEAM(player, flag))
Send_Notification(NOTIF_ONE, player, MSG_CENTER, APP_TEAM_NUM(flag.team, CENTER_CTF_PICKUP));
else
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_TEAM : CENTER_CTF_PICKUP_TEAM_ENEMY), Team_ColorCode(flag.team));
Send_Notification(NOTIF_ONE, player, MSG_CENTER, ((SAME_TEAM(player, flag)) ? CENTER_CTF_PICKUP_RETURN : CENTER_CTF_PICKUP_RETURN_ENEMY), Team_ColorCode(flag.team));
Send_Notification(NOTIF_TEAM_EXCEPT, player, MSG_CHOICE, APP_NUM(flag.team, CHOICE_CTF_PICKUP_TEAM), Team_ColorCode(player.team), player.netname);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment