2010-12-23 15:31:50 +02:00
|
|
|
/*
|
2013-02-24 18:40:43 +01:00
|
|
|
Minetest
|
2013-02-24 19:38:45 +01:00
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2010-12-23 15:31:50 +02:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
2012-06-05 17:56:56 +03:00
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2.1 of the License, or
|
2010-12-23 15:31:50 +02:00
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2012-06-05 17:56:56 +03:00
|
|
|
GNU Lesser General Public License for more details.
|
2010-12-23 15:31:50 +02:00
|
|
|
|
2012-06-05 17:56:56 +03:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
2010-12-23 15:31:50 +02:00
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2017-08-17 22:19:39 +02:00
|
|
|
#pragma once
|
2010-12-23 15:31:50 +02:00
|
|
|
|
2012-06-17 04:00:31 +03:00
|
|
|
#include "irrlichttypes_extrabloated.h"
|
2018-06-24 20:50:57 +01:00
|
|
|
#include "util/string.h"
|
2010-12-23 15:31:50 +02:00
|
|
|
|
2011-01-23 17:29:15 +02:00
|
|
|
class GUIModalMenu;
|
|
|
|
|
|
|
|
class IMenuManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// A GUIModalMenu calls these when this class is passed as a parameter
|
2016-02-27 15:51:09 -05:00
|
|
|
virtual void createdMenu(gui::IGUIElement *menu) = 0;
|
|
|
|
virtual void deletingMenu(gui::IGUIElement *menu) = 0;
|
2011-01-23 17:29:15 +02:00
|
|
|
};
|
|
|
|
|
2018-06-24 20:50:57 +01:00
|
|
|
// Remember to drop() the menu after creating, so that it can
|
|
|
|
// remove itself when it wants to.
|
2010-12-23 17:09:49 +02:00
|
|
|
|
2010-12-23 15:31:50 +02:00
|
|
|
class GUIModalMenu : public gui::IGUIElement
|
|
|
|
{
|
|
|
|
public:
|
2017-04-22 00:51:13 +02:00
|
|
|
GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id,
|
2018-06-24 20:50:57 +01:00
|
|
|
IMenuManager *menumgr);
|
|
|
|
virtual ~GUIModalMenu();
|
2017-04-22 00:51:13 +02:00
|
|
|
|
2018-06-24 20:50:57 +01:00
|
|
|
void allowFocusRemoval(bool allow);
|
|
|
|
bool canTakeFocus(gui::IGUIElement *e);
|
|
|
|
void draw();
|
|
|
|
void quitMenu();
|
|
|
|
void removeChildren();
|
2011-01-23 17:29:15 +02:00
|
|
|
|
2010-12-23 17:09:49 +02:00
|
|
|
virtual void regenerateGui(v2u32 screensize) = 0;
|
|
|
|
virtual void drawMenu() = 0;
|
2018-06-24 20:50:57 +01:00
|
|
|
virtual bool preprocessEvent(const SEvent& event);
|
2010-12-23 15:31:50 +02:00
|
|
|
virtual bool OnEvent(const SEvent& event) { return false; };
|
2018-06-24 20:50:57 +01:00
|
|
|
virtual bool pausesGame() { return false; } // Used for pause menu
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
virtual bool getAndroidUIInput() { return false; }
|
|
|
|
bool hasAndroidUIInput();
|
|
|
|
#endif
|
2011-04-05 00:24:47 +03:00
|
|
|
|
|
|
|
protected:
|
2018-06-24 20:50:57 +01:00
|
|
|
virtual std::wstring getLabelByID(s32 id) = 0;
|
|
|
|
virtual std::string getNameByID(s32 id) = 0;
|
|
|
|
|
|
|
|
v2s32 m_pointer;
|
|
|
|
v2s32 m_old_pointer; // Mouse position after previous mouse event
|
2012-03-13 08:50:03 +02:00
|
|
|
v2u32 m_screensize_old;
|
2018-11-26 21:55:24 +00:00
|
|
|
float m_gui_scale;
|
2018-06-24 20:50:57 +01:00
|
|
|
#ifdef __ANDROID__
|
|
|
|
v2s32 m_down_pos;
|
|
|
|
std::string m_jni_field_name;
|
|
|
|
#endif
|
|
|
|
#ifdef HAVE_TOUCHSCREENGUI
|
|
|
|
bool m_touchscreen_visible = true;
|
|
|
|
#endif
|
2010-12-23 15:31:50 +02:00
|
|
|
private:
|
2011-01-23 17:29:15 +02:00
|
|
|
IMenuManager *m_menumgr;
|
2010-12-23 17:09:49 +02:00
|
|
|
// This might be necessary to expose to the implementation if it
|
|
|
|
// wants to launch other menus
|
2017-06-18 19:55:15 +02:00
|
|
|
bool m_allow_focus_removal = false;
|
2010-12-23 15:31:50 +02:00
|
|
|
};
|