GUI Scripting: Parsing of Set 'Cmd': Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
(add)
 
No edit summary
(9 intermediate revisions by 6 users not shown)
Line 1: Line 1:
== GUI commands ==
== GUI commands ==


Commands in the main menu like:
Commands in the main menu GUI with "cmd" as first parameter


  set "command argument1 argument2;"
  set "cmd" "mycommand argument1 argument2;"


are handled in <tt>idGameLocal::HandleMainMenuCommands()</tt> in ''game/game_loca.cpp''.
are handled in <tt>idGameLocal::HandleMainMenuCommands()</tt> in ''game/game_local.cpp''.


For each of the parts "command", "argument1", "argument2" and the final ";" (even if this is ommitted!), the routine is called again. It therefore keeps a stack of these parts, and when it sees the final ";", handles the command and clears the stack before returning.
For each of the parts "mycommand", "argument1", "argument2" and sometimes the final ";", the routine is called again.  


Even if you just use
One special case is just using "set" "cmd" "mycommand", this will call <tt>HandleMainMenuCommands()</tt> twice, once with "mycommand" and once with ";" as the ''menuCommand'' parameter.


set command
Commands like "play" or "music" are special cases, too, only the first part ("play" or "music") is relayed to the routine, but the argument is not. Thus it seems impossible to recover what sound shader is to be played.


the routine will be called twice, once with "command" and once with ";" as the ''menuCommand'' parameter.
=== 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";  // will result in "play", and potentially ";"
set "cmd" "log 'Some text here';";          // will result in "log", "Some text here" and ";" - written to the console
set "cmd" "mainmenu_heartbeat";              // will result in "mainmenu_heartbeat" and ";"
set "cmd" "mainmenu_heartbeat;";            // will result in "mainmenu_heartbeat", ";" and ";"
 
Note: The "log" command only works on MainMenu guis, and only if the executable has been built with the cvar "tdm_debug_mainmenu" set to "1".


== See also ==
== See also ==


* [http://www.iddevnet.com/doom3/guis.php Introduction to Doom3 GUIs]
* [http://www.iddevnet.com/doom3/guis.php Introduction to Doom3 GUIs]
* [http://www.modwiki.net/wiki/GUI_scripting GUI Scripting] on modwiki
* [https://modwiki.dhewm3.org/GUI_scripting GUI Scripting] on modwiki
* [http://www.modwiki.net/wiki/Set_%28GUI_command%29 The "set" command] on modiwki
* [https://modwiki.dhewm3.org/Set_(GUI_command) The "set" command] on modiwki
 
[[Category:Editing]]

Revision as of 19:03, 27 June 2020

GUI commands

Commands in the main menu GUI with "cmd" as first parameter

set "cmd" "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" "cmd" "mycommand", this will call HandleMainMenuCommands() twice, once with "mycommand" and once with ";" as the menuCommand parameter.

Commands like "play" or "music" are special cases, too, only the first part ("play" or "music") is relayed to the routine, but the argument is not. Thus it seems impossible to recover what sound shader is to be played.

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";  // will result in "play", and potentially ";"
set "cmd" "log 'Some text here';";           // will result in "log", "Some text here" and ";" - written to the console
set "cmd" "mainmenu_heartbeat";              // will result in "mainmenu_heartbeat" and ";"
set "cmd" "mainmenu_heartbeat;";             // will result in "mainmenu_heartbeat", ";" and ";"

Note: The "log" command only works on MainMenu guis, and only if the executable has been built with the cvar "tdm_debug_mainmenu" set to "1".

See also