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 | |
---|
56 | |
---|
57 | namespace orxonox |
---|
58 | { |
---|
59 | /* class to handle chat using an InputBuffer */ |
---|
60 | class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>, |
---|
61 | public ChatListener |
---|
62 | { |
---|
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 | /** input state */ |
---|
72 | InputState *inputState; |
---|
73 | |
---|
74 | /** setup input buffer, the constructor calls this */ |
---|
75 | void configureInputBuffer(); |
---|
76 | |
---|
77 | /** adjust display offset depending on cursor position */ |
---|
78 | void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen ); |
---|
79 | |
---|
80 | /** singleton pointer */ |
---|
81 | static ChatInputHandler* singletonPtr_s; |
---|
82 | |
---|
83 | /** cegui window handles */ |
---|
84 | CEGUI::Window *input, *inputonly; |
---|
85 | |
---|
86 | /** cegui handle for the history window */ |
---|
87 | CEGUI::Listbox *lb_history; |
---|
88 | |
---|
89 | /* callbacks for input handler */ |
---|
90 | void inputChanged(); |
---|
91 | void addline(); |
---|
92 | void backspace(); |
---|
93 | void deleteChar(); |
---|
94 | void cursorRight(); |
---|
95 | void cursorLeft(); |
---|
96 | void cursorEnd(); |
---|
97 | void cursorHome(); |
---|
98 | void exit(); |
---|
99 | |
---|
100 | public: |
---|
101 | /** constructor */ |
---|
102 | ChatInputHandler(); |
---|
103 | friend class Singleton<ChatInputHandler>; |
---|
104 | |
---|
105 | /** start listening */ |
---|
106 | static void activate_static(); |
---|
107 | |
---|
108 | /** stop listening */ |
---|
109 | static void activate_small_static(); |
---|
110 | |
---|
111 | /** \param message the message text |
---|
112 | * \param senderID ID of the player who sent the message |
---|
113 | * |
---|
114 | * Deal with incoming chat (which means in our case: Add it to the |
---|
115 | * history window of the full chat window) |
---|
116 | */ |
---|
117 | void incomingChat( const std::string& message, |
---|
118 | unsigned int senderID ); |
---|
119 | |
---|
120 | /** \param full true means show full chat window with history, |
---|
121 | false means show only an input line |
---|
122 | * |
---|
123 | * Show the chat window and redirect the game's keyboard input |
---|
124 | * into it. |
---|
125 | */ |
---|
126 | void activate( bool full ); |
---|
127 | |
---|
128 | /** Deactivate the chat window, meaning: hide it. */ |
---|
129 | void deactivate(); |
---|
130 | |
---|
131 | }; |
---|
132 | |
---|
133 | |
---|
134 | } |
---|
135 | |
---|
136 | |
---|
137 | #endif /*_ChatInputHandler_H__*/ |
---|