GUI Scripting: Parsing of Set 'Cmd': Difference between revisions
update |
tweak |
||
Line 3: | Line 3: | ||
Commands in the main menu like: | Commands in the main menu like: | ||
set " | set "mycommand argument1 argument2;" | ||
are handled in <tt>idGameLocal::HandleMainMenuCommands()</tt> in ''game/ | are handled in <tt>idGameLocal::HandleMainMenuCommands()</tt> in ''game/game_local.cpp''. | ||
For each of the parts " | For each of the parts "mycommand", "argument1", "argument2" and sometimes the final ";", the routine is called again. | ||
One special case is just using "set" "mycommand", this will call <tt>HandleMainMenuCommands()</tt> twice, once with "mycommand" and once with ";" as the ''menuCommand'' parameter. | |||
In addition, things like: | |||
set "noTime" "1" | |||
will call the routine three times, with "set", "noTime" "1" as menuCommand, respectively. | |||
=== Solution === | |||
The routine there fore predicts how much arguments the current command takes, accumulates them on a stack. And when it has seen enough arguments, handles the command and clears the stack before returning. | |||
Any stray ";" as command is silently skipped. | |||
The routine will also complain if you give not enough arguments to a command. | |||
=== Examples === | === Examples === | ||
Line 18: | Line 30: | ||
set "cmd" "log 'Some text here'"; | set "cmd" "log 'Some text here'"; | ||
set "cmd" "mainmenu_heartbeat"; | set "cmd" "mainmenu_heartbeat"; | ||
set "noTime" "1" | |||
== See also == | == See also == |
Revision as of 16:51, 2 September 2011
GUI commands
Commands in the main menu like:
set "mycommand argument1 argument2;"
are handled in idGameLocal::HandleMainMenuCommands() in game/game_local.cpp.
For each of the parts "mycommand", "argument1", "argument2" and sometimes the final ";", the routine is called again.
One special case is just using "set" "mycommand", this will call HandleMainMenuCommands() twice, once with "mycommand" and once with ";" as the menuCommand parameter.
In addition, things like:
set "noTime" "1"
will call the routine three times, with "set", "noTime" "1" as menuCommand, respectively.
Solution
The routine there fore predicts how much arguments the current command takes, accumulates them on a stack. And when it has seen enough arguments, handles the command and clears the stack before returning.
Any stray ";" as command is silently skipped.
The routine will also complain if you give not enough arguments to a command.
Examples
set "cmd" "play sound/meta/menu/mnu_hover"; set "cmd" "log 'Some text here'"; set "cmd" "mainmenu_heartbeat"; set "noTime" "1"
See also
- Introduction to Doom3 GUIs
- GUI Scripting on modwiki
- The "set" command on modiwki