Changeset 6417 for code/trunk/src/libraries/core/input/KeyBinderManager.h
- Timestamp:
- Dec 25, 2009, 10:23:58 PM (14 years ago)
- Location:
- code/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/libraries/core/input/KeyBinderManager.h
r5929 r6417 34 34 #include <map> 35 35 #include <string> 36 #include <boost/shared_ptr.hpp> 37 36 38 #include "util/Singleton.h" 37 39 #include "core/OrxonoxClass.h" 38 40 39 namespace orxonox 40 { 41 namespace orxonox //tolua_export 42 { //tolua_export 41 43 /** 42 44 @brief … … 46 48 maps to the currently active KeyBinder. You can set that with setCurrent(). 47 49 There is also a default one, retrieved with getDefault(). The idea is that 48 mostly the default KeyBinder is active except for special situ tations (mini-game for inst).50 mostly the default KeyBinder is active except for special situations (mini-game for inst). 49 51 @remarks 50 52 You are not forced to use the KeyBinder imposed by getCurrent(). But be aware that "keybind" 51 53 will not work as expected! 52 54 */ 53 class _CoreExport KeyBinderManager : public Singleton<KeyBinderManager>, public OrxonoxClass 54 { 55 class _CoreExport KeyBinderManager //tolua_export 56 : public Singleton<KeyBinderManager>, public OrxonoxClass 57 { //tolua_export 55 58 friend class Singleton<KeyBinderManager>; 56 59 public: … … 59 62 void setConfigValues(); 60 63 64 static KeyBinderManager& getInstance() { return Singleton<KeyBinderManager>::getInstance(); } //tolua_export 61 65 //! Returns the currently selected KeyBinder 62 KeyBinder* getCurrent() 63 { return this->currentBinder_; } 66 KeyBinder* getCurrent() { return this->currentBinder_; } //tolua_export 64 67 //! Like getCurrent(), but returns it as InputHandler* (so you don't have to include KeyBinder.h) 65 68 InputHandler* getCurrentAsHandler(); … … 68 71 69 72 //! Returns the default KeyBinder 70 KeyBinder* 73 KeyBinder* getDefault() 71 74 { return binders_[this->defaultFilename_]; } 72 75 //! Returns the default KeyBinder as InputHandler* (so you don't have to include KeyBinder.h) … … 80 83 81 84 //! Returns a pointer to a KeyBinder (creates it if not yet loaded) 82 KeyBinder* 85 KeyBinder* get(const std::string& name); 83 86 //! Like get() but return value is of type InputHandler* (so you don't have to include KeyBinder.h) 84 87 InputHandler* getAsHandler(const std::string& name); 85 88 86 89 //! Loads a KeyBinder by creating it (no different from get() except for the return value) 87 void load 90 void load(const std::string& filename); 88 91 //! Destroys a KeyBinder completely (does nothing if not yet loaded) 89 92 void unload(const std::string& filename); 90 93 91 94 //! Bind 'command' to any key pressed after this call (use with care!) 92 inline void keybind(const std::string& command) 93 { this->keybindInternal(command, false); } 95 inline void keybind(const std::string& command) { this->keybindInternal(command, false); } //tolua_export 94 96 //! Bind 'command' to any key pressed after this call (use with care!), but temporarily (no file save) 95 97 inline void tkeybind(const std::string& command) 96 98 { this->keybindInternal(command, true); } 99 void unbind(const std::string& binding); //tolua_export 100 void tunbind(const std::string& binding); 101 inline void registerKeybindCallback(Functor* function) { this->callbackFunction_.reset(function); } // tolua_export 97 102 98 103 private: 99 104 KeyBinderManager(const KeyBinderManager&); 100 105 void keybindInternal(const std::string& command, bool bTemporary); 101 void callback(const std::string& keyName);106 void keybindKeyPressed(const std::string& keyName); 102 107 void defaultFilenameChanged(); 103 108 … … 109 114 110 115 // keybind command related 111 Functor* callbackFunction_;//! Function to be called when key was pressed after "keybind" command116 shared_ptr<Functor> callbackFunction_; //! Function to be called when key was pressed after "keybind" command 112 117 bool bBinding_; //! Tells whether a key binding process is active 113 118 bool bTemporary_; //! Stores tkeybind/keybind value … … 115 120 116 121 static KeyBinderManager* singletonPtr_s; 117 }; 118 } 122 }; //tolua_export 123 } //tolua_export 119 124 120 125 #endif /* _KeyBinderManager_H__ */
Note: See TracChangeset
for help on using the changeset viewer.