]> git.lizzy.rs Git - minetest.git/blob - src/gui/modalMenu.h
Update color of main menu clouds (#8172)
[minetest.git] / src / gui / modalMenu.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 #pragma once
21
22 #include "irrlichttypes_extrabloated.h"
23 #include "util/string.h"
24
25 class GUIModalMenu;
26
27 class IMenuManager
28 {
29 public:
30         // A GUIModalMenu calls these when this class is passed as a parameter
31         virtual void createdMenu(gui::IGUIElement *menu) = 0;
32         virtual void deletingMenu(gui::IGUIElement *menu) = 0;
33 };
34
35 // Remember to drop() the menu after creating, so that it can
36 // remove itself when it wants to.
37
38 class GUIModalMenu : public gui::IGUIElement
39 {
40 public:
41         GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id,
42                 IMenuManager *menumgr);
43         virtual ~GUIModalMenu();
44
45         void allowFocusRemoval(bool allow);
46         bool canTakeFocus(gui::IGUIElement *e);
47         void draw();
48         void quitMenu();
49         void removeChildren();
50
51         virtual void regenerateGui(v2u32 screensize) = 0;
52         virtual void drawMenu() = 0;
53         virtual bool preprocessEvent(const SEvent& event);
54         virtual bool OnEvent(const SEvent& event) { return false; };
55         virtual bool pausesGame() { return false; } // Used for pause menu
56 #ifdef __ANDROID__
57         virtual bool getAndroidUIInput() { return false; }
58         bool hasAndroidUIInput();
59 #endif
60
61 protected:
62         virtual std::wstring getLabelByID(s32 id) = 0;
63         virtual std::string getNameByID(s32 id) = 0;
64
65         v2s32 m_pointer;
66         v2s32 m_old_pointer;  // Mouse position after previous mouse event
67         v2u32 m_screensize_old;
68         float m_gui_scale;
69 #ifdef __ANDROID__
70         v2s32 m_down_pos;
71         std::string m_jni_field_name;
72 #endif
73 #ifdef HAVE_TOUCHSCREENGUI
74         bool m_touchscreen_visible = true;
75 #endif
76 private:
77         IMenuManager *m_menumgr;
78         // This might be necessary to expose to the implementation if it
79         // wants to launch other menus
80         bool m_allow_focus_removal = false;
81 };