Changeset 6788
- Timestamp:
- Apr 26, 2010, 4:09:23 PM (15 years ago)
- Location:
- code/branches/chat/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat/src/orxonox/CMakeLists.txt
r6698 r6788 33 33 Radar.cc 34 34 ChatHistory.cc 35 ChatInputHandler.cc 35 36 COMPILATION_BEGIN SceneCompilation.cc 36 37 CameraManager.cc -
code/branches/chat/src/orxonox/ChatInputHandler.cc
r6777 r6788 28 28 29 29 #include "ChatInputHandler.h" 30 #include <core/ScopedSingletonManager.h> 31 #include "core/ConsoleCommand.h" 32 #include "core/CoreIncludes.h" 33 #include <string> 30 34 31 35 namespace orxonox 32 36 { 33 37 /* singleton */ 34 ManageScopedSingleton( ChatInputHandler, ScopeID:: Root, false );38 ManageScopedSingleton( ChatInputHandler, ScopeID::Graphics, false ); 35 39 36 40 /* constructor */ 37 voidChatInputHandler::ChatInputHandler()41 ChatInputHandler::ChatInputHandler() 38 42 { 39 43 /* register the object */ 40 44 RegisterObject(ChatInputHandler); 41 45 46 //COUT(0) << "Singleton registered for ChatInputHandler." << std::endl; 47 42 48 /* create necessary objects */ 43 49 this->inpbuf = new InputBuffer(); 44 50 51 /* configure the input buffer */ 45 52 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); 46 60 } 47 61 … … 49 63 { 50 64 /* input has changed */ 51 this->inp utBuffer_->registerListener(this, &ChatInputHandler::inputChanged, true);65 this->inpbuf->registerListener(this, &ChatInputHandler::inputChanged, true); 52 66 53 67 /* add a line */ 54 this->inp utBuffer_->registerListener(this, &ChatInputHandler::addline, '\r', false);55 this->inp utBuffer_->registerListener(this, &ChatInputHandler::addline, '\n', false);68 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\r', false); 69 this->inpbuf->registerListener(this, &ChatInputHandler::addline, '\n', false); 56 70 57 71 /* backspace */ 58 this->inp utBuffer_->registerListener(this, &ChatInputHandler::backspace, '\b', true);59 this->inp utBuffer_->registerListener(this, &ChatInputHandler::backspace, '\177', true);72 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\b', true); 73 this->inpbuf->registerListener(this, &ChatInputHandler::backspace, '\177', true); 60 74 61 75 /* exit the chatinputhandler thingy (tbd) */ 62 this->inp utBuffer_->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape76 this->inpbuf->registerListener(this, &ChatInputHandler::exit, '\033', true); // escape 63 77 64 78 /* delete character */ 65 this->inp utBuffer_->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete);79 this->inpbuf->registerListener(this, &ChatInputHandler::deleteChar, KeyCode::Delete); 66 80 67 81 /* cursor movement */ 68 this->inp utBuffer_->registerListener(this, &ChatInputHandler::cursorRight, KeyCode::Right);69 this->inp utBuffer_->registerListener(this, &ChatInputHandler::cursorLeft, KeyCode::Left);70 this->inp utBuffer_->registerListener(this, &ChatInputHandler::cursorEnd, KeyCode::End);71 this->inp utBuffer_->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); 72 86 } 73 87 74 88 75 89 /* activate, deactivate */ 76 void ChatInputHandler::activate() /* TBI */90 void ChatInputHandler::activate() 77 91 { 78 92 /* start listening */ 93 COUT(0) << "chatinput activated." << std::endl; 94 InputManager::getInstance().enterState("chatinput"); 79 95 } 80 96 81 void ChatInputHandler::deactivate() /* TBI */97 void ChatInputHandler::deactivate() 82 98 { 83 99 /* stop listening */ 100 InputManager::getInstance().leaveState("chatinput"); 84 101 } 85 102 … … 99 116 /* actually do send what was input */ 100 117 /* a) get the string out of the inputbuffer */ 101 String msgtosend = this->inpbuf->get();118 std::string msgtosend = this->inpbuf->get(); 102 119 103 120 /* b) clear the input buffer */ 104 this->inpbuf->clear(); 121 if (this->inpbuf->getSize() > 0) 122 this->inpbuf->clear(); 105 123 106 124 /* c) send the chat via some call */ … … 108 126 109 127 /* d) stop listening to input */ 128 this->deactivate(); 110 129 } 111 130 112 131 void ChatInputHandler::backspace() 113 132 { 114 this->inp utBuffer_->removeBehindCursor();133 this->inpbuf->removeBehindCursor(); 115 134 //this->updateListeners<&ShellListener::inputChanged>(); 116 135 //this->updateListeners<&ShellListener::cursorChanged>(); … … 119 138 void ChatInputHandler::deleteChar() 120 139 { 121 this->inp utBuffer_->removeAtCursor();140 this->inpbuf->removeAtCursor(); 122 141 //this->updateListeners<&ShellListener::inputChanged>(); 123 142 } … … 125 144 void ChatInputHandler::cursorRight() 126 145 { 127 this->inp utBuffer_->increaseCursor();146 this->inpbuf->increaseCursor(); 128 147 //this->updateListeners<&ShellListener::cursorChanged>(); 129 148 } … … 131 150 void ChatInputHandler::cursorLeft() 132 151 { 133 this->inp utBuffer_->decreaseCursor();152 this->inpbuf->decreaseCursor(); 134 153 //this->updateListeners<&ShellListener::cursorChanged>(); 135 154 } … … 137 156 void ChatInputHandler::cursorEnd() 138 157 { 139 this->inp utBuffer_->setCursorToEnd();158 this->inpbuf->setCursorToEnd(); 140 159 //this->updateListeners<&ShellListener::cursorChanged>(); 141 160 } … … 143 162 void ChatInputHandler::cursorHome() 144 163 { 145 this->inp utBuffer_->setCursorToBegin();164 this->inpbuf->setCursorToBegin(); 146 165 //this->updateListeners<&ShellListener::cursorChanged>(); 147 166 } … … 149 168 void ChatInputHandler::exit() 150 169 { 151 //if (this->inp utBuffer_->getSize() > 0)170 //if (this->inpbuf->getSize() > 0) 152 171 //{ 153 172 //this->clearInput(); -
code/branches/chat/src/orxonox/ChatInputHandler.h
r6777 r6788 39 39 /* project includes */ 40 40 #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> 43 51 44 52 … … 46 54 { 47 55 /* class to handle chat using an InputBuffer */ 48 class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler> 56 class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>, 57 public OrxonoxClass 49 58 { 50 59 private: … … 54 63 InputBuffer *inpbuf; 55 64 56 /* setup input buffer, the constructor calls this */ 65 /** input state */ 66 InputState *inputState; 67 68 /** setup input buffer, the constructor calls this */ 57 69 void configureInputBuffer(); 70 71 /* singleton pointer */ 72 static ChatInputHandler* singletonPtr_s; 58 73 59 74 public: … … 65 80 void activate(); 66 81 void deactivate(); 82 83 /* callbacks for input handler */ 67 84 68 85 void inputChanged();
Note: See TracChangeset
for help on using the changeset viewer.