]> git.lizzy.rs Git - minetest.git/blob - src/guiChatConsole.h
Remove useless recalculation of bounding box (mapblock_mesh)
[minetest.git] / src / guiChatConsole.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef GUICHATCONSOLE_HEADER
21 #define GUICHATCONSOLE_HEADER
22
23 #include "irrlichttypes_extrabloated.h"
24 #include "chat.h"
25
26 class Client;
27
28 class GUIChatConsole : public gui::IGUIElement
29 {
30 public:
31         GUIChatConsole(gui::IGUIEnvironment* env,
32                         gui::IGUIElement* parent,
33                         s32 id,
34                         ChatBackend* backend,
35                         Client* client);
36         virtual ~GUIChatConsole();
37
38         // Open the console (height = desired fraction of screen size)
39         // This doesn't open immediately but initiates an animation.
40         // You should call isOpenInhibited() before this.
41         void openConsole(f32 height);
42
43         bool isOpen() const;
44
45         // Check if the console should not be opened at the moment
46         // This is to avoid reopening the console immediately after closing
47         bool isOpenInhibited() const;
48         // Close the console, equivalent to openConsole(0).
49         // This doesn't close immediately but initiates an animation.
50         void closeConsole();
51         // Close the console immediately, without animation.
52         void closeConsoleAtOnce();
53
54         // Return the desired height (fraction of screen size)
55         // Zero if the console is closed or getting closed
56         f32 getDesiredHeight() const;
57
58         // Change how the cursor looks
59         void setCursor(
60                 bool visible,
61                 bool blinking = false,
62                 f32 blink_speed = 1.0,
63                 f32 relative_height = 1.0);
64
65         // Irrlicht draw method
66         virtual void draw();
67
68         bool canTakeFocus(gui::IGUIElement* element) { return false; }
69
70         virtual bool OnEvent(const SEvent& event);
71
72 private:
73         void reformatConsole();
74         void recalculateConsolePosition();
75
76         // These methods are called by draw
77         void animate(u32 msec);
78         void drawBackground();
79         void drawText();
80         void drawPrompt();
81
82 private:
83         // pointer to the chat backend
84         ChatBackend* m_chat_backend;
85
86         // pointer to the client
87         Client* m_client;
88
89         // current screen size
90         v2u32 m_screensize;
91
92         // used to compute how much time passed since last animate()
93         u32 m_animate_time_old;
94
95         // should the console be opened or closed?
96         bool m_open;
97         // current console height [pixels]
98         s32 m_height;
99         // desired height [pixels]
100         f32 m_desired_height;
101         // desired height [screen height fraction]
102         f32 m_desired_height_fraction;
103         // console open/close animation speed [screen height fraction / second]
104         f32 m_height_speed;
105         // if nonzero, opening the console is inhibited [milliseconds]
106         u32 m_open_inhibited;
107
108         // cursor blink frame (16-bit value)
109         // cursor is off during [0,32767] and on during [32768,65535]
110         u32 m_cursor_blink;
111         // cursor blink speed [on/off toggles / second]
112         f32 m_cursor_blink_speed;
113         // cursor height [line height]
114         f32 m_cursor_height;
115
116         // background texture
117         video::ITexture* m_background;
118         // background color (including alpha)
119         video::SColor m_background_color;
120
121         // font
122         gui::IGUIFont* m_font;
123         v2u32 m_fontsize;
124 };
125
126
127 #endif
128