Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1594 for code/branches/core3


Ignore:
Timestamp:
Jun 12, 2008, 4:14:21 PM (17 years ago)
Author:
landauf
Message:

added more SetConsoleCommand macros like SetConsoleCommandAlias to use a different name than the real functionname for the command. this provides more comfort as it reduces the need of creating your own ConsoleCommand-object via *Generic macros.

Location:
code/branches/core3/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • code/branches/core3/src/core/ConfigFileManager.cc

    r1543 r1594  
    3838namespace orxonox
    3939{
    40     SetConsoleCommandShortcutExtern(config).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
    41     SetConsoleCommandShortcutExtern(tconfig).setArgumentCompleter(0, autocompletion::configvalueclasses()).setArgumentCompleter(1, autocompletion::configvalues()).setArgumentCompleter(2, autocompletion::configvalue());
     40    SetConsoleCommandShortcutExtern(config).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
     41    SetConsoleCommandShortcutExtern(tconfig).argumentCompleter(0, autocompletion::configvalueclasses()).argumentCompleter(1, autocompletion::configvalues()).argumentCompleter(2, autocompletion::configvalue());
    4242    SetConsoleCommandShortcutExtern(reloadConfig);
    4343    SetConsoleCommandShortcutExtern(cleanConfig);
    44     SetConsoleCommandShortcutExtern(loadSettings).setArgumentCompleter(0, autocompletion::files());
    45     SetConsoleCommandShortcutExtern(loadKeybindings).setArgumentCompleter(0, autocompletion::files());
     44    SetConsoleCommandShortcutExtern(loadSettings).argumentCompleter(0, autocompletion::files());
     45    SetConsoleCommandShortcutExtern(loadKeybindings).argumentCompleter(0, autocompletion::files());
    4646
    4747    bool config(const std::string& classname, const std::string& varname, const std::string& value)
  • code/branches/core3/src/core/ConsoleCommand.cc

    r1505 r1594  
    4545    }
    4646
    47     ConsoleCommand& ConsoleCommand::setArgumentCompleter(unsigned int param, ArgumentCompleter* completer)
     47    ConsoleCommand& ConsoleCommand::argumentCompleter(unsigned int param, ArgumentCompleter* completer)
    4848    {
    4949        if (param < 5)
  • code/branches/core3/src/core/ConsoleCommand.h

    r1583 r1594  
    3838
    3939
    40 #define SetConsoleCommand(classname, function,  bCreateShortcut) \
    41     SetConsoleCommandGeneric(classname##function##consolecommand__, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function), bCreateShortcut)
     40#define SetConsoleCommand(classname, function, bCreateShortcut) \
     41    SetConsoleCommandAliasMulti(classname, function, #function, 0, bCreateShortcut)
     42#define SetConsoleCommandAlias(classname, function, name, bCreateShortcut) \
     43    SetConsoleCommandAliasMulti(classname, function, name, 0, bCreateShortcut)
     44#define SetConsoleCommandAliasMulti(classname, function, name, number, bCreateShortcut) \
     45    SetConsoleCommandGeneric(classname##function##consolecommand__##number, classname, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name), bCreateShortcut)
    4246
    4347#define SetConsoleCommandGeneric(fakevariable, classname, command, bCreateShortcut) \
     
    4650
    4751#define SetConsoleCommandShortcut(classname, function) \
    48     SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), #function))
     52    SetConsoleCommandShortcutAliasMulti(classname, function, #function, 0)
     53#define SetConsoleCommandShortcutAlias(classname, function, name) \
     54    SetConsoleCommandShortcutAliasMulti(classname, function, name, 0)
     55#define SetConsoleCommandShortcutAliasMulti(classname, function, name, number) \
     56    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&classname::function), name))
    4957
    5058#define SetConsoleCommandShortcutExtern(function) \
    51     SetConsoleCommandShortcutGeneric(function##consolecommand__, orxonox::createConsoleCommand(orxonox::createFunctor(&function), #function))
     59    SetConsoleCommandShortcutExternAliasMulti(function, #function, 0)
     60#define SetConsoleCommandShortcutExternAlias(function, name) \
     61    SetConsoleCommandShortcutExternAliasMulti(function, name, 0)
     62#define SetConsoleCommandShortcutExternAliasMulti(function, name, number) \
     63    SetConsoleCommandShortcutGeneric(function##consolecommand__##number, orxonox::createConsoleCommand(orxonox::createFunctor(&function), name))
    5264
    5365#define SetConsoleCommandShortcutGeneric(fakevariable, command) \
     
    7587            ConsoleCommand(FunctorStatic* functor, const std::string& name = "");
    7688
    77             inline ConsoleCommand& setDescription(const std::string& description)
     89            inline ConsoleCommand& description(const std::string& description)
    7890                { this->ExecutorStatic::setDescription(description); return (*this); }
    79             inline ConsoleCommand& setDescriptionParam(int param, const std::string& description)
     91            inline ConsoleCommand& descriptionParam(int param, const std::string& description)
    8092                { this->ExecutorStatic::setDescriptionParam(param, description); return (*this); }
    81             inline ConsoleCommand& setDescriptionReturnvalue(const std::string& description)
     93            inline ConsoleCommand& descriptionReturnvalue(const std::string& description)
    8294                { this->ExecutorStatic::setDescriptionReturnvalue(description); return (*this); }
    83             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1)
     95            inline ConsoleCommand& defaultValues(const MultiTypeMath& param1)
    8496                { this->ExecutorStatic::setDefaultValues(param1); return (*this); }
    85             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
     97            inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2)
    8698                { this->ExecutorStatic::setDefaultValues(param1, param2); return (*this); }
    87             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
     99            inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3)
    88100                { this->ExecutorStatic::setDefaultValues(param1, param2, param3); return (*this); }
    89             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
     101            inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4)
    90102                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4); return (*this); }
    91             inline ConsoleCommand& setDefaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
     103            inline ConsoleCommand& defaultValues(const MultiTypeMath& param1, const MultiTypeMath& param2, const MultiTypeMath& param3, const MultiTypeMath& param4, const MultiTypeMath& param5)
    92104                { this->ExecutorStatic::setDefaultValues(param1, param2, param3, param4, param5); return (*this); }
    93             inline ConsoleCommand& setDefaultValue(unsigned int index, const MultiTypeMath& param)
     105            inline ConsoleCommand& defaultValue(unsigned int index, const MultiTypeMath& param)
    94106                { this->ExecutorStatic::setDefaultValue(index, param); return (*this); }
    95107
    96             inline ConsoleCommand& setAccessLevel(AccessLevel::Level level)
     108            inline ConsoleCommand& accessLevel(AccessLevel::Level level)
    97109                { this->accessLevel_ = level; return (*this); }
    98110            inline AccessLevel::Level getAccessLevel() const
    99111                { return this->accessLevel_; }
    100112
    101             ConsoleCommand& setArgumentCompleter(unsigned int param, ArgumentCompleter* completer);
     113            ConsoleCommand& argumentCompleter(unsigned int param, ArgumentCompleter* completer);
    102114            ArgumentCompleter* getArgumentCompleter(unsigned int param) const;
    103115
     
    110122                { return this->argumentList_.end(); }
    111123
    112             inline ConsoleCommand& setKeybindMode(KeybindMode::Enum mode)
     124            inline ConsoleCommand& keybindMode(KeybindMode::Enum mode)
    113125                { this->keybindMode_ = mode; return *this; }
    114126            inline KeybindMode::Enum getKeybindMode() const
    115127                { return this->keybindMode_; }
    116128
    117             inline ConsoleCommand& setAxisParamIndex(int index)
     129            inline ConsoleCommand& axisParamIndex(int index)
    118130                { this->axisParamIndex_ = index; return *this; }
    119131            inline int getAxisParamIndex() const
    120132                { return this->axisParamIndex_; }
    121133
    122             inline ConsoleCommand& setIsAxisRelative(bool val)
     134            inline ConsoleCommand& isAxisRelative(bool val)
    123135                { this->bAxisRelative_ = val; return *this; }
    124136            inline int getIsAxisRelative() const
  • code/branches/core3/src/core/ConsoleCommandCompilation.cc

    r1586 r1594  
    3434namespace orxonox
    3535{
    36     SetConsoleCommandShortcutExtern(source).setArgumentCompleter(0, autocompletion::files());
     36    SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
    3737    SetConsoleCommandShortcutExtern(echo);
    3838    SetConsoleCommandShortcutExtern(puts);
    3939
    40     SetConsoleCommandShortcutExtern(read).setArgumentCompleter(0, autocompletion::files());
    41     SetConsoleCommandShortcutExtern(append).setArgumentCompleter(0, autocompletion::files());
    42     SetConsoleCommandShortcutExtern(write).setArgumentCompleter(0, autocompletion::files());
     40    SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
     41    SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
     42    SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
    4343
    4444    SetConsoleCommandShortcutExtern(calculate);
  • code/branches/core3/src/core/IRC.cc

    r1583 r1594  
    3939namespace orxonox
    4040{
    41     SetConsoleCommand(IRC, say,  true).setAccessLevel(AccessLevel::User);
    42     SetConsoleCommand(IRC, msg,  false).setAccessLevel(AccessLevel::User);
    43     SetConsoleCommand(IRC, nick, false).setAccessLevel(AccessLevel::User);
     41    SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
     42    SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
     43    SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
    4444
    4545    IRC::IRC()
  • code/branches/core3/src/core/Shell.cc

    r1591 r1594  
    4545    SetConsoleCommand(Shell, history, true);
    4646
    47     SetConsoleCommandShortcutGeneric(log,     createConsoleCommand(createFunctor(&OutputHandler::log),     "log"    ));
    48     SetConsoleCommandShortcutGeneric(error,   createConsoleCommand(createFunctor(&OutputHandler::error),   "error"  ));
    49     SetConsoleCommandShortcutGeneric(warning, createConsoleCommand(createFunctor(&OutputHandler::warning), "warning"));
    50     SetConsoleCommandShortcutGeneric(info,    createConsoleCommand(createFunctor(&OutputHandler::info),    "info"   ));
    51     SetConsoleCommandShortcutGeneric(debug,   createConsoleCommand(createFunctor(&OutputHandler::debug),   "debug"  ));
     47    SetConsoleCommandShortcut(OutputHandler, log);
     48    SetConsoleCommandShortcut(OutputHandler, error);
     49    SetConsoleCommandShortcut(OutputHandler, warning);
     50    SetConsoleCommandShortcut(OutputHandler, info);
     51    SetConsoleCommandShortcut(OutputHandler, debug);
    5252
    5353    Shell::Shell()
  • code/branches/core3/src/core/TclBind.cc

    r1586 r1594  
    3939namespace orxonox
    4040{
    41     SetConsoleCommandShortcutGeneric(tcl, createConsoleCommand(createFunctor(&TclBind::tcl), "tcl"));
    42     SetConsoleCommandShortcutGeneric(bgerror, createConsoleCommand(createFunctor(&TclBind::bgerror), "bgerror"));
     41    SetConsoleCommandShortcut(TclBind, tcl);
     42    SetConsoleCommandShortcut(TclBind, bgerror);
    4343
    4444    TclBind::TclBind()
  • code/branches/core3/src/core/TclThreadManager.cc

    r1586 r1594  
    4848namespace orxonox
    4949{
    50     SetConsoleCommandShortcutGeneric(tclexecute, createConsoleCommand(createFunctor(&TclThreadManager::execute), "tclexecute")).setArgumentCompleter(0, autocompletion::tclthreads());
    51     SetConsoleCommandShortcutGeneric(tclquery,   createConsoleCommand(createFunctor(&TclThreadManager::query),   "tclquery"  )).setArgumentCompleter(0, autocompletion::tclthreads());
     50    SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
     51    SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
    5252    SetConsoleCommand(TclThreadManager, create,  false);
    53     SetConsoleCommand(TclThreadManager, destroy, false).setArgumentCompleter(0, autocompletion::tclthreads());
    54     SetConsoleCommand(TclThreadManager, execute, false).setArgumentCompleter(0, autocompletion::tclthreads());
    55     SetConsoleCommand(TclThreadManager, query,   false).setArgumentCompleter(0, autocompletion::tclthreads());
     53    SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
     54    SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
     55    SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
    5656    SetConsoleCommand(TclThreadManager, status,  false);
    57     SetConsoleCommand(TclThreadManager, dump,    false).setArgumentCompleter(0, autocompletion::tclthreads());
    58     SetConsoleCommand(TclThreadManager, flush,   false).setArgumentCompleter(0, autocompletion::tclthreads());
     57    SetConsoleCommand(TclThreadManager, dump,    false).argumentCompleter(0, autocompletion::tclthreads());
     58    SetConsoleCommand(TclThreadManager, flush,   false).argumentCompleter(0, autocompletion::tclthreads());
    5959
    6060    TclThreadManager::TclThreadManager()
  • code/branches/core3/src/orxonox/Orxonox.cc

    r1591 r1594  
    8585namespace orxonox
    8686{
    87   SetConsoleCommandShortcut(Orxonox, exit).setKeybindMode(KeybindMode::OnPress);
    88   SetConsoleCommandShortcut(Orxonox, slomo).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0).setAxisParamIndex(0).setIsAxisRelative(false);
    89   SetConsoleCommandShortcut(Orxonox, setTimeFactor).setAccessLevel(AccessLevel::Offline).setDefaultValue(0, 1.0);
     87  SetConsoleCommandShortcut(Orxonox, exit).keybindMode(KeybindMode::OnPress);
     88  SetConsoleCommandShortcut(Orxonox, slomo).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0).axisParamIndex(0).isAxisRelative(false);
     89  SetConsoleCommandShortcut(Orxonox, setTimeFactor).accessLevel(AccessLevel::Offline).defaultValue(0, 1.0);
    9090
    9191  /**
  • code/branches/core3/src/orxonox/hud/HUD.cc

    r1586 r1594  
    4949namespace orxonox
    5050{
    51     SetConsoleCommandShortcut(HUD, cycleNavigationFocus).setAccessLevel(AccessLevel::User);
    52     SetConsoleCommandShortcut(HUD, releaseNavigationFocus).setAccessLevel(AccessLevel::User);
    53     SetConsoleCommandShortcut(HUD, toggleFPS).setAccessLevel(AccessLevel::User);
    54     SetConsoleCommandShortcut(HUD, toggleRenderTime).setAccessLevel(AccessLevel::User);
     51    SetConsoleCommandShortcut(HUD, cycleNavigationFocus).accessLevel(AccessLevel::User);
     52    SetConsoleCommandShortcut(HUD, releaseNavigationFocus).accessLevel(AccessLevel::User);
     53    SetConsoleCommandShortcut(HUD, toggleFPS).accessLevel(AccessLevel::User);
     54    SetConsoleCommandShortcut(HUD, toggleRenderTime).accessLevel(AccessLevel::User);
    5555
    5656    using namespace Ogre;
  • code/branches/core3/src/orxonox/objects/Ambient.cc

    r1592 r1594  
    4747namespace orxonox
    4848{
    49     SetConsoleCommand(Ambient, setAmbientLightTest, false).setDefaultValues(ColourValue(1, 1, 1, 1)).setAccessLevel(AccessLevel::Offline);
     49    SetConsoleCommandAlias(Ambient, setAmbientLightTest, "setAmbientLight", false).defaultValues(ColourValue(1, 1, 1, 1)).accessLevel(AccessLevel::Offline);
    5050
    5151    CreateFactory(Ambient);
  • code/branches/core3/src/orxonox/objects/SpaceShip.cc

    r1592 r1594  
    5454namespace orxonox
    5555{
    56     SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).setAccessLevel(AccessLevel::Debug);
    57     SetConsoleCommand(SpaceShip, whereAmI, true).setAccessLevel(AccessLevel::User);
    58     SetConsoleCommand(SpaceShip, moveLongitudinal, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
    59     SetConsoleCommand(SpaceShip, moveLateral, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
    60     SetConsoleCommand(SpaceShip, moveYaw, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
    61     SetConsoleCommand(SpaceShip, movePitch, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
    62     SetConsoleCommand(SpaceShip, moveRoll, true).setAccessLevel(AccessLevel::User).setDefaultValue(0, 1.0f).setAxisParamIndex(0).setKeybindMode(KeybindMode::OnHold);
    63     SetConsoleCommand(SpaceShip, fire, true).setAccessLevel(AccessLevel::User).setKeybindMode(KeybindMode::OnHold);
    64     SetConsoleCommandGeneric(test1, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxSpeed"), false).setAccessLevel(AccessLevel::Debug);
    65     SetConsoleCommandGeneric(test2, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setMaxBlubber"), false).setAccessLevel(AccessLevel::Debug);
    66     SetConsoleCommandGeneric(test3, SpaceShip, createConsoleCommand(createFunctor(&SpaceShip::setMaxSpeedTest), "setRofl"), false).setAccessLevel(AccessLevel::Debug);
     56    SetConsoleCommand(SpaceShip, setMaxSpeedTest, false).accessLevel(AccessLevel::Debug);
     57    SetConsoleCommand(SpaceShip, whereAmI, true).accessLevel(AccessLevel::User);
     58    SetConsoleCommand(SpaceShip, moveLongitudinal, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
     59    SetConsoleCommand(SpaceShip, moveLateral, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
     60    SetConsoleCommand(SpaceShip, moveYaw, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
     61    SetConsoleCommand(SpaceShip, movePitch, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
     62    SetConsoleCommand(SpaceShip, moveRoll, true).accessLevel(AccessLevel::User).defaultValue(0, 1.0f).axisParamIndex(0).keybindMode(KeybindMode::OnHold);
     63    SetConsoleCommand(SpaceShip, fire, true).accessLevel(AccessLevel::User).keybindMode(KeybindMode::OnHold);
     64    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxSpeed", 1, false).accessLevel(AccessLevel::Debug);
     65    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setMaxBlubber", 2, false).accessLevel(AccessLevel::Debug);
     66    SetConsoleCommandAliasMulti(SpaceShip, setMaxSpeedTest, "setRofl", 3, false).accessLevel(AccessLevel::Debug);
    6767
    6868    CreateFactory(SpaceShip);
  • code/branches/core3/src/orxonox/objects/SpaceShipAI.cc

    r1591 r1594  
    4444namespace orxonox
    4545{
    46     SetConsoleCommand(SpaceShipAI, createEnemy, true).setDefaultValue(0, 1);
    47     SetConsoleCommand(SpaceShipAI, killEnemies, true).setDefaultValue(0, 0);
     46    SetConsoleCommand(SpaceShipAI, createEnemy, true).defaultValue(0, 1);
     47    SetConsoleCommand(SpaceShipAI, killEnemies, true).defaultValue(0, 0);
    4848
    4949    CreateFactory(SpaceShipAI);
Note: See TracChangeset for help on using the changeset viewer.