Bugfix: Update formname on showing new formspec while already one shown
parent
f62ddf9022
commit
efc75db764
13
src/game.cpp
13
src/game.cpp
|
@ -134,6 +134,10 @@ struct TextDestPlayerInventory : public TextDest
|
||||||
m_client->sendInventoryFields(m_formname, fields);
|
m_client->sendInventoryFields(m_formname, fields);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setFormName(std::string formname) {
|
||||||
|
m_formname = formname;
|
||||||
|
}
|
||||||
|
|
||||||
Client *m_client;
|
Client *m_client;
|
||||||
std::string m_formname;
|
std::string m_formname;
|
||||||
};
|
};
|
||||||
|
@ -920,6 +924,7 @@ void the_game(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FormspecFormSource* current_formspec = 0;
|
FormspecFormSource* current_formspec = 0;
|
||||||
|
TextDestPlayerInventory* current_textdest = 0;
|
||||||
video::IVideoDriver* driver = device->getVideoDriver();
|
video::IVideoDriver* driver = device->getVideoDriver();
|
||||||
scene::ISceneManager* smgr = device->getSceneManager();
|
scene::ISceneManager* smgr = device->getSceneManager();
|
||||||
|
|
||||||
|
@ -2236,19 +2241,23 @@ void the_game(
|
||||||
if (current_formspec == 0)
|
if (current_formspec == 0)
|
||||||
{
|
{
|
||||||
/* Create menu */
|
/* Create menu */
|
||||||
|
/* Note: FormspecFormSource and TextDestPlayerInventory
|
||||||
|
* are deleted by guiFormSpecMenu */
|
||||||
current_formspec = new FormspecFormSource(*(event.show_formspec.formspec),¤t_formspec);
|
current_formspec = new FormspecFormSource(*(event.show_formspec.formspec),¤t_formspec);
|
||||||
|
current_textdest = new TextDestPlayerInventory(&client,*(event.show_formspec.formname));
|
||||||
GUIFormSpecMenu *menu =
|
GUIFormSpecMenu *menu =
|
||||||
new GUIFormSpecMenu(device, guiroot, -1,
|
new GUIFormSpecMenu(device, guiroot, -1,
|
||||||
&g_menumgr,
|
&g_menumgr,
|
||||||
&client, gamedef);
|
&client, gamedef);
|
||||||
menu->setFormSource(current_formspec);
|
menu->setFormSource(current_formspec);
|
||||||
menu->setTextDest(new TextDestPlayerInventory(&client,*(event.show_formspec.formname)));
|
menu->setTextDest(current_textdest);
|
||||||
menu->drop();
|
menu->drop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
assert(current_textdest != 0);
|
||||||
/* update menu */
|
/* update menu */
|
||||||
|
current_textdest->setFormName(*(event.show_formspec.formname));
|
||||||
current_formspec->setForm(*(event.show_formspec.formspec));
|
current_formspec->setForm(*(event.show_formspec.formspec));
|
||||||
}
|
}
|
||||||
delete(event.show_formspec.formspec);
|
delete(event.show_formspec.formspec);
|
||||||
|
|
Loading…
Reference in New Issue