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