Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6788


Ignore:
Timestamp:
Apr 26, 2010, 4:09:23 PM (15 years ago)
Author:
smerkli
Message:

stuff works, but keybinding still does only work in the build folder

Location:
code/branches/chat/src/orxonox
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/branches/chat/src/orxonox/CMakeLists.txt

    r6698 r6788  
    3333  Radar.cc
    3434  ChatHistory.cc
     35  ChatInputHandler.cc
    3536COMPILATION_BEGIN SceneCompilation.cc
    3637  CameraManager.cc
  • code/branches/chat/src/orxonox/ChatInputHandler.cc

    r6777 r6788  
    2828
    2929#include "ChatInputHandler.h"
     30#include <core/ScopedSingletonManager.h>
     31#include "core/ConsoleCommand.h"
     32#include "core/CoreIncludes.h"
     33#include <string>
    3034
    3135namespace orxonox
    3236{
    3337  /* singleton */
    34   ManageScopedSingleton( ChatInputHandler, ScopeID::Root, false );
     38  ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false );
    3539
    3640  /* constructor */
    37   void ChatInputHandler::ChatInputHandler()
     41  ChatInputHandler::ChatInputHandler()
    3842  {
    3943    /* register the object  */
    4044    RegisterObject(ChatInputHandler);
    4145
     46    //COUT(0) << "Singleton registered for ChatInputHandler." << std::endl;
     47
    4248    /* create necessary objects */
    4349    this->inpbuf = new InputBuffer();
    4450
     51    /* configure the input buffer */
    4552                configureInputBuffer();
     53
     54    this->inputState = InputManager::getInstance().createInputState( "chatinput", false, false, InputStatePriority::Dynamic );
     55    this->inputState->setKeyHandler(this->inpbuf);
     56
     57    /* set console shortcut */
     58    this->getIdentifier()->addConsoleCommand(createConsoleCommand(createFunctor(
     59      &ChatInputHandler::activate, this), "startchat"), false);
    4660  }
    4761
     
    4963  {
    5064          /* input has changed */
    51     this->inputBuffer_->registerListener(this, &ChatInputHandler::inputChanged, true);
     65    this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true);
    5266               
    5367                /* add a line */
    54     this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
    55     this->inputBuffer_->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
     68    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\r',   false);
     69    this->inpbuf->registerListener(this, &ChatInputHandler::addline,         '\n',   false);
    5670
    5771                /* backspace */
    58     this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
    59     this->inputBuffer_->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
     72    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\b',   true);
     73    this->inpbuf->registerListener(this, &ChatInputHandler::backspace,       '\177', true);
    6074
    6175                /* exit the chatinputhandler thingy (tbd) */
    62     this->inputBuffer_->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
     76    this->inpbuf->registerListener(this, &ChatInputHandler::exit,            '\033', true); // escape
    6377
    6478                /* delete character */
    65     this->inputBuffer_->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
     79    this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar,      KeyCode::Delete);
    6680
    6781                /* cursor movement */
    68     this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
    69     this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
    70     this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
    71     this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
     82    this->inpbuf->registerListener(this, &ChatInputHandler::cursorRight,     KeyCode::Right);
     83    this->inpbuf->registerListener(this, &ChatInputHandler::cursorLeft,      KeyCode::Left);
     84    this->inpbuf->registerListener(this, &ChatInputHandler::cursorEnd,       KeyCode::End);
     85    this->inpbuf->registerListener(this, &ChatInputHandler::cursorHome,      KeyCode::Home);
    7286  }
    7387
    7488
    7589  /* activate, deactivate */
    76   void ChatInputHandler::activate()   /* TBI */
     90  void ChatInputHandler::activate()
    7791  {
    7892    /* start listening */
     93    COUT(0) << "chatinput activated." << std::endl;
     94    InputManager::getInstance().enterState("chatinput");
    7995  }
    8096
    81   void ChatInputHandler::deactivate()   /* TBI */
     97  void ChatInputHandler::deactivate()
    8298  {
    8399    /* stop listening */
     100    InputManager::getInstance().leaveState("chatinput");
    84101  }
    85102
     
    99116    /* actually do send what was input */
    100117    /* a) get the string out of the inputbuffer */
    101     String msgtosend = this->inpbuf->get();
     118    std::string msgtosend = this->inpbuf->get();
    102119
    103120    /* b) clear the input buffer */
    104     this->inpbuf->clear();
     121    if (this->inpbuf->getSize() > 0)
     122      this->inpbuf->clear();
    105123
    106124    /* c) send the chat via some call */
     
    108126
    109127    /* d) stop listening to input  */
     128    this->deactivate();
    110129  }
    111130
    112131  void ChatInputHandler::backspace()
    113132  {
    114     this->inputBuffer_->removeBehindCursor();
     133    this->inpbuf->removeBehindCursor();
    115134    //this->updateListeners<&ShellListener::inputChanged>();
    116135    //this->updateListeners<&ShellListener::cursorChanged>();
     
    119138  void ChatInputHandler::deleteChar()
    120139  {
    121     this->inputBuffer_->removeAtCursor();
     140    this->inpbuf->removeAtCursor();
    122141    //this->updateListeners<&ShellListener::inputChanged>();
    123142  }
     
    125144  void ChatInputHandler::cursorRight()
    126145  {
    127     this->inputBuffer_->increaseCursor();
     146    this->inpbuf->increaseCursor();
    128147    //this->updateListeners<&ShellListener::cursorChanged>();
    129148  }
     
    131150  void ChatInputHandler::cursorLeft()
    132151  {
    133     this->inputBuffer_->decreaseCursor();
     152    this->inpbuf->decreaseCursor();
    134153    //this->updateListeners<&ShellListener::cursorChanged>();
    135154  }
     
    137156  void ChatInputHandler::cursorEnd()
    138157  {
    139     this->inputBuffer_->setCursorToEnd();
     158    this->inpbuf->setCursorToEnd();
    140159    //this->updateListeners<&ShellListener::cursorChanged>();
    141160  }
     
    143162  void ChatInputHandler::cursorHome()
    144163  {
    145     this->inputBuffer_->setCursorToBegin();
     164    this->inpbuf->setCursorToBegin();
    146165    //this->updateListeners<&ShellListener::cursorChanged>();
    147166  }
     
    149168  void ChatInputHandler::exit()
    150169  {
    151     //if (this->inputBuffer_->getSize() > 0)
     170    //if (this->inpbuf->getSize() > 0)
    152171    //{
    153172      //this->clearInput();
  • code/branches/chat/src/orxonox/ChatInputHandler.h

    r6777 r6788  
    3939/* project includes */
    4040#include <OrxonoxPrereqs.h>
    41 #include <InputBuffer.h>
    42 #include <Host.h>
     41#include "core/input/InputBuffer.h"
     42#include "core/input/InputManager.h"
     43#include "core/input/InputState.h"
     44#include "../libraries/network/Host.h"
     45#include <core/BaseObject.h>
     46#include <PlayerManager.h>
     47#include <infos/PlayerInfo.h>
     48#include <network/ChatListener.h>
     49#include <core/PathConfig.h>
     50#include <util/Singleton.h>
    4351
    4452
     
    4654{
    4755  /* class to handle chat using an InputBuffer */
    48   class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>
     56  class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>,
     57    public OrxonoxClass
    4958  {
    5059    private:
     
    5463      InputBuffer *inpbuf;
    5564
    56       /* setup input buffer, the constructor calls this */
     65      /** input state */
     66      InputState *inputState;
     67
     68      /** setup input buffer, the constructor calls this */
    5769      void configureInputBuffer();
     70
     71      /* singleton pointer */
     72      static ChatInputHandler* singletonPtr_s;
    5873
    5974    public:
     
    6580      void activate();
    6681      void deactivate();
     82
     83      /* callbacks for input handler */
    6784
    6885      void inputChanged();
Note: See TracChangeset for help on using the changeset viewer.