Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Aug 26, 2010, 12:09:12 AM (14 years ago)
Author:
landauf
Message:

adapted all console commands to the new interface

Location:
code/branches/consolecommands3/src/libraries/core
Files:
16 edited

Legend:

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

    r7204 r7219  
    425425    ////////////////////////
    426426
     427    static const std::string __CC_load_name = "reloadSettings";
     428    static const std::string __CC_setFilename_name = "setSettingsFile";
     429    static const std::string __CC_config_name = "config";
     430    static const std::string __CC_tconfig_name = "tconfig";
     431    static const std::string __CC_getConfig_name = "getConfig";
     432
     433    _SetConsoleCommand(__CC_load_name,            &ConfigFile::load);
     434    _SetConsoleCommand(__CC_setFilename_name,     &SettingsConfigFile::setFilename);
     435    _SetConsoleCommand(__CC_config_name,          &SettingsConfigFile::config).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
     436    _SetConsoleCommand(__CC_tconfig_name,         &SettingsConfigFile::tconfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
     437    _SetConsoleCommand(__CC_getConfig_name,       &SettingsConfigFile::getConfig).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries());
     438
    427439    SettingsConfigFile* SettingsConfigFile::singletonPtr_s = 0;
    428440
     
    430442        : ConfigFile(filename)
    431443    {
    432         ConsoleCommand* command = createConsoleCommand(createFunctor(&ConfigFile::load, this), "reloadSettings");
    433         CommandExecutor::addConsoleCommandShortcut(command);
    434         command = createConsoleCommand(createFunctor(&SettingsConfigFile::setFilename, this), "setSettingsFile");
    435         CommandExecutor::addConsoleCommandShortcut(command);
    436         command = createConsoleCommand(createFunctor(&SettingsConfigFile::config, this), "config");
    437         CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
    438         command = createConsoleCommand(createFunctor(&SettingsConfigFile::tconfig, this), "tconfig");
    439         CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries()).argumentCompleter(2, autocompletion::settingsvalue());
    440         command = createConsoleCommand(createFunctor(&SettingsConfigFile::getConfig, this), "getConfig");
    441         CommandExecutor::addConsoleCommandShortcut(command).argumentCompleter(0, autocompletion::settingssections()).argumentCompleter(1, autocompletion::settingsentries());
     444        _ModifyConsoleCommand(__CC_load_name).setObject(this);
     445        _ModifyConsoleCommand(__CC_setFilename_name).setObject(this);
     446        _ModifyConsoleCommand(__CC_config_name).setObject(this);
     447        _ModifyConsoleCommand(__CC_tconfig_name).setObject(this);
     448        _ModifyConsoleCommand(__CC_getConfig_name).setObject(this);
    442449    }
    443450
    444451    SettingsConfigFile::~SettingsConfigFile()
    445452    {
     453        _ModifyConsoleCommand(__CC_load_name).setObject(0);
     454        _ModifyConsoleCommand(__CC_setFilename_name).setObject(0);
     455        _ModifyConsoleCommand(__CC_config_name).setObject(0);
     456        _ModifyConsoleCommand(__CC_tconfig_name).setObject(0);
     457        _ModifyConsoleCommand(__CC_getConfig_name).setObject(0);
    446458    }
    447459
  • code/branches/consolecommands3/src/libraries/core/Core.cc

    r7207 r7219  
    6666#include "Language.h"
    6767#include "LuaState.h"
    68 #include "command/CommandExecutor.h"
     68#include "command/ConsoleCommand.h"
    6969#include "command/IOConsole.h"
    7070#include "command/TclBind.h"
     
    8888        : identifierDestroyer_(Identifier::destroyAllIdentifiers)
    8989        // Cleanup guard for external console commands that don't belong to an Identifier
    90         , consoleCommandDestroyer_(CommandExecutor::destroyExternalCommands)
     90        , consoleCommandDestroyer_(_ConsoleCommand::destroyAll)
    9191        , bGraphicsLoaded_(false)
    9292        , bStartIOConsole_(true)
  • code/branches/consolecommands3/src/libraries/core/CorePrereqs.h

    r7212 r7219  
    194194    class ArgumentCompletionListElement;
    195195    class CommandEvaluation;
    196     class ConsoleCommand;
     196    class _ConsoleCommand;
    197197    class Executor;
    198198    template <class T>
  • code/branches/consolecommands3/src/libraries/core/GUIManager.cc

    r7204 r7219  
    7171    static void key_esc()
    7272        { GUIManager::getInstance().keyESC(); }
    73     SetConsoleCommandShortcutExternAlias(key_esc, "keyESC");
     73    _SetConsoleCommand("keyESC", &key_esc);
    7474
    7575    class CEGUILogger : public CEGUI::DefaultLogger
     
    9999    GUIManager* GUIManager::singletonPtr_s = 0;
    100100
    101     SetConsoleCommandShortcut(GUIManager, showGUI).accessLevel(AccessLevel::User).defaultValue(1, false).defaultValue(2, true);
    102     SetConsoleCommandShortcut(GUIManager, hideGUI).accessLevel(AccessLevel::User);
     101    _SetConsoleCommand("showGUI", &GUIManager::showGUI).defaultValue(1, false).defaultValue(2, true);
     102    _SetConsoleCommand("hideGUI", &GUIManager::hideGUI);
    103103
    104104    /**
  • code/branches/consolecommands3/src/libraries/core/Game.cc

    r7204 r7219  
    5757    static void stop_game()
    5858        { Game::getInstance().stop(); }
    59     SetConsoleCommandShortcutExternAlias(stop_game, "exit");
     59    _SetConsoleCommand("exit", &stop_game);
    6060    static void printFPS()
    6161        { COUT(0) << Game::getInstance().getAvgFPS() << std::endl; }
    62     SetConsoleCommandShortcutExternAlias(printFPS, "printFPS");
     62    _SetConsoleCommand("printFPS", &printFPS);
    6363    static void printTickTime()
    6464        { COUT(0) << Game::getInstance().getAvgTickTime() << std::endl; }
    65     SetConsoleCommandShortcutExternAlias(printTickTime, "printTickTime");
     65    _SetConsoleCommand("printTickTime", &printTickTime);
    6666
    6767    std::map<std::string, GameStateInfo> Game::gameStateDeclarations_s;
  • code/branches/consolecommands3/src/libraries/core/GraphicsManager.cc

    r7204 r7219  
    6565namespace orxonox
    6666{
     67    static const std::string __CC_printScreen_name = "printScreen";
     68    _DeclareConsoleCommand(__CC_printScreen_name, &prototype::void__void);
     69
    6770    class OgreWindowEventListener : public Ogre::WindowEventListener
    6871    {
     
    131134
    132135        Ogre::WindowEventUtilities::removeWindowEventListener(renderWindow_, ogreWindowEventListener_.get());
    133         // TODO: Destroy the console command
     136        _ModifyConsoleCommand(__CC_printScreen_name).resetFunction();
    134137
    135138        // Undeclare the resources
     
    321324
    322325        // add console commands
    323         ccPrintScreen_ = createConsoleCommand(createFunctor(&GraphicsManager::printScreen, this), "printScreen");
    324         CommandExecutor::addConsoleCommandShortcut(ccPrintScreen_);
     326        _ModifyConsoleCommand(__CC_printScreen_name).setFunction(&GraphicsManager::printScreen, this);
    325327    }
    326328
  • code/branches/consolecommands3/src/libraries/core/GraphicsManager.h

    r6417 r7219  
    114114        int                 ogreLogLevelCritical_;     //!< Corresponding Orxonox debug level for LL_CRITICAL
    115115
    116         // console commands
    117         ConsoleCommand*     ccPrintScreen_;
    118 
    119116        static GraphicsManager* singletonPtr_s;        //!< Pointer to the Singleton
    120117    };
  • code/branches/consolecommands3/src/libraries/core/command/ConsoleCommandCompilation.cc

    r7202 r7219  
    3737#include "util/StringUtils.h"
    3838#include "ConsoleCommand.h"
     39#include "CommandExecutor.h"
    3940
    4041namespace orxonox
    4142{
    42     SetConsoleCommandShortcutExtern(source).argumentCompleter(0, autocompletion::files());
    43     SetConsoleCommandShortcutExtern(echo);
    44     SetConsoleCommandShortcutExtern(puts);
     43    _SetConsoleCommand("source", source).argumentCompleter(0, autocompletion::files());
     44    _SetConsoleCommand("echo", echo);
     45    _SetConsoleCommand("puts", puts);
    4546
    46     SetConsoleCommandShortcutExtern(read).argumentCompleter(0, autocompletion::files());
    47     SetConsoleCommandShortcutExtern(append).argumentCompleter(0, autocompletion::files());
    48     SetConsoleCommandShortcutExtern(write).argumentCompleter(0, autocompletion::files());
     47    _SetConsoleCommand("read", read).argumentCompleter(0, autocompletion::files());
     48    _SetConsoleCommand("append", append).argumentCompleter(0, autocompletion::files());
     49    _SetConsoleCommand("write", write).argumentCompleter(0, autocompletion::files());
    4950
    50     SetConsoleCommandShortcutExtern(calculate);
     51    _SetConsoleCommand("calculate", calculate);
    5152
    5253    void source(const std::string& filename)
  • code/branches/consolecommands3/src/libraries/core/command/IRC.cc

    r7203 r7219  
    4242    static const unsigned int IRC_TCL_THREADID  = 1421421421;
    4343
    44     SetConsoleCommand(IRC, say,  true).accessLevel(AccessLevel::User);
    45     SetConsoleCommand(IRC, msg,  false).accessLevel(AccessLevel::User);
    46     SetConsoleCommand(IRC, nick, false).accessLevel(AccessLevel::User);
     44    _SetConsoleCommand("IRC", "say",  &IRC::say);
     45    _SetConsoleCommand("IRC", "msg",  &IRC::msg);
     46    _SetConsoleCommand("IRC", "nick", &IRC::nick);
    4747
    4848    IRC::IRC()
  • code/branches/consolecommands3/src/libraries/core/command/Shell.cc

    r7203 r7219  
    4040namespace orxonox
    4141{
    42     SetConsoleCommandShortcut(OutputHandler, log);
    43     SetConsoleCommandShortcut(OutputHandler, error);
    44     SetConsoleCommandShortcut(OutputHandler, warning);
    45     SetConsoleCommandShortcut(OutputHandler, info);
    46     SetConsoleCommandShortcut(OutputHandler, debug);
     42    _SetConsoleCommand("log",     OutputHandler::log    );
     43    _SetConsoleCommand("error",   OutputHandler::error  );
     44    _SetConsoleCommand("warning", OutputHandler::warning);
     45    _SetConsoleCommand("info",    OutputHandler::info   );
     46    _SetConsoleCommand("debug",   OutputHandler::debug  );
    4747
    4848    Shell::Shell(const std::string& consoleName, bool bScrollable)
  • code/branches/consolecommands3/src/libraries/core/command/TclBind.cc

    r7203 r7219  
    4444namespace orxonox
    4545{
    46     SetConsoleCommandShortcut(TclBind, tcl);
    47     SetConsoleCommandShortcut(TclBind, bgerror);
     46    _SetConsoleCommand("tcl", &TclBind::tcl);
     47    _SetConsoleCommand("bgerror", &TclBind::bgerror);
    4848
    4949    TclBind* TclBind::singletonPtr_s = 0;
  • code/branches/consolecommands3/src/libraries/core/command/TclThreadManager.cc

    r7203 r7219  
    5050    const float TCLTHREADMANAGER_MAX_CPU_USAGE = 0.50f;
    5151
    52     SetConsoleCommandShortcutAlias(TclThreadManager, execute, "tclexecute").argumentCompleter(0, autocompletion::tclthreads());
    53     SetConsoleCommandShortcutAlias(TclThreadManager, query,   "tclquery"  ).argumentCompleter(0, autocompletion::tclthreads());
    54     SetConsoleCommand(TclThreadManager, create,  false);
    55     SetConsoleCommand(TclThreadManager, destroy, false).argumentCompleter(0, autocompletion::tclthreads());
    56     SetConsoleCommand(TclThreadManager, execute, false).argumentCompleter(0, autocompletion::tclthreads());
    57     SetConsoleCommand(TclThreadManager, query,   false).argumentCompleter(0, autocompletion::tclthreads());
    58     SetConsoleCommand(TclThreadManager, source,  false).argumentCompleter(0, autocompletion::tclthreads());
     52    _SetConsoleCommand("tclexecute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());
     53    _SetConsoleCommand("tclquery",   &TclThreadManager::query  ).argumentCompleter(0, autocompletion::tclthreads());
     54    _SetConsoleCommand("TclThreadManager", "create",  &TclThreadManager::create);
     55    _SetConsoleCommand("TclThreadManager", "destroy", &TclThreadManager::destroy).argumentCompleter(0, autocompletion::tclthreads());
     56    _SetConsoleCommand("TclThreadManager", "execute", &TclThreadManager::execute).argumentCompleter(0, autocompletion::tclthreads());
     57    _SetConsoleCommand("TclThreadManager", "query",   &TclThreadManager::query  ).argumentCompleter(0, autocompletion::tclthreads());
     58    _SetConsoleCommand("TclThreadManager", "source",  &TclThreadManager::source ).argumentCompleter(0, autocompletion::tclthreads());
    5959
    6060    /**
  • code/branches/consolecommands3/src/libraries/core/input/InputManager.cc

    r7204 r7219  
    6262    SetCommandLineSwitch(keyboard_no_grab).information("Whether not to exclusively grab the keyboard");
    6363
     64    static const std::string __CC_InputManager_name = "InputManager";
     65    static const std::string __CC_calibrate_name = "calibrate";
     66    static const std::string __CC_reload_name = "reload";
     67
     68    _SetConsoleCommand(__CC_InputManager_name, __CC_calibrate_name, &InputManager::calibrate).addShortcut();
     69    _SetConsoleCommand(__CC_InputManager_name, __CC_reload_name,    &InputManager::reload   );
     70
    6471    // Abuse of this source file for the InputHandler
    6572    InputHandler InputHandler::EMPTY;
     
    118125        this->updateActiveStates();
    119126
    120         // calibrate console command
    121         this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::calibrate, this), "calibrate"), true);
    122         // reload console command
    123         this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(&InputManager::reload, this), "reload"), false);
     127        _ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(this);
     128        _ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(this);
    124129
    125130        CCOUT(4) << "Construction complete." << std::endl;
     
    287292        if (!(internalState_ & Bad))
    288293            this->destroyDevices();
     294
     295        // Reset console commands
     296        _ModifyConsoleCommand(__CC_InputManager_name, __CC_calibrate_name).setObject(0);
     297        _ModifyConsoleCommand(__CC_InputManager_name, __CC_reload_name).setObject(0);
    289298
    290299        CCOUT(3) << "Destruction complete." << std::endl;
  • code/branches/consolecommands3/src/libraries/core/input/KeyBinderManager.cc

    r7207 r7219  
    4343    ManageScopedSingleton(KeyBinderManager, ScopeID::Graphics, false);
    4444
     45    static const std::string __CC_keybind_name = "keybind";
     46    static const std::string __CC_tkeybind_name = "tkeybind";
     47    static const std::string __CC_unbind_name = "unbind";
     48    static const std::string __CC_tunbind_name = "tunbind";
     49
     50    _SetConsoleCommand(__CC_keybind_name,  &KeyBinderManager::keybind).defaultValues("");
     51    _SetConsoleCommand(__CC_tkeybind_name, &KeyBinderManager::tkeybind).defaultValues("");
     52    _SetConsoleCommand(__CC_unbind_name,   &KeyBinderManager::unbind).defaultValues("");
     53    _SetConsoleCommand(__CC_tunbind_name,  &KeyBinderManager::tunbind).defaultValues("");
     54
    4555    KeyBinderManager::KeyBinderManager()
    4656        : currentBinder_(NULL)
     
    5262
    5363        // keybind console commands
    54         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::keybind,  this), "keybind" ))
    55             .defaultValues("");
    56         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tkeybind, this), "tkeybind"))
    57             .defaultValues("");
    58         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::unbind, this), "unbind"))
    59             .defaultValues("");
    60         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyBinderManager::tunbind, this), "tunbind"))
    61             .defaultValues("");
     64        _ModifyConsoleCommand(__CC_keybind_name ).setObject(this);
     65        _ModifyConsoleCommand(__CC_tkeybind_name).setObject(this);
     66        _ModifyConsoleCommand(__CC_unbind_name  ).setObject(this);
     67        _ModifyConsoleCommand(__CC_tunbind_name ).setObject(this);
    6268
    6369        // Load default key binder
     
    7076        for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
    7177            delete it->second;
     78
     79        // Reset console commands
     80        _ModifyConsoleCommand(__CC_keybind_name ).setObject(0);
     81        _ModifyConsoleCommand(__CC_tkeybind_name).setObject(0);
     82        _ModifyConsoleCommand(__CC_unbind_name  ).setObject(0);
     83        _ModifyConsoleCommand(__CC_tunbind_name ).setObject(0);
    7284    }
    7385
  • code/branches/consolecommands3/src/libraries/core/input/KeyDetector.cc

    r7207 r7219  
    3838namespace orxonox
    3939{
    40     std::string KeyDetector::callbackCommand_s = "KeyDetectorKeyPressed";
    4140    ManageScopedSingleton(KeyDetector, ScopeID::Graphics, false);
     41
     42    static const std::string __CC_KeyDetector_callback_name = "KeyDetectorKeyPressed";
     43    _DeclareConsoleCommand(__CC_KeyDetector_callback_name, &prototype::void__string);
    4244
    4345    KeyDetector::KeyDetector()
     
    4648        RegisterObject(KeyDetector);
    4749
    48         CommandExecutor::addConsoleCommandShortcut(createConsoleCommand(createFunctor(&KeyDetector::callback,  this), callbackCommand_s));
     50        _ModifyConsoleCommand(__CC_KeyDetector_callback_name).setFunction(&KeyDetector::callback, this);
     51
    4952        this->assignCommands();
    5053
     
    5962        inputState_->setHandler(NULL);
    6063        InputManager::getInstance().destroyState("detector");
     64        _ModifyConsoleCommand(__CC_KeyDetector_callback_name).resetFunction();
    6165    }
    6266
     
    6569        // Assign every button/axis the same command, but with its name as argument
    6670        for (std::map<std::string, Button*>::const_iterator it = allButtons_.begin(); it != allButtons_.end(); ++it)
    67             it->second->parse(callbackCommand_s + ' ' + it->second->groupName_ + "." + it->second->name_);
     71            it->second->parse(__CC_KeyDetector_callback_name + ' ' + it->second->groupName_ + "." + it->second->name_);
    6872    }
    6973
  • code/branches/consolecommands3/src/libraries/core/input/KeyDetector.h

    r7198 r7219  
    5757        FunctorPtr callbackFunction_;
    5858        InputState* inputState_;
    59         static std::string callbackCommand_s;
    6059        static KeyDetector* singletonPtr_s;
    6160    };
Note: See TracChangeset for help on using the changeset viewer.