[Orxonox-commit 2163] r6879 - code/branches/chat2/src/orxonox

smerkli at orxonox.net smerkli at orxonox.net
Mon May 10 15:50:27 CEST 2010


Author: smerkli
Date: 2010-05-10 15:50:27 +0200 (Mon, 10 May 2010)
New Revision: 6879

Modified:
   code/branches/chat2/src/orxonox/ChatInputHandler.cc
   code/branches/chat2/src/orxonox/ChatInputHandler.h
Log:
bugfixes, performance improvements.

Modified: code/branches/chat2/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.cc	2010-05-10 13:38:16 UTC (rev 6878)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.cc	2010-05-10 13:50:27 UTC (rev 6879)
@@ -127,6 +127,8 @@
       GUIManager::getInstance().showGUI( "ChatBox" );
     else
       GUIManager::getInstance().showGUI( "ChatBox-inputonly" );
+
+    this->fullchat = full;
   }
 
   void ChatInputHandler::deactivate() 
@@ -173,21 +175,23 @@
     /* set the text */
     std::string assembled = "$ " + left + "|" + right;
 
-    /* adjust curser position - magic number 5 for font width */
-    sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 
-      cursorpos, assembled.length() );
-    this->input->setProperty( "Text", assembled.substr( disp_offset ) );
+    if( this->fullchat )
+    { 
+      /* adjust curser position - magic number 5 for font width */
+      sub_adjust_dispoffset( (this->input->getUnclippedInnerRect().getWidth()/6), 
+        cursorpos, assembled.length() );
+      this->input->setProperty( "Text", assembled.substr( disp_offset ) );
+    }
+    else
+    {
+      /* adjust curser position - magic number 5 for font width */
+      sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 
+        cursorpos, assembled.length() );
+      this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
+    }
 
     /* reset display offset */
     disp_offset = 0;
-
-    /* adjust curser position - magic number 5 for font width */
-    sub_adjust_dispoffset( (this->inputonly->getUnclippedInnerRect().getWidth()/6), 
-      cursorpos, assembled.length() );
-    this->inputonly->setProperty( "Text", assembled.substr( disp_offset) );
-
-    /* reset display offset */
-    disp_offset = 0;
   }
 
   void ChatInputHandler::addline()
@@ -209,7 +213,8 @@
     Host::Chat( msgtosend );
 
     /* d) stop listening to input  */
-    this->deactivate();
+    if( !this->fullchat )
+      this->deactivate();
 
     /* e) create item and add to history */
     CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( msgtosend );
@@ -239,6 +244,13 @@
   { this->inpbuf->setCursorToBegin(); }
 
   void ChatInputHandler::exit()
-  { }
+  {
+    /* b) clear the input buffer */
+    if (this->inpbuf->getSize() > 0)
+      this->inpbuf->clear();
 
+    /* d) stop listening to input  */
+    this->deactivate();
+  }
+
 }

Modified: code/branches/chat2/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.h	2010-05-10 13:38:16 UTC (rev 6878)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.h	2010-05-10 13:50:27 UTC (rev 6879)
@@ -62,6 +62,7 @@
        */
       InputBuffer *inpbuf;
       int disp_offset, width;
+      bool fullchat;
 
       /** input state */
       InputState *inputState;




More information about the Orxonox-commit mailing list