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

Inventory menu changes: Tooltips; dragging; drop from menu. Lag is a bit annoying (even in single player).

This commit is contained in:
Kahrl 2012-01-13 12:35:55 +01:00
parent a58d725569
commit c920df748b
4 changed files with 184 additions and 80 deletions

View file

@ -302,18 +302,28 @@ void IDropAction::apply(InventoryManager *mgr, ServerActiveObject *player)
return;
}
/*
Drop the item
*/
ItemStack item = list_from->getItem(from_i);
if(scriptapi_item_on_drop(player->getEnv()->getLua(), item, player,
// Take item from source list
ItemStack item1;
if(count == 0)
item1 = list_from->changeItem(from_i, ItemStack());
else
item1 = list_from->takeItem(from_i, count);
// Drop the item and apply the returned ItemStack
ItemStack item2 = item1;
if(scriptapi_item_on_drop(player->getEnv()->getLua(), item2, player,
player->getBasePosition() + v3f(0,1,0)))
{
// Apply returned ItemStack
if(g_settings->getBool("creative_mode") == false
|| from_inv.type != InventoryLocation::PLAYER)
list_from->changeItem(from_i, item);
mgr->setInventoryModified(from_inv);
if(g_settings->getBool("creative_mode") == true
&& from_inv.type == InventoryLocation::PLAYER)
item2 = item1; // creative mode
list_from->addItem(from_i, item2);
// Unless we have put the same amount back as we took in the first place,
// set inventory modified flag
if(item2.count != item1.count)
mgr->setInventoryModified(from_inv);
}
infostream<<"IDropAction::apply(): dropped "