diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 998adec4..fe713545 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -516,6 +516,7 @@ menuitemslider [Font type: ] 0 2 [findlist $__fontlist (curfont)] 1 [Default Ser menuitemslider [Mini-map background style: ] 0 2 "$showmapbackdrop" 1 ["Fully Transparent" Black White/Transparent] [ showmapbackdrop $arg1 ] menuitemslider [Menu map file sort order: ] 0 (- (listlen (listoptions menufilesortorders)) 1) "$menufilesort_cgz" 1 (listoptions menufilesortorders) [menufilesort_cgz = $arg1] menuitemslider [Menu demo file sort order: ] 0 (- (listlen (listoptions menufilesortorders)) 1) "$menufilesort_dmo" 1 (listoptions menufilesortorders) [menufilesort_dmo = $arg1] +menuitem [Edit hook script --> ] [ showmenu "Edit cubescript hook" ] // Reduced game violence mode... alias poniesmodeon 0 @@ -786,6 +787,28 @@ menuinit [ pop serverlist words ] +newmenu "Edit cubescript hook" +menuinit [ + resetcurmenu + looplist [ + autoexec "after autoexec.cfg" + afterinit "after saved.cfg but before autoexec.cfg" + mapstartalways "when a map was loaded" + onLastMin "when the last minute of a game has started" + start_intermission "when a game ended" + onNewMap "when a new (empty) map was created" + onPM "when you got a private message" + onConnect "after a player connected" + onDisconnect "after a player disconnected" + onCallVote "when a vote was called" + onVoteEnd "after voting ended" + onChangeVote "when a vote is changed" + ] [ cmd desc ] [ + menuitem (concatword "\fs\f2" $cmd ":\fr gets executed " $desc) (concat editalias $cmd) "" (if (checkalias $cmd) [ concatword "\fs\f4current: \fr" $$cmd ]) + ] +] + + newmenu "Configure package server" menuinit [ resetcurmenu diff --git a/config/scripts.cfg b/config/scripts.cfg index cd8dfcc9..0d1e4ed3 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -59,6 +59,7 @@ const gibsgore [ const fullscreentoggle [ fullscreen (! $fullscreen) ] const editsvar [ inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " (at $q 0) ; pop q") (concatword "edit " $arg1 :) ] const editmapmsg [ editsvar mapmsg ] +const editalias [ if (checkalias $arg1) 0 [ alias $arg1 "" ] ; inputcommand $$arg1 (concatword "push q (addpunct $cmdbuf) ; " $arg1 " = (at $q 0) ; pop q") (concatword "edit " $arg1 :) ] const return [ result $arg1 ] const run [ push n (concatword "exec config/" $arg1 ".cfg ") ; loop i (- $numargs 1) [ n = (concat $n (getalias (concatword "arg" (+ $i 2)))) ] ; n ; pop n] const closecurmenu [ closemenu (curmenu) ] diff --git a/source/src/command.cpp b/source/src/command.cpp index c63ca1a8..0d7a270a 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -734,7 +734,9 @@ bool exechook(int context, const char *ident, const char *body,...) // execute { defvformatstring(arglist, body, body); defformatstring(execbody)("%s%c%s", ident, *arglist ? ' ' : '\0', arglist); + setcontext("hook", execbody); execute(execbody); + resetcontext(); return true; } return false; diff --git a/source/src/main.cpp b/source/src/main.cpp index 188a223f..4b8f4dcc 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -1225,6 +1225,7 @@ int main(int argc, char **argv) exechook(HOOK_SP_MP, "afterinit", ""); autostartscripts(""); // all remaining scripts execfile("config/autoexec.cfg"); + exechook(HOOK_SP_MP, "autoexec", ""); execute("addallfavcatmenus"); // exec here, to add all categories (including those defined in autoexec.cfg) initing = NOT_INITING; uniformtexres = !hirestextures;