[12177] | 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 | * Felix Schulthess |
---|
| 24 | * Co-authors: |
---|
| 25 | * Fabian 'x3n' Landau |
---|
| 26 | * |
---|
| 27 | */ |
---|
| 28 | |
---|
| 29 | #ifndef _InGameConsole_H__ |
---|
| 30 | #define _InGameConsole_H__ |
---|
| 31 | |
---|
| 32 | |
---|
| 33 | #include "OrxonoxPrereqs.h" |
---|
| 34 | |
---|
| 35 | #include <string> |
---|
| 36 | |
---|
| 37 | #include "util/OgreForwardRefs.h" |
---|
| 38 | #include "util/Singleton.h" |
---|
| 39 | #include "core/WindowEventListener.h" |
---|
| 40 | #include "core/command/Shell.h" |
---|
| 41 | #include "core/UpdateListener.h" |
---|
| 42 | |
---|
| 43 | namespace orxonox |
---|
| 44 | { |
---|
| 45 | class _OrxonoxExport InGameConsole : public Singleton<InGameConsole>, public ShellListener, public WindowEventListener, public UpdateListener |
---|
| 46 | { |
---|
| 47 | friend class Singleton<InGameConsole>; |
---|
| 48 | public: // functions |
---|
| 49 | InGameConsole(); |
---|
| 50 | ~InGameConsole(); |
---|
| 51 | |
---|
| 52 | void initialise(); |
---|
| 53 | void setConfigValues(); |
---|
| 54 | |
---|
| 55 | virtual void preUpdate(const Clock& time) override; |
---|
| 56 | virtual void postUpdate(const Clock& time) override { /*no action*/ } |
---|
| 57 | |
---|
| 58 | static void openConsole(); |
---|
| 59 | static void closeConsole(); |
---|
| 60 | |
---|
| 61 | private: // functions |
---|
| 62 | InGameConsole(const InGameConsole& other); |
---|
| 63 | |
---|
| 64 | void activate(); |
---|
| 65 | void deactivate(); |
---|
| 66 | |
---|
| 67 | virtual void linesChanged() override; |
---|
| 68 | virtual void lineAdded() override; |
---|
| 69 | virtual void inputChanged() override; |
---|
| 70 | virtual void cursorChanged() override; |
---|
| 71 | virtual void executed() override; |
---|
| 72 | virtual void exit() override; |
---|
| 73 | |
---|
| 74 | void shiftLines(); |
---|
| 75 | void colourLine(Shell::LineType type, int index); |
---|
| 76 | void setCursorPosition(unsigned int pos); |
---|
| 77 | void print(const std::string& text, Shell::LineType type, int index, bool alwaysShift = false); |
---|
| 78 | |
---|
| 79 | virtual void windowResized(unsigned int newWidth, unsigned int newHeight) override; |
---|
| 80 | |
---|
| 81 | // config value related |
---|
| 82 | void bHidesAllInputChanged(); |
---|
| 83 | |
---|
| 84 | private: // variables |
---|
| 85 | Shell* shell_; |
---|
| 86 | bool bActive_; |
---|
| 87 | int windowW_; |
---|
| 88 | int windowH_; |
---|
| 89 | int desiredTextWidth_; |
---|
| 90 | unsigned int maxCharsPerLine_; |
---|
| 91 | unsigned int numLinesShifted_; |
---|
| 92 | int scroll_; |
---|
| 93 | float cursor_; |
---|
| 94 | unsigned int inputWindowStart_; |
---|
| 95 | bool bShowCursor_; |
---|
| 96 | std::string displayedText_; |
---|
| 97 | Ogre::Overlay* consoleOverlay_; |
---|
| 98 | Ogre::OverlayContainer* consoleOverlayContainer_; |
---|
| 99 | Ogre::PanelOverlayElement* consoleOverlayNoise_; |
---|
| 100 | Ogre::TextAreaOverlayElement* consoleOverlayCursor_; |
---|
| 101 | Ogre::BorderPanelOverlayElement* consoleOverlayBorder_; |
---|
| 102 | Ogre::TextAreaOverlayElement** consoleOverlayTextAreas_; |
---|
| 103 | |
---|
| 104 | // input related |
---|
| 105 | InputState* inputState_; |
---|
| 106 | |
---|
| 107 | // config values |
---|
| 108 | float relativeWidth; |
---|
| 109 | float relativeHeight; |
---|
| 110 | float blinkTime; |
---|
| 111 | float scrollSpeed_; |
---|
| 112 | float noiseSize_; |
---|
| 113 | char cursorSymbol_; |
---|
| 114 | bool bHidesAllInput_; |
---|
| 115 | |
---|
| 116 | static InGameConsole* singletonPtr_s; |
---|
| 117 | }; |
---|
| 118 | } |
---|
| 119 | |
---|
| 120 | #endif /* _InGameConsole_H__ */ |
---|