From 99a9c2cd70d658113eb2bd335775c6d67985977a Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Fri, 5 Oct 2012 00:53:32 -0400 Subject: [PATCH] Add "dumpnotifs" command so you can automatically generate configs --- qcsrc/common/command/generic.qc | 35 +++++++++++++++++++++++++++++++++ qcsrc/common/notifications.qc | 33 +++++++++++++++++++++++++------ qcsrc/menu/progs.src | 2 ++ 3 files changed, 64 insertions(+), 6 deletions(-) diff --git a/qcsrc/common/command/generic.qc b/qcsrc/common/command/generic.qc index b7b8da0e9..29c0d420d 100644 --- a/qcsrc/common/command/generic.qc +++ b/qcsrc/common/command/generic.qc @@ -226,6 +226,40 @@ void GenericCommand_dumpcommands(float request) } } +void GenericCommand_dumpnotifs(float request) +{ + switch(request) + { + case CMD_REQUEST_COMMAND: + { + float fh; + string filename = "notifications_dump.txt"; + fh = fopen(filename, FILE_WRITE); + + if(fh >= 0) + { + fputs(fh, "dump of notifications list:\n"); + Dump_Notifications(fh); + print("Completed dump of notifications in ^2data/data/notifications_dump.txt^7.\n"); + fclose(fh); + } + else + { + print("^1Error: ^7Could not dump to file!\n"); + } + return; + } + + default: + case CMD_REQUEST_USAGE: + { + print(strcat("\nUsage:^3 ", GetProgramCommandPrefix(), " dumpnotifs")); + print(" No arguments required.\n"); + return; + } + } +} + void GenericCommand_maplist(float request, float argc) { switch(request) @@ -463,6 +497,7 @@ void GenericCommand_(float request) GENERIC_COMMAND("addtolist", GenericCommand_addtolist(request, arguments), "Add a string to a cvar") \ GENERIC_COMMAND("curl", GenericCommand_curl(request, arguments), "Queries an URL") \ GENERIC_COMMAND("dumpcommands", GenericCommand_dumpcommands(request), "Dump all commands on the program to *_cmd_dump.txt") \ + GENERIC_COMMAND("dumpnotifs", GenericCommand_dumpnotifs(request), "Dump all notifications into notifications_dump.txt") \ GENERIC_COMMAND("maplist", GenericCommand_maplist(request, arguments), "Automatic control of maplist") \ GENERIC_COMMAND("nextframe", GenericCommand_nextframe(request, arguments, command), "Execute the given command next frame of this VM") \ GENERIC_COMMAND("removefromlist", GenericCommand_removefromlist(request, arguments), "Remove a string from a cvar") \ diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index b970907e5..0d75bef28 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -197,14 +197,18 @@ MSG_WEAPON_NOTIFICATIONS // select between the normal or the gentle message string based on client (or server) settings string normal_or_gentle(string normal, string gentle) { - #ifdef CSQC - if(autocvar_cl_gentle || autocvar_cl_gentle_messages) + #ifndef MENUQC + #ifdef CSQC + if(autocvar_cl_gentle || autocvar_cl_gentle_messages) + #else + if(autocvar_sv_gentle) + #endif + return ((gentle != "") ? gentle : normal); + else + return normal; #else - if(autocvar_sv_gentle) - #endif - return ((gentle != "") ? gentle : normal); - else return normal; + #endif } float notif_stringcount(string s1, string s2) @@ -284,6 +288,23 @@ string CCR(string input) } +// ============================= +// Debug/Maintenance Functions +// ============================= + +#define NOTIF_Write(type,name,text) fputs(fh, (sprintf("seta %s 1 // %s - %s\n", name, type, strreplace("\n", "\\n", text)))) +void Dump_Notifications(float fh) +{ + #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) { NOTIF_Write("MSG_INFO", VAR_TO_TEXT(name), normal); } + #define MSG_CENTER_NOTIF(name,strnum,flnum,args,cpid,durcnt,normal,gentle) { NOTIF_Write("MSG_CENTER", VAR_TO_TEXT(name), normal); } + #define MSG_WEAPON_NOTIF(name,strnum,flnum,args,normal,gentle) { NOTIF_Write("MSG_WEAPON", VAR_TO_TEXT(name), normal); } + MSG_INFO_NOTIFICATIONS + MSG_CENTER_NOTIFICATIONS + MSG_WEAPON_NOTIFICATIONS + return; +} + + // =============================== // Frontend Notification Pushing // =============================== diff --git a/qcsrc/menu/progs.src b/qcsrc/menu/progs.src index 0f545e60c..37bc4bea8 100644 --- a/qcsrc/menu/progs.src +++ b/qcsrc/menu/progs.src @@ -11,6 +11,8 @@ config.qh oo/base.h +../common/teams.qh +../common/notifications.qc ../common/constants.qh ../common/mapinfo.qh ../common/campaign_common.qh -- 2.39.2