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.
22 #include "irrlichttypes_extrabloated.h"
23 #include "modalMenu.h"
29 class GUIChatConsole : public gui::IGUIElement
32 GUIChatConsole(gui::IGUIEnvironment* env,
33 gui::IGUIElement* parent,
37 IMenuManager* menumgr);
38 virtual ~GUIChatConsole();
40 // Open the console (height = desired fraction of screen size)
41 // This doesn't open immediately but initiates an animation.
42 // You should call isOpenInhibited() before this.
43 void openConsole(f32 scale);
47 // Check if the console should not be opened at the moment
48 // This is to avoid reopening the console immediately after closing
49 bool isOpenInhibited() const;
50 // Close the console, equivalent to openConsole(0).
51 // This doesn't close immediately but initiates an animation.
53 // Close the console immediately, without animation.
54 void closeConsoleAtOnce();
55 // Set whether to close the console after the user presses enter.
56 void setCloseOnEnter(bool close) { m_close_on_enter = close; }
58 // Return the desired height (fraction of screen size)
59 // Zero if the console is closed or getting closed
60 f32 getDesiredHeight() const;
62 // Replace actual line when adding the actual to the history (if there is any)
63 void replaceAndAddToHistory(std::wstring line);
65 // Change how the cursor looks
68 bool blinking = false,
69 f32 blink_speed = 1.0,
70 f32 relative_height = 1.0);
72 // Irrlicht draw method
75 bool canTakeFocus(gui::IGUIElement* element) { return false; }
77 virtual bool OnEvent(const SEvent& event);
79 virtual void setVisible(bool visible);
82 void reformatConsole();
83 void recalculateConsolePosition();
85 // These methods are called by draw
86 void animate(u32 msec);
87 void drawBackground();
92 ChatBackend* m_chat_backend;
94 IMenuManager* m_menumgr;
96 // current screen size
99 // used to compute how much time passed since last animate()
100 u64 m_animate_time_old;
102 // should the console be opened or closed?
104 // should it close after you press enter?
105 bool m_close_on_enter = false;
106 // current console height [pixels]
108 // desired height [pixels]
109 f32 m_desired_height = 0.0f;
110 // desired height [screen height fraction]
111 f32 m_desired_height_fraction = 0.0f;
112 // console open/close animation speed [screen height fraction / second]
113 f32 m_height_speed = 5.0f;
114 // if nonzero, opening the console is inhibited [milliseconds]
115 u32 m_open_inhibited = 0;
117 // cursor blink frame (16-bit value)
118 // cursor is off during [0,32767] and on during [32768,65535]
119 u32 m_cursor_blink = 0;
120 // cursor blink speed [on/off toggles / second]
121 f32 m_cursor_blink_speed = 0.0f;
122 // cursor height [line height]
123 f32 m_cursor_height = 0.0f;
125 // background texture
126 video::ITexture *m_background = nullptr;
127 // background color (including alpha)
128 video::SColor m_background_color = video::SColor(255, 0, 0, 0);
131 gui::IGUIFont *m_font = nullptr;