1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Update inventory menu from formspec on-the-fly

This commit is contained in:
Perttu Ahola 2012-06-03 18:30:34 +03:00
parent 3ccb0f691b
commit a09d86dd3c
3 changed files with 55 additions and 10 deletions

View file

@ -132,6 +132,28 @@ private:
Client *m_client;
};
/* Form update callback */
class NodeMetadataFormSource: public IFormSource
{
public:
NodeMetadataFormSource(ClientMap *map, v3s16 p):
m_map(map),
m_p(p)
{
}
std::string getForm()
{
NodeMetadata *meta = m_map->getNodeMetadata(m_p);
if(!meta)
return "";
return meta->getString("formspec");
}
ClientMap *m_map;
v3s16 m_p;
};
/*
Hotbar draw routine
*/
@ -2348,6 +2370,8 @@ void the_game(
&client, gamedef);
menu->setFormSpec(meta->getString("formspec"),
inventoryloc);
menu->setFormSource(new NodeMetadataFormSource(
&client.getEnv().getClientMap(), nodepos));
menu->drop();
}
// Otherwise report right click to server