]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add "dumpnotifs" command so you can automatically generate configs
authorSamual Lenks <samual@xonotic.org>
Fri, 5 Oct 2012 04:53:32 +0000 (00:53 -0400)
committerSamual Lenks <samual@xonotic.org>
Fri, 5 Oct 2012 04:53:32 +0000 (00:53 -0400)
qcsrc/common/command/generic.qc
qcsrc/common/notifications.qc
qcsrc/menu/progs.src

index b7b8da0e9f407f64da0bab06bc3dae90c7d4c528..29c0d420d46c37d86d9ba46ddf4b2a29d66107f5 100644 (file)
@@ -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") \
index b970907e5de86e8b967253f8e672c8bc73f1307d..0d75bef282e6691bada7968b1ae086935833d179 100644 (file)
@@ -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
 // ===============================
index 0f545e60cfa368967ca4cb6f694132fff6558fd1..37bc4bea81e08e7325afb0789cee53558dd11886 100644 (file)
@@ -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