Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1312 for code


Ignore:
Timestamp:
May 16, 2008, 6:03:46 PM (17 years ago)
Author:
landauf
Message:

changed InputBuffer, added OutputBuffer and made a first sketch of Shell.

Location:
code/branches/console/src/core
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • code/branches/console/src/core/CMakeLists.txt

    r1276 r1312  
    1515  CoreSettings.cc
    1616  OutputHandler.cc
     17  OutputBuffer.cc
     18  InputBuffer.cc
     19  CommandExecutor.cc
    1720  Language.cc
    1821  ClassTreeMask.cc
     
    2225  Namespace.cc
    2326  NamespaceNode.cc
    24   CommandExecutor.cc
    25   InputBuffer.cc
    2627  Tickable.cc
    2728  Script.cc
  • code/branches/console/src/core/CorePrereqs.h

    r1277 r1312  
    137137  class OrxonoxClass;
    138138  class OutputBuffer;
     139  class OutputBufferListener;
    139140  class OutputHandler;
    140141  class Shell;
  • code/branches/console/src/core/InputBuffer.cc

    r1269 r1312  
    3838    InputBuffer::InputBuffer()
    3939    {
    40         //this->bActivated_ = false;
    41         this->allowedChars_ = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZäöüÄÖÜ0123456789 \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
     40        this->allowedChars_ = "abcdefghijklmnopqrstuvwxyz \
     41                               ABCDEFGHIJKLMNOPQRSTUVWXYZ \
     42                               äëïöüÄËÏÖÜáâàéêèíîìóôòúûù \
     43                               0123456789 \
     44                               \\\"(){}[]<>.:,;_-+*/=!?|$&%^~#";
    4245        this->keyboard_ = InputManager::getSingleton().getKeyboard();
    4346        this->buffer_ = "";
    44 
    45         //this->keyboard_->setEventCallback(this);
    4647    }
    4748
    4849    InputBuffer::InputBuffer(const std::string allowedChars)
    4950    {
    50         //this->bActivated_ = false;
    5151        this->allowedChars_ = allowedChars;
    5252        this->keyboard_ = InputManager::getSingleton().getKeyboard();
    5353        this->buffer_ = "";
    5454    }
    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     }
    6155
    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 */
    6856    void InputBuffer::set(const std::string& input)
    6957    {
     
    117105        for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    118106        {
    119             if (((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
     107            if ((!(*it).trueKeyFalseChar_) && ((*it).bListenToAllChanges_ || ((*it).char_ == update)) && (!(*it).bOnlySingleInput_ || bSingleInput))
    120108                (*(*it).listener_.*(*it).function_)();
    121109        }
    122110    }
    123 
    124     /*void InputBuffer::activityChanged() const
    125     {
    126     }*/
    127111
    128112    bool InputBuffer::charIsAllowed(const char& input)
     
    136120    bool InputBuffer::keyPressed(const OIS::KeyEvent &e)
    137121    {
    138         /*if (e.key == OIS::KC_NUMPADENTER)
     122        for (std::list<InputBufferListenerTuple>::iterator it = this->listeners_.begin(); it != this->listeners_.end(); ++it)
    139123        {
    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        }
    144127
    145128        if (this->keyboard_->isModifierDown(OIS::Keyboard::Ctrl))
     
    177160        }
    178161
    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 
    185162        this->append((char)e.text);
    186163        return true;
  • code/branches/console/src/core/InputBuffer.h

    r1151 r1312  
    5454            bool bListenToAllChanges_;
    5555            bool bOnlySingleInput_;
     56            bool trueKeyFalseChar_;
    5657            char char_;
     58            OIS::KeyCode key_;
    5759        };
    5860
     
    6466            void registerListener(T* listener, void (T::*function)(), bool bOnlySingleInput)
    6567            {
    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};
    6769                this->listeners_.insert(this->listeners_.end(), newListener);
    6870            }
     
    7072            void registerListener(T* listener, void (T::*function)() const, bool bOnlySingleInput)
    7173            {
    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};
    7375                this->listeners_.insert(this->listeners_.end(), newListener);
    7476            }
    7577
    7678            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)
    7880            {
    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};
    8082                this->listeners_.insert(this->listeners_.end(), newListener);
    8183            }
    8284            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)
    8486            {
    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};
    86101                this->listeners_.insert(this->listeners_.end(), newListener);
    87102            }
     
    99114                { return this->buffer_; }
    100115
    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() const
    108                 { return this->bActivated_; }
    109 
    110             void activityChanged() const;*/
    111 
    112116        private:
    113117            bool charIsAllowed(const char& input);
     
    117121
    118122            OIS::Keyboard* keyboard_;
    119             //bool bActivated_;
    120123            std::string buffer_;
    121124            std::list<InputBufferListenerTuple> listeners_;
Note: See TracChangeset for help on using the changeset viewer.