本文整理汇总了C++中Inventory::ContainsHowMany方法的典型用法代码示例。如果您正苦于以下问题:C++ Inventory::ContainsHowMany方法的具体用法?C++ Inventory::ContainsHowMany怎么用?C++ Inventory::ContainsHowMany使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Inventory
的用法示例。
在下文中一共展示了Inventory::ContainsHowMany方法的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: UiBase
UiObjectQuantityPicker::UiObjectQuantityPicker(WindowFramework* window, Rocket::Core::Context* context, const Inventory& inventory, const InventoryObject* object) : UiBase(window, context)
{
_max_quantity = inventory.ContainsHowMany(object->GetName());
root = context->LoadDocument("data/object_quantity_picker.rml");
if (root)
{
Rocket::Core::Element* icon = root->GetElementById("item_icon");
_line_edit = root->GetElementById("item_quantity");
if (_line_edit)
{
ToggleEventListener(true, "button_confirm", "click", EventAccepted);
EventAccepted.EventReceived.Connect(*this, &UiObjectQuantityPicker::Accepted);
}
if (icon)
{
Rocket::Core::String src("../textures/itemIcons/");
src += object->GetIcon().c_str();
icon->SetAttribute("src", src);
}
ToggleEventListener(true, "item_minus", "click", EventIncrement);
ToggleEventListener(true, "item_plus", "click", EventIncrement);
ToggleEventListener(true, "item_quantity", "change", EventValueChanged);
ToggleEventListener(true, "button_cancel", "click", EventCanceled);
EventIncrement.EventReceived.Connect(*this, &UiObjectQuantityPicker::Increment);
EventValueChanged.EventReceived.Connect([this](Rocket::Core::Event&) { SetQuantity(GetQuantity()); });
EventCanceled.EventReceived.Connect( [this](Rocket::Core::Event&) { Canceled.Emit(); });
Canceled.Connect(*this, &UiBase::Hide);
SetModal(true);
}
}