- Timestamp:
- Jun 9, 2010, 9:32:58 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/presentation3/src/orxonox/ChatInputHandler.cc
r7049 r7127 40 40 #include <string> 41 41 42 namespace orxonox 42 namespace orxonox 43 43 { 44 44 /* singleton */ … … 48 48 SetConsoleCommandAlias( ChatInputHandler, activate_static, "startchat", 49 49 true ); 50 SetConsoleCommandAlias( ChatInputHandler, activate_small_static, 50 SetConsoleCommandAlias( ChatInputHandler, activate_small_static, 51 51 "startchat_small", true ); 52 52 … … 111 111 112 112 /* cast it to a listbox */ 113 lb_history = dynamic_cast<CEGUI::Listbox*>(history); 113 lb_history = dynamic_cast<CEGUI::Listbox*>(history); 114 114 115 115 /* assert wee */ … … 140 140 } 141 141 142 // blues 142 // blues 143 143 red = 0.5, green = 0.5, blue = 1; 144 144 for( ; i < NumberOfColors; ++i ) … … 171 171 } 172 172 173 void ChatInputHandler::deactivate() 173 void ChatInputHandler::deactivate() 174 174 { 175 175 /* stop listening */ … … 202 202 203 203 /* handle incoming chat */ 204 void ChatInputHandler::incomingChat(const std::string& message, 204 void ChatInputHandler::incomingChat(const std::string& message, 205 205 unsigned int senderID) 206 206 { … … 210 210 /* setup player name info */ 211 211 if (senderID != CLIENTID_UNKNOWN) 212 { 212 { 213 213 PlayerInfo* player = PlayerManager::getInstance().getClient(senderID); 214 214 if (player) … … 227 227 /* now add */ 228 228 this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 229 this->lb_history->ensureItemIsVisible( 229 this->lb_history->ensureItemIsVisible( 230 230 dynamic_cast<CEGUI::ListboxItem*>(toadd) ); 231 231 232 232 /* make sure the history handles it */ 233 233 this->lb_history->handleUpdatedItemData(); 234 } 234 } 235 235 236 236 237 237 /* sub for inputchanged */ 238 void ChatInputHandler::sub_adjust_dispoffset( int maxlen, 239 int cursorpos, 238 void ChatInputHandler::sub_adjust_dispoffset( int maxlen, 239 int cursorpos, 240 240 int inplen ) 241 241 { 242 242 /* already start offsetting 5 characters before end */ 243 243 if( cursorpos+5 > maxlen ) 244 { 244 { 245 245 /* always stay 5 characters ahead of end, looks better */ 246 246 ((disp_offset = cursorpos-maxlen+5) >= 0) ? 1 : disp_offset = 0; … … 249 249 (disp_offset > cursorpos ) ? disp_offset = 0 : 1; 250 250 } 251 251 252 252 /* make sure we don't die at substr */ 253 253 if( inplen <= disp_offset ) disp_offset = 0; … … 260 260 std::string raw = this->inpbuf->get(); 261 261 int cursorpos = this->inpbuf->getCursorPosition(); 262 262 263 263 /* get string before cursor */ 264 264 std::string left = raw.substr( 0, cursorpos ); … … 268 268 if( raw.length() >= left.length()+1 ) 269 269 right = raw.substr( cursorpos ); 270 270 271 271 /* set the text */ 272 272 std::string assembled = "$ " + left + "|" + right; 273 273 274 274 if( this->fullchat ) 275 { 275 { 276 276 /* adjust curser position - magic number 5 for font width */ 277 sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 277 sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 278 278 cursorpos, assembled.length() ); 279 279 this->input->setProperty( "Text", assembled.substr( disp_offset ) ); … … 282 282 { 283 283 /* adjust curser position - magic number 5 for font width */ 284 sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 284 sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 285 285 cursorpos, assembled.length() ); 286 286 this->inputonly->setProperty( "Text", assembled.substr( disp_offset) ); … … 323 323 void ChatInputHandler::cursorRight() 324 324 { this->inpbuf->increaseCursor(); } 325 325 326 326 void ChatInputHandler::cursorLeft() 327 327 { this->inpbuf->decreaseCursor(); } 328 328 329 329 void ChatInputHandler::cursorEnd() 330 330 { this->inpbuf->setCursorToEnd(); }
Note: See TracChangeset
for help on using the changeset viewer.