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 stuff */ |
---|
84 | CEGUI::Window *input, *inputonly; |
---|
85 | CEGUI::Listbox *lb_history; |
---|
86 | |
---|
87 | public: |
---|
88 | /** constructor */ |
---|
89 | ChatInputHandler(); |
---|
90 | friend class Singleton<ChatInputHandler>; |
---|
91 | |
---|
92 | /* start listening, stop listening */ |
---|
93 | static void activate_static(); |
---|
94 | static void activate_small_static(); |
---|
95 | |
---|
96 | void incomingChat( const std::string& message, |
---|
97 | unsigned int senderID ); |
---|
98 | |
---|
99 | void activate( bool full ); |
---|
100 | void deactivate(); |
---|
101 | |
---|
102 | /* callbacks for input handler */ |
---|
103 | void inputChanged(); |
---|
104 | void addline(); |
---|
105 | void backspace(); |
---|
106 | void deleteChar(); |
---|
107 | void cursorRight(); |
---|
108 | void cursorLeft(); |
---|
109 | void cursorEnd(); |
---|
110 | void cursorHome(); |
---|
111 | void exit(); |
---|
112 | }; |
---|
113 | |
---|
114 | |
---|
115 | } |
---|
116 | |
---|
117 | |
---|
118 | #endif /*_ChatInputHandler_H__*/ |
---|