Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changes between Initial Version and Version 1 of code/doc/ConsoleCommand


Ignore:
Timestamp:
Oct 1, 2008, 12:04:28 AM (16 years ago)
Author:
landauf
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • code/doc/ConsoleCommand

    v1 v1  
     1= ConsoleCommand =
     2[[TracNav(TracNav/TOC_Development)]]
     3
     4== Description ==
     5A !ConsoleCommand is a function which can be called by the [wiki:Shell]. !ConsoleCommand inherits from [wiki:Executor] and adds some additional features used to [wiki:KeyBinder bind commands to keys] and to allow easy use in the Shell ([wiki:ArgumentCompleter like argument completion]).
     6
     7At the moment, a !ConsoleCommand must call a '''static''' function. The command is of static nature too and exists for the whole time. But this will change in the future.
     8
     9A !ConsoleCommand can also be called directly from the code by using [wiki:CommandExecutor]. If you want to execute the same command over and over, see [wiki:CommandEvaluation] for more performance.
     10
     11== Usage ==
     12=== Creation ===
     13Creating a !ConsoleCommand is usually really easy. Just write the following lines:
     14
     15*.cc file:
     16{{{
     17#include "core/ConsoleCommand.h"
     18
     19SetConsoleCommand(ClassName, functionname, true);
     20}}}
     21Note: The last argument (true) means: create a shortcut for this command.
     22
     23*.h file:
     24{{{
     25class ClassName
     26{
     27    public:
     28        static returntype functionname(param1, param2, ...);
     29};
     30}}}
     31
     32=== Call ===
     33Now you can call the function by typing the ''functionname'' into the [wiki:Shell]:
     34{{{
     35> functionname arg1 arg2 ...
     36or
     37> ClassName functionname arg1 arg2 ...
     38}}}
     39
     40Note: The first variant works only if you enable the shortcut (''true'' in SetConsoleCommand).
     41
     42It's also possible to call the command directly from the code by using [wiki:CommandExecutor]:
     43{{{
     44CommandExecutor::execute("functionname arg1 arg2 ...");
     45or
     46CommandExecutor::execute("ClassName functionname arg1 arg2 ...");
     47}}}
     48
     49=== Attributes ===
     50There are several attributes you can set, some of them are inherited from [wiki:Executor], some are new.
     51
     52'''Inherited''':
     53 * '''description('''''description''''')''': Sets the description of the Executor (what the function does)
     54 * '''descriptionParam('''''param number (0-4)''''', '''''description''''')''': Sets the description of an argument (what the argument does)
     55 * '''descriptionReturnvalue('''''description''''')''': Sets the description of the return value (what the return value does)
     56
     57 * '''defaultValues('''''value1''''', '''...''')''': Sets default values
     58 * '''defaultValue('''''param number (0-4)''''', '''''value''''')''': Sets the default value for a given parameter
     59
     60'''New''':
     61 * '''accessLevel('''''level''''')''': Sets the access level (see [wiki:ConsoleCommand#AccessLevels the chapter below])
     62 * '''argumentCompleter('''''param number (0-4)''''', '''''completer''''')''': Sets the [wiki:ArgumentCompleter] for a given parameter (see [wiki:ConsoleCommand#ArgumentCompletion the chapter below])
     63
     64 * '''keybindMode('''''mode''''')''':
     65 * '''axisParamIndex('''''index''''')''':
     66 * '''isAxisRelative('''''bool''''')''':
     67
     68=== Chained attributes ===
     69You can specify all attributes from above in one single chained call, for example:
     70{{{
     71SetConsoleCommand(ClassName, functionname, true).description("Does something nice").defaultVal
     72    ues(10, "test", true, 1.234).argumentCompleter(0, autocompletion::completerfunction()).isA
     73    xisRelative(true);
     74}}}
     75Note: The attributes can be specified in any order.
     76
     77== Access Levels ==
     78
     79== Argument Completion ==