Changeset 6885 for code/branches
- Timestamp:
- May 10, 2010, 4:24:18 PM (15 years ago)
- Location:
- code/branches/chat2/src/orxonox
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/chat2/src/orxonox/ChatInputHandler.cc
r6879 r6885 117 117 { ChatInputHandler::getInstance().activate( false ); } 118 118 119 120 121 119 122 void ChatInputHandler::activate( bool full ) 120 123 { … … 142 145 } 143 146 144 void ChatInputHandler::sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen ) 147 148 void ChatInputHandler::incomingChat(const std::string& message, 149 unsigned int senderID) 150 { 151 /* --> a) look up the actual name of the sender */ 152 std::string text; 153 154 if (senderID != CLIENTID_UNKNOWN) 155 { 156 std::string name = "unknown"; 157 PlayerInfo* player = PlayerManager::getInstance().getClient(senderID); 158 if (player) 159 name = player->getName(); 160 161 text = name + ": " + message; 162 } 163 else 164 text = message; 165 166 /* e) create item and add to history */ 167 CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text ); 168 this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 169 this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 170 171 /* f) make sure the history handles it */ 172 this->lb_history->handleUpdatedItemData(); 173 } 174 175 176 void ChatInputHandler::sub_adjust_dispoffset( int maxlen, 177 int cursorpos, 178 int inplen ) 145 179 { 146 180 /* already start offsetting 5 characters before end */ … … 213 247 Host::Chat( msgtosend ); 214 248 215 /* d) stop listening to input */249 /* d) stop listening to input - only if this is not fullchat */ 216 250 if( !this->fullchat ) 217 251 this->deactivate(); 218 252 219 /* e) create item and add to history */220 CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( msgtosend );221 this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );222 this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) );223 224 /* f) make sure the history handles it */225 this->lb_history->handleUpdatedItemData();226 253 } 227 254 -
code/branches/chat2/src/orxonox/ChatInputHandler.h
r6879 r6885 47 47 #include "core/input/InputState.h" 48 48 49 #include <network/ChatListener.h> 50 #include <PlayerManager.h> 51 #include <infos/PlayerInfo.h> 52 49 53 #include "../libraries/network/Host.h" 50 54 #include <util/Singleton.h> … … 55 59 /* class to handle chat using an InputBuffer */ 56 60 class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>, 57 public OrxonoxClass61 public ChatListener 58 62 { 59 63 private: … … 89 93 static void activate_static(); 90 94 static void activate_small_static(); 95 96 void incomingChat( const std::string& message, 97 unsigned int senderID ); 98 91 99 void activate( bool full ); 92 100 void deactivate();
Note: See TracChangeset
for help on using the changeset viewer.