Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/orxonox/ChatInputHandler.h @ 7408

Last change on this file since 7408 was 7163, checked in by dafrick, 14 years ago

Merged presentation3 branch into trunk.

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