Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/sound6/src/orxonox/ChatInputHandler.h @ 8301

Last change on this file since 8301 was 8000, checked in by rgrieder, 14 years ago

Destructors can sometimes be very useful for clean up ;)

  • Property svn:eol-style set to native
File size: 4.1 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/* std includes */
33#include <deque>
34#include <string>
35#include <fstream>
36#include <iostream>
37#include <cassert>
38#include <CEGUIForwardRefs.h>
39#include <CEGUIcolour.h>
40
41/* project includes */
42#include <OrxonoxPrereqs.h>
43#include <core/BaseObject.h>
44#include <core/PathConfig.h>
45
46#include "core/input/InputBuffer.h"
47#include "core/input/InputManager.h"
48#include "core/input/InputState.h"
49
50#include <network/ChatListener.h>
51#include <PlayerManager.h>
52#include <infos/PlayerInfo.h>
53
54#include "../libraries/network/Host.h"
55#include <util/Singleton.h>
56
57namespace orxonox // tolua_export
58{ // tolua_export
59  /* class to handle chat using an InputBuffer */
60  class _OrxonoxExport ChatInputHandler  // tolua_export
61    : public Singleton<ChatInputHandler>, public ChatListener
62  { // tolua_export
63    private:
64      /** Input buffer, to be used to catch input from the
65       * keyboard
66       */
67      InputBuffer *inpbuf;
68      int disp_offset, width;
69      bool fullchat;
70
71      /* colors for nickname coloring */
72      static const int NumberOfColors = 10;
73      CEGUI::colour text_colors[ NumberOfColors ];
74
75      /** input state */
76      InputState *inputState;
77
78      /** setup input buffer, the constructor calls this */
79      void configureInputBuffer();
80
81      /** adjust display offset depending on cursor position */
82      void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen );
83
84      /** singleton pointer */
85      static ChatInputHandler* singletonPtr_s;
86
87      /** cegui window handles */
88      CEGUI::Window *input, *inputonly;
89
90      /** cegui handle for the history window */
91      CEGUI::Listbox *lb_history;
92
93      /* methods to deal with colors */
94      void sub_setcolor( CEGUI::ListboxTextItem *tocolor,
95        std::string name );
96
97      void setupColors();
98
99      /* callbacks for input handler */
100      void inputChanged();
101      void addline();
102      void backspace();
103      void deleteChar();
104      void cursorRight();
105      void cursorLeft();
106      void cursorEnd();
107      void cursorHome();
108      void exit();
109
110    public:
111      /** constructor */
112      ChatInputHandler();
113      ~ChatInputHandler();
114      friend class Singleton<ChatInputHandler>;
115
116      static ChatInputHandler& getInstance(void) { return Singleton<ChatInputHandler>::getInstance(); }  // tolua_export
117
118      /** start listening */
119      static void activate_static();
120
121      /** stop listening */
122      static void activate_small_static();
123
124      /** \param message the message text
125       * \param senderID ID of the player who sent the message
126       *
127       * Deal with incoming chat (which means in our case: Add it to the
128       * history window of the full chat window)
129       */
130      void incomingChat( const std::string& message,
131        unsigned int senderID );
132
133      /** \param full true means show full chat window with history,
134            false means show only an input line
135       *
136       * Show the chat window and redirect the game's keyboard input
137       * into it.
138       */
139      void activate( bool full );
140
141      /** Deactivate the chat window, meaning: hide it. */
142      void deactivate();  // tolua_export
143
144  };  // tolua_export
145
146
147}  // tolua_export
148
149
150#endif /*_ChatInputHandler_H__*/
Note: See TracBrowser for help on using the repository browser.