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/input
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • 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.