mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
comments
This commit is contained in:
parent
4b3a809021
commit
25a319bb23
4 changed files with 22 additions and 16 deletions
|
@ -6873,7 +6873,7 @@ Formspec
|
||||||
* `playername`: name of player to show formspec
|
* `playername`: name of player to show formspec
|
||||||
* `formname`: name passed to `on_player_receive_fields` callbacks.
|
* `formname`: name passed to `on_player_receive_fields` callbacks.
|
||||||
* It should follow the `"modname:<whatever>"` naming convention.
|
* It should follow the `"modname:<whatever>"` naming convention.
|
||||||
* If empty: Shows an inventory formspec. Use
|
* If empty: Shows a custom, temporary inventory formspec. Use
|
||||||
`ObjectRef:set_inventory_formspec` to change it for future opens.
|
`ObjectRef:set_inventory_formspec` to change it for future opens.
|
||||||
Supported if server AND client are both of version >= 5.13.0.
|
Supported if server AND client are both of version >= 5.13.0.
|
||||||
* `formspec`: formspec to display
|
* `formspec`: formspec to display
|
||||||
|
@ -8654,9 +8654,12 @@ child will follow movement and rotation of that bone.
|
||||||
* Returns `nil` if no attribute found.
|
* Returns `nil` if no attribute found.
|
||||||
* `get_meta()`: Returns metadata associated with the player (a PlayerMetaRef).
|
* `get_meta()`: Returns metadata associated with the player (a PlayerMetaRef).
|
||||||
* `set_inventory_formspec(formspec)`
|
* `set_inventory_formspec(formspec)`
|
||||||
* Redefine player's inventory form. This sends an update to the player.
|
* Redefines the player's inventory formspec.
|
||||||
* Should usually be called in `on_joinplayer`
|
* Should usually be called at least once in the `on_joinplayer` callback.
|
||||||
* If `formspec` is `""`, the player's inventory is disabled.
|
* If `formspec` is `""`, the player's inventory is disabled.
|
||||||
|
* If the inventory formspec is currently open on the client, it is
|
||||||
|
updated immediately.
|
||||||
|
* See also: `core.register_on_player_receive_fields`
|
||||||
* `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,
|
||||||
|
|
|
@ -321,33 +321,35 @@ void GameFormSpec::showPlayerInventory(const std::string *fs_override)
|
||||||
|
|
||||||
infostream << "Game: Launching inventory" << std::endl;
|
infostream << "Game: Launching inventory" << std::endl;
|
||||||
|
|
||||||
PlayerInventoryFormSource *fs_src = new PlayerInventoryFormSource(m_client);
|
auto fs_src = std::make_unique<PlayerInventoryFormSource>(m_client);
|
||||||
|
|
||||||
InventoryLocation inventoryloc;
|
InventoryLocation inventoryloc;
|
||||||
inventoryloc.setCurrentPlayer();
|
inventoryloc.setCurrentPlayer();
|
||||||
|
|
||||||
if (fs_override)
|
if (fs_override) {
|
||||||
|
// Temporary overwrite for this specific formspec.
|
||||||
player->inventory_formspec_override = *fs_override;
|
player->inventory_formspec_override = *fs_override;
|
||||||
else
|
} else {
|
||||||
|
// Show the regular inventory formspec
|
||||||
player->inventory_formspec_override.clear();
|
player->inventory_formspec_override.clear();
|
||||||
|
|
||||||
if (m_client->modsLoaded() && m_client->getScript()->on_inventory_open(m_client->getInventory(inventoryloc))) {
|
|
||||||
delete fs_src;
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fs_src->getForm().empty() || (fs_override && fs_override->empty())) {
|
// If preventedd by Client-Side Mods
|
||||||
delete fs_src;
|
if (m_client->modsLoaded() && m_client->getScript()->on_inventory_open(m_client->getInventory(inventoryloc)))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Empty formspec -> do not show.
|
||||||
|
if (fs_src->getForm().empty())
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
TextDest *txt_dst = new TextDestPlayerInventory(m_client);
|
TextDest *txt_dst = new TextDestPlayerInventory(m_client);
|
||||||
|
|
||||||
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
GUIFormSpecMenu::create(m_formspec, m_client, m_rendering_engine->get_gui_env(),
|
||||||
&m_input->joystick, fs_src, txt_dst, m_client->getFormspecPrepend(),
|
&m_input->joystick, fs_src.get(), txt_dst, m_client->getFormspecPrepend(),
|
||||||
m_client->getSoundManager());
|
m_client->getSoundManager());
|
||||||
|
|
||||||
m_formspec->setFormSpec(fs_src->getForm(), inventoryloc);
|
m_formspec->setFormSpec(fs_src->getForm(), inventoryloc);
|
||||||
|
fs_src.release(); // owned by GUIFormSpecMenu
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SIZE_TAG "size[11,5.5,true]" // Fixed size (ignored in touchscreen mode)
|
#define SIZE_TAG "size[11,5.5,true]" // Fixed size (ignored in touchscreen mode)
|
||||||
|
|
|
@ -34,8 +34,8 @@ struct GameFormSpec
|
||||||
// Currently only used for the in-game settings menu.
|
// Currently only used for the in-game settings menu.
|
||||||
void showPauseMenuFormSpec(const std::string &formspec, const std::string &formname);
|
void showPauseMenuFormSpec(const std::string &formspec, const std::string &formname);
|
||||||
void showNodeFormspec(const std::string &formspec, const v3s16 &nodepos);
|
void showNodeFormspec(const std::string &formspec, const v3s16 &nodepos);
|
||||||
/// If ` fs_override`: Uses `player->inventory_formspec`.
|
/// If `!fs_override`: Uses `player->inventory_formspec`.
|
||||||
/// If `!fs_override`: Uses a temporary formspec until an update is received.
|
/// If ` fs_override`: Uses a temporary formspec until an update is received.
|
||||||
void showPlayerInventory(const std::string *fs_override);
|
void showPlayerInventory(const std::string *fs_override);
|
||||||
void showDeathFormspecLegacy();
|
void showDeathFormspecLegacy();
|
||||||
// Shows the hardcoded "main" pause menu.
|
// Shows the hardcoded "main" pause menu.
|
||||||
|
|
|
@ -99,6 +99,7 @@ public:
|
||||||
|
|
||||||
std::string hotbar_image = "";
|
std::string hotbar_image = "";
|
||||||
std::string hotbar_selected_image = "";
|
std::string hotbar_selected_image = "";
|
||||||
|
/// Temporary player inventory formspec. Empty value = feature inactive.
|
||||||
std::string inventory_formspec_override;
|
std::string inventory_formspec_override;
|
||||||
|
|
||||||
video::SColor light_color = video::SColor(255, 255, 255, 255);
|
video::SColor light_color = video::SColor(255, 255, 255, 255);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue