Started work on nonmodal menus
parent
7033689d72
commit
bf5441f336
|
@ -246,8 +246,11 @@ set(minetest_SRCS
|
|||
clouds.cpp
|
||||
clientobject.cpp
|
||||
chat.cpp
|
||||
modalMenu.cpp
|
||||
nonmodalMenu.cpp
|
||||
guiMainMenu.cpp
|
||||
guiKeyChangeMenu.cpp
|
||||
guiMessage.cpp
|
||||
guiMessageMenu.cpp
|
||||
guiTextInputMenu.cpp
|
||||
guiInventoryMenu.cpp
|
||||
|
|
|
@ -37,6 +37,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
|||
#include "guiInventoryMenu.h"
|
||||
#include "guiTextInputMenu.h"
|
||||
#include "guiDeathScreen.h"
|
||||
#include "guiMessage.h"
|
||||
#include "tool.h"
|
||||
#include "guiChatConsole.h"
|
||||
#include "config.h"
|
||||
|
@ -2127,6 +2128,10 @@ void the_game(
|
|||
}
|
||||
else if(event.type == CE_KICKED)
|
||||
{
|
||||
/*GUIMessage *message =
|
||||
new GUIMessage(guienv, guiroot, -1, &g_menumgr,
|
||||
"You were kicked!");
|
||||
message->drop();*/
|
||||
g_gamecallback->disconnect();
|
||||
}
|
||||
else if(event.type == CE_DEATHSCREEN)
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -45,6 +51,7 @@ GUIDeathScreen::~GUIDeathScreen()
|
|||
{
|
||||
removeChildren();
|
||||
delete m_respawner;
|
||||
delete m_gamecallback;
|
||||
}
|
||||
|
||||
void GUIDeathScreen::removeChildren()
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "guiMessage.h"
|
||||
#include "debug.h"
|
||||
#include "serialization.h"
|
||||
#include <string>
|
||||
#include <IGUICheckBox.h>
|
||||
#include <IGUIEditBox.h>
|
||||
#include <IGUIButton.h>
|
||||
#include <IGUIStaticText.h>
|
||||
#include <IGUIFont.h>
|
||||
#include "gettext.h"
|
||||
|
||||
GUIMessage::GUIMessage(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr, std::string text
|
||||
):
|
||||
GUIModalMenu(env, parent, id, menumgr, false),
|
||||
m_screensize(1,1),
|
||||
m_text(text)
|
||||
{
|
||||
allowFocusRemoval(true);
|
||||
}
|
||||
|
||||
GUIMessage::~GUIMessage()
|
||||
{
|
||||
removeChildren();
|
||||
}
|
||||
|
||||
void GUIMessage::removeChildren()
|
||||
{
|
||||
const core::list<gui::IGUIElement*> &children = getChildren();
|
||||
core::list<gui::IGUIElement*> children_copy;
|
||||
for(core::list<gui::IGUIElement*>::ConstIterator
|
||||
i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
children_copy.push_back(*i);
|
||||
}
|
||||
for(core::list<gui::IGUIElement*>::Iterator
|
||||
i = children_copy.begin();
|
||||
i != children_copy.end(); i++)
|
||||
{
|
||||
(*i)->remove();
|
||||
}
|
||||
}
|
||||
|
||||
void GUIMessage::regenerateGui(v2u32 screensize)
|
||||
{
|
||||
m_screensize = screensize;
|
||||
|
||||
/*
|
||||
Remove stuff
|
||||
*/
|
||||
removeChildren();
|
||||
|
||||
/*
|
||||
Calculate new sizes and positions
|
||||
*/
|
||||
core::rect<s32> rect(
|
||||
screensize.X - screensize.X/4,
|
||||
0,
|
||||
screensize.X,
|
||||
screensize.Y/4
|
||||
);
|
||||
|
||||
DesiredRect = rect;
|
||||
recalculateAbsolutePosition(false);
|
||||
|
||||
v2s32 size = rect.getSize();
|
||||
const s32 btn_height = 30;
|
||||
const s32 btn_gap = 50;
|
||||
const s32 btn_gap_hor = 50;
|
||||
const s32 btn_num = 2;
|
||||
const s32 btn_width = 140;
|
||||
|
||||
/*
|
||||
Add stuff
|
||||
*/
|
||||
changeCtype("");
|
||||
{
|
||||
core::rect<s32> rect(0, 0, size.X, size.Y);
|
||||
rect = rect + v2s32(size.X/2-400/2, size.Y/2-50/2-25);
|
||||
gui::IGUIStaticText *e =
|
||||
Environment->addStaticText(wgettext(m_text.c_str()), rect, false,
|
||||
true, this, 256);
|
||||
e->setTextAlignment(gui::EGUIA_CENTER, gui::EGUIA_CENTER);
|
||||
}
|
||||
changeCtype("C");
|
||||
}
|
||||
|
||||
void GUIMessage::drawMenu()
|
||||
{
|
||||
gui::IGUISkin* skin = Environment->getSkin();
|
||||
if (!skin)
|
||||
{
|
||||
return;
|
||||
}
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
{
|
||||
video::SColor bgcolor(50,0,0,0);
|
||||
driver->draw2DRectangle(bgcolor, AbsoluteRect, &AbsoluteClippingRect);
|
||||
}
|
||||
|
||||
gui::IGUIElement::draw();
|
||||
}
|
||||
|
||||
bool GUIMessage::OnEvent(const SEvent& event)
|
||||
{
|
||||
/*if(event.EventType==EET_GUI_EVENT)
|
||||
{
|
||||
if(event.GUIEvent.EventType==gui::EGET_ELEMENT_FOCUS_LOST
|
||||
&& isVisible())
|
||||
{
|
||||
if(!canTakeFocus(event.GUIEvent.Element))
|
||||
{
|
||||
dstream<<"GUIDeathScreen: Not allowing focus change."
|
||||
<<std::endl;
|
||||
// Returning true disables focus change
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if(event.GUIEvent.EventType==gui::EGET_BUTTON_CLICKED)
|
||||
{
|
||||
switch(event.GUIEvent.Caller->getID())
|
||||
{
|
||||
case 257: // respawn
|
||||
respawn();
|
||||
quitMenu();
|
||||
return true;
|
||||
case 258: // disconnect
|
||||
m_gamecallback->disconnect();
|
||||
quitMenu();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Parent ? Parent->OnEvent(event) : false;*/
|
||||
return false;
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef GUIMESSAGE_HEADER
|
||||
#define GUIMESSAGE_HEADER
|
||||
|
||||
#include "common_irrlicht.h"
|
||||
#include "modalMenu.h"
|
||||
#include "utility.h"
|
||||
#include <string>
|
||||
//#include "guiPauseMenu.h"
|
||||
|
||||
class GUIMessage : public GUIModalMenu
|
||||
{
|
||||
public:
|
||||
GUIMessage(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr, std::string text);
|
||||
~GUIMessage();
|
||||
|
||||
void removeChildren();
|
||||
/*
|
||||
Remove and re-add (or reposition) stuff
|
||||
*/
|
||||
void regenerateGui(v2u32 screensize);
|
||||
|
||||
void drawMenu();
|
||||
|
||||
bool OnEvent(const SEvent& event);
|
||||
|
||||
void respawn();
|
||||
|
||||
private:
|
||||
v2u32 m_screensize;
|
||||
std::string m_text;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -0,0 +1,127 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "modalMenu.h"
|
||||
#include "common_irrlicht.h"
|
||||
|
||||
GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr):
|
||||
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
|
||||
core::rect<s32>(0,0,100,100))
|
||||
{
|
||||
//m_force_regenerate_gui = false;
|
||||
|
||||
m_menumgr = menumgr;
|
||||
m_allow_focus_removal = false;
|
||||
m_screensize_old = v2u32(0,0);
|
||||
|
||||
setVisible(true);
|
||||
Environment->setFocus(this);
|
||||
m_menumgr->createdMenu(this);
|
||||
}
|
||||
|
||||
GUIModalMenu::GUIModalMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr, bool modal):
|
||||
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
|
||||
core::rect<s32>(0,0,100,100))
|
||||
{
|
||||
//m_force_regenerate_gui = false;
|
||||
|
||||
m_menumgr = menumgr;
|
||||
m_allow_focus_removal = !modal;
|
||||
m_screensize_old = v2u32(0,0);
|
||||
|
||||
setVisible(true);
|
||||
if(modal)
|
||||
{
|
||||
Environment->setFocus(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
Environment->removeFocus(this);
|
||||
}
|
||||
m_menumgr->createdMenu(this);
|
||||
}
|
||||
|
||||
GUIModalMenu::~GUIModalMenu()
|
||||
{
|
||||
m_menumgr->deletingMenu(this);
|
||||
}
|
||||
|
||||
void GUIModalMenu::allowFocusRemoval(bool allow)
|
||||
{
|
||||
m_allow_focus_removal = allow;
|
||||
}
|
||||
|
||||
bool GUIModalMenu::canTakeFocus(gui::IGUIElement *e)
|
||||
{
|
||||
return (e && (e == this || isMyChild(e))) || m_allow_focus_removal;
|
||||
}
|
||||
|
||||
void GUIModalMenu::draw()
|
||||
{
|
||||
if(!IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
v2u32 screensize = driver->getScreenSize();
|
||||
if(screensize != m_screensize_old /*|| m_force_regenerate_gui*/)
|
||||
{
|
||||
m_screensize_old = screensize;
|
||||
regenerateGui(screensize);
|
||||
//m_force_regenerate_gui = false;
|
||||
}
|
||||
|
||||
drawMenu();
|
||||
}
|
||||
|
||||
void GUIModalMenu::quitMenu()
|
||||
{
|
||||
allowFocusRemoval(true);
|
||||
// This removes Environment's grab on us
|
||||
Environment->removeFocus(this);
|
||||
this->remove();
|
||||
}
|
||||
|
||||
void GUIModalMenu::removeChildren()
|
||||
{
|
||||
const core::list<gui::IGUIElement*> &children = getChildren();
|
||||
core::list<gui::IGUIElement*> children_copy;
|
||||
for(core::list<gui::IGUIElement*>::ConstIterator
|
||||
i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
children_copy.push_back(*i);
|
||||
}
|
||||
for(core::list<gui::IGUIElement*>::Iterator
|
||||
i = children_copy.begin();
|
||||
i != children_copy.end(); i++)
|
||||
{
|
||||
(*i)->remove();
|
||||
}
|
||||
}
|
|
@ -1,6 +1,12 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,51 +48,19 @@ class GUIModalMenu : public gui::IGUIElement
|
|||
public:
|
||||
GUIModalMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr):
|
||||
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
|
||||
core::rect<s32>(0,0,100,100))
|
||||
{
|
||||
//m_force_regenerate_gui = false;
|
||||
|
||||
m_menumgr = menumgr;
|
||||
m_allow_focus_removal = false;
|
||||
m_screensize_old = v2u32(0,0);
|
||||
IMenuManager *menumgr);
|
||||
|
||||
setVisible(true);
|
||||
Environment->setFocus(this);
|
||||
m_menumgr->createdMenu(this);
|
||||
}
|
||||
virtual ~GUIModalMenu()
|
||||
{
|
||||
m_menumgr->deletingMenu(this);
|
||||
}
|
||||
GUIModalMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
IMenuManager *menumgr, bool modal);
|
||||
|
||||
void allowFocusRemoval(bool allow)
|
||||
{
|
||||
m_allow_focus_removal = allow;
|
||||
}
|
||||
virtual ~GUIModalMenu();
|
||||
|
||||
bool canTakeFocus(gui::IGUIElement *e)
|
||||
{
|
||||
return (e && (e == this || isMyChild(e))) || m_allow_focus_removal;
|
||||
}
|
||||
void allowFocusRemoval(bool allow);
|
||||
|
||||
void draw()
|
||||
{
|
||||
if(!IsVisible)
|
||||
return;
|
||||
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
v2u32 screensize = driver->getScreenSize();
|
||||
if(screensize != m_screensize_old /*|| m_force_regenerate_gui*/)
|
||||
{
|
||||
m_screensize_old = screensize;
|
||||
regenerateGui(screensize);
|
||||
//m_force_regenerate_gui = false;
|
||||
}
|
||||
bool canTakeFocus(gui::IGUIElement *e);
|
||||
|
||||
drawMenu();
|
||||
}
|
||||
void draw();
|
||||
|
||||
/*
|
||||
This should be called when the menu wants to quit.
|
||||
|
@ -94,30 +68,9 @@ public:
|
|||
WARNING: THIS DEALLOCATES THE MENU FROM MEMORY. Return
|
||||
immediately if you call this from the menu itself.
|
||||
*/
|
||||
void quitMenu()
|
||||
{
|
||||
allowFocusRemoval(true);
|
||||
// This removes Environment's grab on us
|
||||
Environment->removeFocus(this);
|
||||
this->remove();
|
||||
}
|
||||
void quitMenu();
|
||||
|
||||
void removeChildren()
|
||||
{
|
||||
const core::list<gui::IGUIElement*> &children = getChildren();
|
||||
core::list<gui::IGUIElement*> children_copy;
|
||||
for(core::list<gui::IGUIElement*>::ConstIterator
|
||||
i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
children_copy.push_back(*i);
|
||||
}
|
||||
for(core::list<gui::IGUIElement*>::Iterator
|
||||
i = children_copy.begin();
|
||||
i != children_copy.end(); i++)
|
||||
{
|
||||
(*i)->remove();
|
||||
}
|
||||
}
|
||||
void removeChildren();
|
||||
|
||||
virtual void regenerateGui(v2u32 screensize) = 0;
|
||||
virtual void drawMenu() = 0;
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#include "nonmodalMenu.h"
|
||||
#include "common_irrlicht.h"
|
||||
|
||||
GUIMenu::GUIMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
INonModalMenuManager *menumgr):
|
||||
IGUIElement(gui::EGUIET_ELEMENT, env, parent, id,
|
||||
core::rect<s32>(0,0,100,100))
|
||||
{
|
||||
//m_force_regenerate_gui = false;
|
||||
|
||||
m_menumgr = menumgr;
|
||||
m_allow_focus_removal = false;
|
||||
m_screensize_old = v2u32(0,0);
|
||||
|
||||
setVisible(true);
|
||||
Environment->setFocus(this);
|
||||
m_menumgr->createdMenu(this);
|
||||
}
|
||||
|
||||
GUIMenu::~GUIMenu()
|
||||
{
|
||||
m_menumgr->deletingMenu(this);
|
||||
}
|
||||
|
||||
void GUIMenu::allowFocusRemoval(bool allow)
|
||||
{
|
||||
m_allow_focus_removal = allow;
|
||||
}
|
||||
|
||||
bool GUIMenu::canTakeFocus(gui::IGUIElement *e)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void GUIMenu::draw()
|
||||
{
|
||||
if(!IsVisible)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
video::IVideoDriver* driver = Environment->getVideoDriver();
|
||||
v2u32 screensize = driver->getScreenSize();
|
||||
if(screensize != m_screensize_old /*|| m_force_regenerate_gui*/)
|
||||
{
|
||||
m_screensize_old = screensize;
|
||||
regenerateGui(screensize);
|
||||
//m_force_regenerate_gui = false;
|
||||
}
|
||||
|
||||
drawMenu();
|
||||
}
|
||||
|
||||
void GUIMenu::quitMenu()
|
||||
{
|
||||
allowFocusRemoval(true);
|
||||
// This removes Environment's grab on us
|
||||
Environment->removeFocus(this);
|
||||
this->remove();
|
||||
}
|
||||
|
||||
void GUIMenu::removeChildren()
|
||||
{
|
||||
const core::list<gui::IGUIElement*> &children = getChildren();
|
||||
core::list<gui::IGUIElement*> children_copy;
|
||||
for(core::list<gui::IGUIElement*>::ConstIterator
|
||||
i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
children_copy.push_back(*i);
|
||||
}
|
||||
for(core::list<gui::IGUIElement*>::Iterator
|
||||
i = children_copy.begin();
|
||||
i != children_copy.end(); i++)
|
||||
{
|
||||
(*i)->remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,87 @@
|
|||
/*
|
||||
BlockPlanet
|
||||
Copyright (C) 2012 MiJyn, Joel Leclerc <mijyn@mail.com>
|
||||
Licensed under GPLv3
|
||||
|
||||
|
||||
Based on:
|
||||
Minetest-c55
|
||||
Copyright (C) 2010-2011 celeron55, Perttu Ahola <celeron55@gmail.com>
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(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
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License along
|
||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MENU_HEADER
|
||||
#define MENU_HEADER
|
||||
|
||||
#include "common_irrlicht.h"
|
||||
|
||||
class GUIMenu;
|
||||
|
||||
class INonModalMenuManager
|
||||
{
|
||||
public:
|
||||
// A GUIMenu calls these when this class is passed as a parameter
|
||||
virtual void createdMenu(GUIMenu *menu) = 0;
|
||||
virtual void deletingMenu(GUIMenu *menu) = 0;
|
||||
};
|
||||
|
||||
/*
|
||||
Remember to drop() the menu after creating, so that it can
|
||||
remove itself when it wants to.
|
||||
*/
|
||||
|
||||
class GUIMenu : public gui::IGUIElement
|
||||
{
|
||||
public:
|
||||
GUIMenu(gui::IGUIEnvironment* env,
|
||||
gui::IGUIElement* parent, s32 id,
|
||||
INonModalMenuManager *menumgr);
|
||||
|
||||
virtual ~GUIMenu();
|
||||
|
||||
void allowFocusRemoval(bool allow);
|
||||
|
||||
bool canTakeFocus(gui::IGUIElement *e);
|
||||
|
||||
void draw();
|
||||
|
||||
/*
|
||||
This should be called when the menu wants to quit.
|
||||
|
||||
WARNING: THIS DEALLOCATES THE MENU FROM MEMORY. Return
|
||||
immediately if you call this from the menu itself.
|
||||
*/
|
||||
void quitMenu();
|
||||
|
||||
void removeChildren();
|
||||
|
||||
virtual void regenerateGui(v2u32 screensize) = 0;
|
||||
virtual void drawMenu() = 0;
|
||||
virtual bool OnEvent(const SEvent& event) { return false; };
|
||||
|
||||
protected:
|
||||
//bool m_force_regenerate_gui;
|
||||
v2u32 m_screensize_old;
|
||||
private:
|
||||
INonModalMenuManager *m_menumgr;
|
||||
// This might be necessary to expose to the implementation if it
|
||||
// wants to launch other menus
|
||||
bool m_allow_focus_removal;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue