Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/chat/ChatInputHandler.h @ 11462

Last change on this file since 11462 was 11099, checked in by muemart, 9 years ago

Fix loads of doxygen warnings and other documentation issues

  • Property svn:eol-style set to native
File size: 4.0 KB
Line 
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
47namespace orxonox // tolua_export
48{ // tolua_export
49
50#if CEGUI_VERSION >= 0x000800
51  typedef CEGUI::Colour CEGUIColour;
52#else
53  typedef CEGUI::colour CEGUIColour;
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:
61      /** Input buffer, to be used to catch input from the
62       * keyboard
63       */
64      InputBuffer *inpbuf;
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
72      /** input state */
73      InputState *inputState;
74
75      /** setup input buffer, the constructor calls this */
76      void configureInputBuffer();
77
78      /** adjust display offset depending on cursor position */
79      void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
80
81      /** singleton pointer */
82      static ChatInputHandler* singletonPtr_s;
83
84      /** cegui window handles */
85      CEGUI::Window *input, *inputonly;
86
87      /** cegui handle for the history window */
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:
108      /** constructor */
109      ChatInputHandler();
110      ~ChatInputHandler();
111      friend class Singleton<ChatInputHandler>;
112
113      static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); }  // tolua_export
114
115      /** start listening */
116      static void activate_static();
117
118      /** stop listening */
119      static void activate_small_static();
120
121      /** \param message the message text
122       * \param name Name of the player who sent the message
123       *
124       * Deal with incoming chat (which means in our case: Add it to the
125       * history window of the full chat window)
126       */
127      virtual void incomingChat(const std::string& message, const std::string& name) override;
128
129      /** \param full true means show full chat window with history,
130            false means show only an input line
131       *
132       * Show the chat window and redirect the game's keyboard input
133       * into it.
134       */
135      void activate( bool full );
136
137      /** Deactivate the chat window, meaning: hide it. */
138      void deactivate();  // tolua_export
139
140  };  // tolua_export
141
142
143}  // tolua_export
144
145
146#endif /*_ChatInputHandler_H__*/
Note: See TracBrowser for help on using the repository browser.