[6776] | 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> |
---|
[6846] | 38 | #include <CEGUIForwardRefs.h> |
---|
[6776] | 39 | |
---|
| 40 | /* project includes */ |
---|
| 41 | #include <OrxonoxPrereqs.h> |
---|
[6791] | 42 | #include <core/BaseObject.h> |
---|
| 43 | #include <core/PathConfig.h> |
---|
| 44 | |
---|
[6788] | 45 | #include "core/input/InputBuffer.h" |
---|
| 46 | #include "core/input/InputManager.h" |
---|
| 47 | #include "core/input/InputState.h" |
---|
[6791] | 48 | |
---|
[6885] | 49 | #include <network/ChatListener.h> |
---|
| 50 | #include <PlayerManager.h> |
---|
| 51 | #include <infos/PlayerInfo.h> |
---|
| 52 | |
---|
[6788] | 53 | #include "../libraries/network/Host.h" |
---|
| 54 | #include <util/Singleton.h> |
---|
[6776] | 55 | |
---|
| 56 | |
---|
| 57 | namespace orxonox |
---|
| 58 | { |
---|
| 59 | /* class to handle chat using an InputBuffer */ |
---|
[6788] | 60 | class _OrxonoxExport ChatInputHandler : public Singleton<ChatInputHandler>, |
---|
[6885] | 61 | public ChatListener |
---|
[6776] | 62 | { |
---|
| 63 | private: |
---|
| 64 | /** Input buffer, to be used to catch input from the |
---|
| 65 | * keyboard |
---|
| 66 | */ |
---|
| 67 | InputBuffer *inpbuf; |
---|
[6876] | 68 | int disp_offset, width; |
---|
[6879] | 69 | bool fullchat; |
---|
[6776] | 70 | |
---|
[6788] | 71 | /** input state */ |
---|
| 72 | InputState *inputState; |
---|
| 73 | |
---|
| 74 | /** setup input buffer, the constructor calls this */ |
---|
[6776] | 75 | void configureInputBuffer(); |
---|
| 76 | |
---|
[6876] | 77 | /** adjust display offset depending on cursor position */ |
---|
| 78 | void sub_adjust_dispoffset( int maxlen, int cursorpos, int inplen ); |
---|
| 79 | |
---|
[6910] | 80 | /** singleton pointer */ |
---|
[6788] | 81 | static ChatInputHandler* singletonPtr_s; |
---|
| 82 | |
---|
[6910] | 83 | /** cegui window handles */ |
---|
[6870] | 84 | CEGUI::Window *input, *inputonly; |
---|
[6910] | 85 | |
---|
| 86 | /** cegui handle for the history window */ |
---|
[6846] | 87 | CEGUI::Listbox *lb_history; |
---|
| 88 | |
---|
[6910] | 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 | |
---|
[6776] | 100 | public: |
---|
| 101 | /** constructor */ |
---|
| 102 | ChatInputHandler(); |
---|
[6777] | 103 | friend class Singleton<ChatInputHandler>; |
---|
[6776] | 104 | |
---|
[6910] | 105 | /** start listening */ |
---|
[6791] | 106 | static void activate_static(); |
---|
[6910] | 107 | |
---|
| 108 | /** stop listening */ |
---|
[6870] | 109 | static void activate_small_static(); |
---|
[6885] | 110 | |
---|
[6910] | 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 | */ |
---|
[6885] | 117 | void incomingChat( const std::string& message, |
---|
| 118 | unsigned int senderID ); |
---|
| 119 | |
---|
[6910] | 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 | */ |
---|
[6870] | 126 | void activate( bool full ); |
---|
[6910] | 127 | |
---|
| 128 | /** Deactivate the chat window, meaning: hide it. */ |
---|
[6777] | 129 | void deactivate(); |
---|
| 130 | |
---|
[6776] | 131 | }; |
---|
| 132 | |
---|
| 133 | |
---|
| 134 | } |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | #endif /*_ChatInputHandler_H__*/ |
---|