- Timestamp:
- May 16, 2008, 6:03:46 PM (17 years ago)
- Location:
- code/branches/console/src/core
- Files:
-
- 4 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/console/src/core/CMakeLists.txt
r1276 r1312 15 15 CoreSettings.cc 16 16 OutputHandler.cc 17 OutputBuffer.cc 18 InputBuffer.cc 19 CommandExecutor.cc 17 20 Language.cc 18 21 ClassTreeMask.cc … … 22 25 Namespace.cc 23 26 NamespaceNode.cc 24 CommandExecutor.cc25 InputBuffer.cc26 27 Tickable.cc 27 28 Script.cc -
code/branches/console/src/core/CorePrereqs.h
r1277 r1312 137 137 class OrxonoxClass; 138 138 class OutputBuffer; 139 class OutputBufferListener; 139 140 class OutputHandler; 140 141 class Shell; -
code/branches/console/src/core/InputBuffer.cc
r1269 r1312 38 38 InputBuffer::InputBuffer() 39 39 { 40 //this->bActivated_ = false; 41 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#"; 40 this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \ 41 ABCDEFGHIJKLMNOPQRSTUVWXYZ \ 42 äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \ 43 0123456789 \ 44 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#"; 42 45 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 43 46 this->buffer_ = ""; 44 45 //this->keyboard_->setEventCallback(this);46 47 } 47 48 48 49 InputBuffer::InputBuffer(const std::string allowedChars) 49 50 { 50 //this->bActivated_ = false;51 51 this->allowedChars_ = allowedChars; 52 52 this->keyboard_ = InputManager::getSingleton().getKeyboard(); 53 53 this->buffer_ = ""; 54 54 } 55 /*56 void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), bool bOnlySingleInput)57 {58 struct InputBufferListenerTuple newListener = {listener, function, true, bOnlySingleInput, ' '};59 this->listeners_.insert(this->listeners_.end(), newListener);60 }61 55 62 void InputBuffer::registerListener(InputBufferListener* listener, void (InputBufferListener::*function)(), char char_, bool bOnlySingleInput)63 {64 struct InputBufferListenerTuple newListener = {listener, function, false, bOnlySingleInput, char_};65 this->listeners_.insert(this->listeners_.end(), newListener);66 }67 */68 56 void InputBuffer::set(const std::string& input) 69 57 { … … 117 105 for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 118 106 { 119 if (( (*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))107 if ((!(*it).trueKeyFalseChar_) && ((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput)) 120 108 (*(*it).listener_.*(*it).function_)(); 121 109 } 122 110 } 123 124 /*void InputBuffer::activityChanged() const125 {126 }*/127 111 128 112 bool InputBuffer::charIsAllowed(const char& input) … … 136 120 bool InputBuffer::keyPressed(const OIS::KeyEvent &e) 137 121 { 138 /*if (e.key == OIS::KC_NUMPADENTER)122 for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it) 139 123 { 140 this->setActivated(!this->isActivated()); 141 this->clear(); 142 return true; 143 }*/ 124 if ((*it).trueKeyFalseChar_ && ((*it).key_ == e.key)) 125 (*(*it).listener_.*(*it).function_)(); 126 } 144 127 145 128 if (this->keyboard_->isModifierDown(OIS::Keyboard::Ctrl)) … … 177 160 } 178 161 179 //std::cout << this->keyboard_->getAsString(e.key) << " / " << (char)e.text << std::endl;180 181 std::string input = this->keyboard_->getAsString(e.key);182 /*if (input.size() >= 1)183 this->append(input[0]);*/184 185 162 this->append((char)e.text); 186 163 return true; -
code/branches/console/src/core/InputBuffer.h
r1151 r1312 54 54 bool bListenToAllChanges_; 55 55 bool bOnlySingleInput_; 56 bool trueKeyFalseChar_; 56 57 char char_; 58 OIS::KeyCode key_; 57 59 }; 58 60 … … 64 66 void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput) 65 67 { 66 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};68 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, false, '\0', OIS::KC_UNASSIGNED}; 67 69 this->listeners_.insert(this->listeners_.end(), newListener); 68 70 } … … 70 72 void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput) 71 73 { 72 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, ' '};74 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, true, bOnlySingleInput, false, '\0', OIS::KC_UNASSIGNED}; 73 75 this->listeners_.insert(this->listeners_.end(), newListener); 74 76 } 75 77 76 78 template <class T> 77 void registerListener(T* listener, void (T::*function)(), char char_, bool bOnlySingleInput)79 void registerListener(T* listener, void (T::*function)(), char _char, bool bOnlySingleInput) 78 80 { 79 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_};81 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, false, _char, OIS::KC_UNASSIGNED}; 80 82 this->listeners_.insert(this->listeners_.end(), newListener); 81 83 } 82 84 template <class T> 83 void registerListener(T* listener, void (T::*function)() const, char char_, bool bOnlySingleInput)85 void registerListener(T* listener, void (T::*function)() const, char _char, bool bOnlySingleInput) 84 86 { 85 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, char_}; 87 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, bOnlySingleInput, false, _char, OIS::KC_UNASSIGNED}; 88 this->listeners_.insert(this->listeners_.end(), newListener); 89 } 90 91 template <class T> 92 void registerListener(T* listener, void (T::*function)(), OIS::KeyCode key) 93 { 94 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, true, true, '\0', key}; 95 this->listeners_.insert(this->listeners_.end(), newListener); 96 } 97 template <class T> 98 void registerListener(T* listener, void (T::*function)() const, OIS::KeyCode key) 99 { 100 struct InputBufferListenerTuple newListener = {listener, (void (InputBufferListener::*)())function, false, true, true, '\0', key}; 86 101 this->listeners_.insert(this->listeners_.end(), newListener); 87 102 } … … 99 114 { return this->buffer_; } 100 115 101 /*inline void activate()102 { this->setActivated(true); }103 inline void deactivate()104 { this->setActivated(false); }105 inline void setActivated(bool bActivated)106 { if (this->bActivated_ != bActivated) { this->bActivated_ = bActivated; this->activityChanged(); } else { this->bActivated_ = bActivated; } }107 inline bool isActivated() const108 { return this->bActivated_; }109 110 void activityChanged() const;*/111 112 116 private: 113 117 bool charIsAllowed(const char& input); … … 117 121 118 122 OIS::Keyboard* keyboard_; 119 //bool bActivated_;120 123 std::string buffer_; 121 124 std::list<InputBufferListenerTuple> listeners_;
Note: See TracChangeset
for help on using the changeset viewer.