[Orxonox-commit 2061] r6777 - code/branches/chat/src/orxonox
smerkli at orxonox.net
smerkli at orxonox.net
Mon Apr 26 14:48:12 CEST 2010
Author: smerkli
Date: 2010-04-26 14:48:12 +0200 (Mon, 26 Apr 2010)
New Revision: 6777
Modified:
code/branches/chat/src/orxonox/ChatInputHandler.cc
code/branches/chat/src/orxonox/ChatInputHandler.h
Log:
Brought implementation further, now starting to link into main program.
Modified: code/branches/chat/src/orxonox/ChatInputHandler.cc
===================================================================
--- code/branches/chat/src/orxonox/ChatInputHandler.cc 2010-04-26 12:37:12 UTC (rev 6776)
+++ code/branches/chat/src/orxonox/ChatInputHandler.cc 2010-04-26 12:48:12 UTC (rev 6777)
@@ -30,9 +30,15 @@
namespace orxonox
{
+ /* singleton */
+ ManageScopedSingleton( ChatInputHandler, ScopeID::Root, false );
+
/* constructor */
void ChatInputHandler::ChatInputHandler()
{
+ /* register the object */
+ RegisterObject(ChatInputHandler);
+
/* create necessary objects */
this->inpbuf = new InputBuffer();
@@ -65,6 +71,20 @@
this->inputBuffer_->registerListener(this, &ChatInputHandler::cursorHome, KeyCode::Home);
}
+
+ /* activate, deactivate */
+ void ChatInputHandler::activate() /* TBI */
+ {
+ /* start listening */
+ }
+
+ void ChatInputHandler::deactivate() /* TBI */
+ {
+ /* stop listening */
+ }
+
+
+
/* callbacks for InputBuffer */
void ChatInputHandler::inputChanged()
{
@@ -78,10 +98,13 @@
/* actually do send what was input */
/* a) get the string out of the inputbuffer */
+ String msgtosend = this->inpbuf->get();
/* b) clear the input buffer */
+ this->inpbuf->clear();
/* c) send the chat via some call */
+ Host::Chat( msgtosend );
/* d) stop listening to input */
}
Modified: code/branches/chat/src/orxonox/ChatInputHandler.h
===================================================================
--- code/branches/chat/src/orxonox/ChatInputHandler.h 2010-04-26 12:37:12 UTC (rev 6776)
+++ code/branches/chat/src/orxonox/ChatInputHandler.h 2010-04-26 12:48:12 UTC (rev 6777)
@@ -39,12 +39,13 @@
/* project includes */
#include <OrxonoxPrereqs.h>
#include <InputBuffer.h>
+#include <Host.h>
namespace orxonox
{
/* class to handle chat using an InputBuffer */
- class _OrxonoxExport ChatInputHandler
+ class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>
{
private:
/** Input buffer, to be used to catch input from the
@@ -58,7 +59,12 @@
public:
/** constructor */
ChatInputHandler();
+ friend class Singleton<ChatInputHandler>;
+ /* start listening, stop listening */
+ void activate();
+ void deactivate();
+
void inputChanged();
void addline();
void backspace();
More information about the Orxonox-commit
mailing list