本文整理汇总了C++中Inventory::AddObject方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::AddObject方法的具体用法?C++ Inventory::AddObject怎么用?C++ Inventory::AddObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::AddObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SwapFunctor
bool UiBarter::SwapFunctor(InventoryObject* object, Inventory& from, Inventory& to)
{
if (from.IncludesObject(object))
{
string object_name = object->GetName();
function<void (unsigned short)> swap_callback([this, &from, &to, object_name](unsigned short quantity)
{
while (quantity--)
{
InventoryObject* swapping = from.GetObject(object_name);
to.AddObject(swapping);
from.DelObject(swapping);
}
Update();
if (_quantity_picker)
_quantity_picker->SetModal(false);
});
if (from.ContainsHowMany(object->GetName()) > 1)
{
if (_quantity_picker) delete _quantity_picker;
_quantity_picker = new UiObjectQuantityPicker(window, context, from, object);
_quantity_picker->SetModal(true);
_quantity_picker->QuantityPicked.Connect(swap_callback);
_quantity_picker->Observer.Connect(VisibilityToggledOff, *_quantity_picker, &UiBase::Hide);
}
else
swap_callback(1);
return (true);
}
return (false);
}
示例2: DropInventory
void UiBarter::DropInventory(Inventory& from, Inventory& to)
{
Inventory::Content::iterator it, end;
it = from.GetContent().begin();
end = from.GetContent().end();
while (it != end)
{
to.AddObject(*it);
from.DelObject(*it);
it = from.GetContent().begin();
}
}