[Orxonox-commit 2169] r6885 - code/branches/chat2/src/orxonox
smerkli at orxonox.net
smerkli at orxonox.net
Mon May 10 16:24:18 CEST 2010
Author: smerkli
Date: 2010-05-10 16:24:18 +0200 (Mon, 10 May 2010)
New Revision: 6885
Modified:
code/branches/chat2/src/orxonox/ChatInputHandler.cc
code/branches/chat2/src/orxonox/ChatInputHandler.h
Log:
Strage delete-button bug persists.
Modified: code/branches/chat2/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.cc 2010-05-10 14:23:29 UTC (rev 6884)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.cc 2010-05-10 14:24:18 UTC (rev 6885)
@@ -116,6 +116,9 @@
void ChatInputHandler::activate_small_static()
{ ChatInputHandler::getInstance().activate( false ); }
+
+
+
void ChatInputHandler::activate( bool full )
{
/* start listening */
@@ -141,8 +144,39 @@
GUIManager::getInstance().hideGUI( "ChatBox-inputonly" );
}
- void ChatInputHandler::sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen )
+
+ void ChatInputHandler::incomingChat(const std::string& message,
+ unsigned int senderID)
{
+ /* --> a) look up the actual name of the sender */
+ std::string text;
+
+ if (senderID != CLIENTID_UNKNOWN)
+ {
+ std::string name = "unknown";
+ PlayerInfo* player = PlayerManager::getInstance().getClient(senderID);
+ if (player)
+ name = player->getName();
+
+ text = name + ": " + message;
+ }
+ else
+ text = message;
+
+ /* e) create item and add to history */
+ CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( text );
+ this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+ this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
+
+ /* f) make sure the history handles it */
+ this->lb_history->handleUpdatedItemData();
+ }
+
+
+ void ChatInputHandler::sub_adjust_dispoffset( int maxlen,
+ int cursorpos,
+ int inplen )
+ {
/* already start offsetting 5 characters before end */
if( cursorpos+5 > maxlen )
{
@@ -212,17 +246,10 @@
/* c) send the chat via some call */
Host::Chat( msgtosend );
- /* d) stop listening to input */
+ /* d) stop listening to input - only if this is not fullchat */
if( !this->fullchat )
this->deactivate();
- /* e) create item and add to history */
- CEGUI::ListboxTextItem *toadd = new CEGUI::ListboxTextItem( msgtosend );
- this->lb_history->addItem( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
- this->lb_history->ensureItemIsVisible( dynamic_cast<CEGUI::ListboxItem*>(toadd) );
-
- /* f) make sure the history handles it */
- this->lb_history->handleUpdatedItemData();
}
void ChatInputHandler::backspace()
Modified: code/branches/chat2/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/chat2/src/orxonox/ChatInputHandler.h 2010-05-10 14:23:29 UTC (rev 6884)
+++ code/branches/chat2/src/orxonox/ChatInputHandler.h 2010-05-10 14:24:18 UTC (rev 6885)
@@ -46,6 +46,10 @@
#include "core/input/InputManager.h"
#include "core/input/InputState.h"
+#include <network/ChatListener.h>
+#include <PlayerManager.h>
+#include <infos/PlayerInfo.h>
+
#include "../libraries/network/Host.h"
#include <util/Singleton.h>
@@ -54,7 +58,7 @@
{
/* class to handle chat using an InputBuffer */
class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>,
- public OrxonoxClass
+ public ChatListener
{
private:
/** Input buffer, to be used to catch input from the
@@ -88,6 +92,10 @@
/* start listening, stop listening */
static void activate_static();
static void activate_small_static();
+
+ void incomingChat( const std::string& message,
+ unsigned int senderID );
+
void activate( bool full );
void deactivate();
More information about the Orxonox-commit
mailing list