aboutsummaryrefslogtreecommitdiff
path: root/src/guiInventoryMenu.cpp
diff options
context:
space:
mode:
authorPerttu Ahola <celeron55@gmail.com>2012-06-03 18:30:34 +0300
committerPerttu Ahola <celeron55@gmail.com>2012-06-03 22:31:02 +0300
commita09d86dd3cc3fd31404e6403cfc5d9c7020f944f (patch)
treeda48d36fbfc83eaba81fb8cf2ec4a74a56d33c51 /src/guiInventoryMenu.cpp
parent3ccb0f691b1ec45a2fb5b7f4a5fc0ae2db776d36 (diff)
downloadminetest-a09d86dd3cc3fd31404e6403cfc5d9c7020f944f.tar.gz
minetest-a09d86dd3cc3fd31404e6403cfc5d9c7020f944f.tar.bz2
minetest-a09d86dd3cc3fd31404e6403cfc5d9c7020f944f.zip
Update inventory menu from formspec on-the-fly
Diffstat (limited to 'src/guiInventoryMenu.cpp')
-rw-r--r--src/guiInventoryMenu.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/guiInventoryMenu.cpp b/src/guiInventoryMenu.cpp
index 492ea1c19..9898fd5aa 100644
--- a/src/guiInventoryMenu.cpp
+++ b/src/guiInventoryMenu.cpp
@@ -126,23 +126,24 @@ GUIInventoryMenu::GUIInventoryMenu(gui::IGUIEnvironment* env,
IMenuManager *menumgr,
InventoryManager *invmgr,
IGameDef *gamedef
- ):
+):
GUIModalMenu(env, parent, id, menumgr),
m_invmgr(invmgr),
- m_gamedef(gamedef)
+ m_gamedef(gamedef),
+ m_form_src(NULL),
+ m_selected_item(NULL),
+ m_selected_amount(0),
+ m_selected_dragging(false),
+ m_tooltip_element(NULL)
{
- m_selected_item = NULL;
- m_selected_amount = 0;
- m_selected_dragging = false;
- m_tooltip_element = NULL;
}
GUIInventoryMenu::~GUIInventoryMenu()
{
removeChildren();
- if(m_selected_item)
- delete m_selected_item;
+ delete m_selected_item;
+ delete m_form_src;
}
void GUIInventoryMenu::removeChildren()
@@ -244,8 +245,6 @@ void GUIInventoryMenu::regenerateGui(v2u32 screensize)
pos.X += stof(f.next(",")) * (float)spacing.X;
pos.Y += stof(f.next(";")) * (float)spacing.Y;
v2s32 geom;
- /*geom.X = imgsize.X + ((stoi(f.next(","))-1) * spacing.X);
- geom.Y = imgsize.Y + ((stoi(f.next(";"))-1) * spacing.Y);*/
geom.X = stof(f.next(",")) * (float)imgsize.X;
geom.Y = stof(f.next(";")) * (float)imgsize.Y;
std::string name = f.next("]");
@@ -430,6 +429,14 @@ void GUIInventoryMenu::drawSelectedItem()
void GUIInventoryMenu::drawMenu()
{
+ if(m_form_src){
+ std::string newform = m_form_src->getForm();
+ if(newform != m_formspec_string){
+ m_formspec_string = newform;
+ regenerateGui(m_screensize_old);
+ }
+ }
+
updateSelectedItem();
gui::IGUISkin* skin = Environment->getSkin();