2010-12-23 05:31:50 -08:00
|
|
|
/*
|
2013-02-24 09:40:43 -08:00
|
|
|
Minetest
|
2013-02-24 10:38:45 -08:00
|
|
|
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
|
2010-12-23 05:31:50 -08:00
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
2012-06-05 07:56:56 -07:00
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
2020-08-28 09:27:49 -07:00
|
|
|
the Free Software Foundation; either version 3.0 of the License, or
|
2010-12-23 05:31:50 -08: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 07:56:56 -07:00
|
|
|
GNU Lesser General Public License for more details.
|
2010-12-23 05:31:50 -08:00
|
|
|
|
2012-06-05 07:56:56 -07:00
|
|
|
You should have received a copy of the GNU Lesser General Public License along
|
2010-12-23 05:31:50 -08: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 13:19:39 -07:00
|
|
|
#pragma once
|
2010-12-23 05:31:50 -08:00
|
|
|
|
2012-06-16 18:00:31 -07:00
|
|
|
#include "irrlichttypes_extrabloated.h"
|
2018-06-24 12:50:57 -07:00
|
|
|
#include "util/string.h"
|
2010-12-23 05:31:50 -08:00
|
|
|
|
2011-01-23 07:29:15 -08:00
|
|
|
class GUIModalMenu;
|
|
|
|
|
|
|
|
class IMenuManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
// A GUIModalMenu calls these when this class is passed as a parameter
|
2016-02-27 12:51:09 -08:00
|
|
|
virtual void createdMenu(gui::IGUIElement *menu) = 0;
|
|
|
|
virtual void deletingMenu(gui::IGUIElement *menu) = 0;
|
2011-01-23 07:29:15 -08:00
|
|
|
};
|
|
|
|
|
2018-06-24 12:50:57 -07:00
|
|
|
// Remember to drop() the menu after creating, so that it can
|
|
|
|
// remove itself when it wants to.
|
2010-12-23 07:09:49 -08:00
|
|
|
|
2010-12-23 05:31:50 -08:00
|
|
|
class GUIModalMenu : public gui::IGUIElement
|
|
|
|
{
|
|
|
|
public:
|
2017-04-21 15:51:13 -07:00
|
|
|
GUIModalMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id,
|
2018-06-24 12:50:57 -07:00
|
|
|
IMenuManager *menumgr);
|
|
|
|
virtual ~GUIModalMenu();
|
2017-04-21 15:51:13 -07:00
|
|
|
|
2018-06-24 12:50:57 -07:00
|
|
|
void allowFocusRemoval(bool allow);
|
|
|
|
bool canTakeFocus(gui::IGUIElement *e);
|
|
|
|
void draw();
|
|
|
|
void quitMenu();
|
|
|
|
void removeChildren();
|
2011-01-23 07:29:15 -08:00
|
|
|
|
2010-12-23 07:09:49 -08:00
|
|
|
virtual void regenerateGui(v2u32 screensize) = 0;
|
|
|
|
virtual void drawMenu() = 0;
|
2018-06-24 12:50:57 -07:00
|
|
|
virtual bool preprocessEvent(const SEvent& event);
|
2010-12-23 05:31:50 -08:00
|
|
|
virtual bool OnEvent(const SEvent& event) { return false; };
|
2018-06-24 12:50:57 -07:00
|
|
|
virtual bool pausesGame() { return false; } // Used for pause menu
|
|
|
|
#ifdef __ANDROID__
|
|
|
|
virtual bool getAndroidUIInput() { return false; }
|
|
|
|
bool hasAndroidUIInput();
|
|
|
|
#endif
|
2011-04-04 14:24:47 -07:00
|
|
|
|
|
|
|
protected:
|
2018-06-24 12:50:57 -07: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-12 23:50:03 -07:00
|
|
|
v2u32 m_screensize_old;
|
2018-11-26 13:55:24 -08:00
|
|
|
float m_gui_scale;
|
2018-06-24 12:50:57 -07: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 05:31:50 -08:00
|
|
|
private:
|
2011-01-23 07:29:15 -08:00
|
|
|
IMenuManager *m_menumgr;
|
2010-12-23 07:09:49 -08:00
|
|
|
// This might be necessary to expose to the implementation if it
|
|
|
|
// wants to launch other menus
|
2017-06-18 10:55:15 -07:00
|
|
|
bool m_allow_focus_removal = false;
|
2010-12-23 05:31:50 -08:00
|
|
|
};
|