Orxonox  0.0.5 Codename: Arcturus
ChatInputHandler.h
Go to the documentation of this file.
1 /*
2  * ORXONOX - the hottest 3D action shooter ever to exist
3  * > www.orxonox.net <
4  *
5  *
6  * License notice:
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21  *
22  * Author:
23  * Sandro 'smerkli' Merkli
24  * Co-authors:
25  * ...
26  *
27  */
28 
29 #ifndef _ChatInputHandler_H__
30 #define _ChatInputHandler_H__
31 
32 #include "OrxonoxPrereqs.h"
33 
34 #include <string>
35 
36 #if CEGUI_VERSION >= 0x000800
37 # include <CEGUI/ForwardRefs.h>
38 # include <CEGUI/Colour.h>
39 #else
40 # include <CEGUIForwardRefs.h>
41 # include <CEGUIcolour.h>
42 #endif
43 
44 #include "util/Singleton.h"
45 #include "chat/ChatListener.h"
46 
47 namespace orxonox // tolua_export
48 { // tolua_export
49 
50 #if CEGUI_VERSION >= 0x000800
51  typedef CEGUI::Colour CEGUIColour;
52 #else
54 #endif
55 
56  /* class to handle chat using an InputBuffer */
57  class _OrxonoxExport ChatInputHandler // tolua_export
58  : public Singleton<ChatInputHandler>, public ChatListener
59  { // tolua_export
60  private:
65  int disp_offset, width;
66  bool fullchat;
67 
68  /* colors for nickname coloring */
69  static const int NumberOfColors = 10;
70  CEGUIColour text_colors[ NumberOfColors ];
71 
74 
76  void configureInputBuffer();
77 
79  void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
80 
83 
85  CEGUI::Window *input, *inputonly;
86 
88  CEGUI::Listbox *lb_history;
89 
90  /* methods to deal with colors */
91  void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
92  std::string name );
93 
94  void setupColors();
95 
96  /* callbacks for input handler */
97  void inputChanged();
98  void addline();
99  void backspace();
100  void deleteChar();
101  void cursorRight();
102  void cursorLeft();
103  void cursorEnd();
104  void cursorHome();
105  void exit();
106 
107  public:
110  ~ChatInputHandler();
112 
113  static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); } // tolua_export
114 
116  static void activate_static();
117 
119  static void activate_small_static();
120 
127  virtual void incomingChat(const std::string& message, const std::string& name) override;
128 
135  void activate( bool full );
136 
138  void deactivate(); // tolua_export
139 
140  }; // tolua_export
141 
142 
143 } // tolua_export
144 
145 
146 #endif /*_ChatInputHandler_H__*/
int width
Definition: ChatInputHandler.h:65
InputBuffer * inpbuf
Input buffer, to be used to catch input from the keyboard.
Definition: ChatInputHandler.h:64
static ChatInputHandler * singletonPtr_s
singleton pointer
Definition: ChatInputHandler.h:82
InputState * inputState
input state
Definition: ChatInputHandler.h:73
CEGUI::colour CEGUIColour
Definition: ChatInputHandler.h:53
::std::string string
Definition: gtest-port.h:756
static ChatInputHandler & getInstance(void)
Definition: ChatInputHandler.h:113
Output level, used for messages directed to the user (e.g. "Press any key to continue") ...
Definition: OutputDefinitions.h:89
Definition: ChatInputHandler.h:57
Ogre::ColourValue colour(const btVector3 &color, btScalar alpha)
Definition: OgreBulletUtils.h:41
Classes inheriting from this interface get a notification whenever a chat message was sent through Ch...
Definition: ChatListener.h:42
CEGUI::Listbox * lb_history
cegui handle for the history window
Definition: ChatInputHandler.h:88
Base for singleton classes.
Definition: Singleton.h:114
Die Wagnis Klasse hat die folgenden Aufgaben:
Definition: ApplicationPaths.cc:66
Shared library macros, enums, constants and forward declarations for the orxonox library ...
#define _OrxonoxExport
Definition: OrxonoxPrereqs.h:60
InputStates allow you to customise the input event targets at runtime.
Definition: InputState.h:83
Definition of the Singleton template that is used as base class for classes that allow only one insta...
CEGUI::Window * inputonly
Definition: ChatInputHandler.h:85
Definition: InputBuffer.h:76
bool fullchat
Definition: ChatInputHandler.h:66
static T & getInstance()
Returns a reference to the singleton instance.
Definition: Singleton.h:118