Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 9, 2009, 12:43:12 PM (14 years ago)
Author:
rgrieder
Message:

Added LuaFunctor that can execute arbitrary lua code.
Also added LuaState::createLuaFunctor(std::string) and implemented that for the keybindings menu.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/presentation2/src/libraries/core/input/KeyBinderManager.cc

    r6266 r6281  
    2929#include "KeyBinderManager.h"
    3030
     31#include <CEGUIWindow.h>
     32
    3133#include "util/Debug.h"
    3234#include "util/Exception.h"
     
    3739#include "InputManager.h"
    3840#include "KeyDetector.h"
    39 
    40 #include <CEGUIWindow.h>
    4141
    4242namespace orxonox
     
    4949        , bBinding_(false)
    5050    {
    51         this->callbackFunction_ = createFunctor(&KeyBinderManager::callback, this);
    52 
    5351        RegisterObject(KeyBinderManager);
    5452        this->setConfigValues();
     
    6967        for (std::map<std::string, KeyBinder*>::const_iterator it = this->binders_.begin(); it != this->binders_.end(); ++it)
    7068            delete it->second;
    71         delete this->callbackFunction_;
    7269    }
    7370
     
    152149        {
    153150            COUT(0) << "Press any button/key or move a mouse/joystick axis" << std::endl;
    154             KeyDetector::getInstance().setCallback(callbackFunction_);
     151            KeyDetector::getInstance().setCallback(shared_ptr<Functor>(createFunctor(&KeyBinderManager::keybindKeyPressed, this)));
    155152            InputManager::getInstance().enterState("detector");
    156153            this->command_ = command;
     
    162159
    163160    // Gets called by the KeyDetector (registered with a Functor)
    164     void KeyBinderManager::callback(const std::string& keyName)
     161    void KeyBinderManager::keybindKeyPressed(const std::string& keyName)
    165162    {
    166163        if (this->bBinding_)
     
    169166            this->currentBinder_->setBinding(command_, keyName, bTemporary_);
    170167            InputManager::getInstance().leaveState("detector");
     168            // inform whatever was calling the command
     169            if (this->callbackFunction_)
     170                (*this->callbackFunction_)();
    171171            this->bBinding_ = false;
    172172        }
Note: See TracChangeset for help on using the changeset viewer.