3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef GUICHATCONSOLE_HEADER
21 #define GUICHATCONSOLE_HEADER
23 #include "irrlichttypes_extrabloated.h"
29 class GUIChatConsole : public gui::IGUIElement
32 GUIChatConsole(gui::IGUIEnvironment* env,
33 gui::IGUIElement* parent,
37 virtual ~GUIChatConsole();
39 // Open the console (height = desired fraction of screen size)
40 // This doesn't open immediately but initiates an animation.
41 // You should call isOpenInhibited() before this.
42 void openConsole(f32 height);
46 // Check if the console should not be opened at the moment
47 // This is to avoid reopening the console immediately after closing
48 bool isOpenInhibited() const;
49 // Close the console, equivalent to openConsole(0).
50 // This doesn't close immediately but initiates an animation.
52 // Close the console immediately, without animation.
53 void closeConsoleAtOnce();
54 // Set whether to close the console after the user presses enter.
55 void setCloseOnEnter(bool close) { m_close_on_enter = close; }
57 // Return the desired height (fraction of screen size)
58 // Zero if the console is closed or getting closed
59 f32 getDesiredHeight() const;
61 // Replace actual line when adding the actual to the history (if there is any)
62 void replaceAndAddToHistory(std::wstring line);
64 // Change how the cursor looks
67 bool blinking = false,
68 f32 blink_speed = 1.0,
69 f32 relative_height = 1.0);
71 // Irrlicht draw method
74 bool canTakeFocus(gui::IGUIElement* element) { return false; }
76 virtual bool OnEvent(const SEvent& event);
79 void reformatConsole();
80 void recalculateConsolePosition();
82 // These methods are called by draw
83 void animate(u32 msec);
84 void drawBackground();
89 // pointer to the chat backend
90 ChatBackend* m_chat_backend;
92 // pointer to the client
95 // current screen size
98 // used to compute how much time passed since last animate()
99 u32 m_animate_time_old;
101 // should the console be opened or closed?
103 // should it close after you press enter?
104 bool m_close_on_enter;
105 // current console height [pixels]
107 // desired height [pixels]
108 f32 m_desired_height;
109 // desired height [screen height fraction]
110 f32 m_desired_height_fraction;
111 // console open/close animation speed [screen height fraction / second]
113 // if nonzero, opening the console is inhibited [milliseconds]
114 u32 m_open_inhibited;
116 // cursor blink frame (16-bit value)
117 // cursor is off during [0,32767] and on during [32768,65535]
119 // cursor blink speed [on/off toggles / second]
120 f32 m_cursor_blink_speed;
121 // cursor height [line height]
124 // background texture
125 video::ITexture* m_background;
126 // background color (including alpha)
127 video::SColor m_background_color;
130 gui::IGUIFont* m_font;