forked from Mirrorlandia_minetest/minetest
Disable inventory if player's inventory formspec is blank (#11827)
This commit is contained in:
parent
84efe279bb
commit
fcf86ded8f
@ -6690,6 +6690,7 @@ object you are working with still exists.
|
|||||||
* `set_inventory_formspec(formspec)`
|
* `set_inventory_formspec(formspec)`
|
||||||
* Redefine player's inventory form
|
* Redefine player's inventory form
|
||||||
* Should usually be called in `on_joinplayer`
|
* Should usually be called in `on_joinplayer`
|
||||||
|
* If `formspec` is `""`, the player's inventory is disabled.
|
||||||
* `get_inventory_formspec()`: returns a formspec string
|
* `get_inventory_formspec()`: returns a formspec string
|
||||||
* `set_formspec_prepend(formspec)`:
|
* `set_formspec_prepend(formspec)`:
|
||||||
* the formspec string will be added to every formspec shown to the user,
|
* the formspec string will be added to every formspec shown to the user,
|
||||||
|
@ -2060,8 +2060,16 @@ void Game::openInventory()
|
|||||||
InventoryLocation inventoryloc;
|
InventoryLocation inventoryloc;
|
||||||
inventoryloc.setCurrentPlayer();
|
inventoryloc.setCurrentPlayer();
|
||||||
|
|
||||||
if (!client->modsLoaded()
|
if (client->modsLoaded() && client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) {
|
||||||
|| !client->getScript()->on_inventory_open(fs_src->m_client->getInventory(inventoryloc))) {
|
delete fs_src;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fs_src->getForm().empty()) {
|
||||||
|
delete fs_src;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
TextDest *txt_dst = new TextDestPlayerInventory(client);
|
TextDest *txt_dst = new TextDestPlayerInventory(client);
|
||||||
auto *&formspec = m_game_ui->updateFormspec("");
|
auto *&formspec = m_game_ui->updateFormspec("");
|
||||||
GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(),
|
GUIFormSpecMenu::create(formspec, client, m_rendering_engine->get_gui_env(),
|
||||||
@ -2069,7 +2077,6 @@ void Game::openInventory()
|
|||||||
|
|
||||||
formspec->setFormSpec(fs_src->getForm(), inventoryloc);
|
formspec->setFormSpec(fs_src->getForm(), inventoryloc);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Game::openConsole(float scale, const wchar_t *line)
|
void Game::openConsole(float scale, const wchar_t *line)
|
||||||
|
Loading…
Reference in New Issue
Block a user