本文整理汇总了C++中PODVector::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ PODVector::Contains方法的具体用法?C++ PODVector::Contains怎么用?C++ PODVector::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PODVector
的用法示例。
在下文中一共展示了PODVector::Contains方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleMouseClick
void SliderWithTextAndButtons::HandleMouseClick(StringHash, VariantMap& eventData)
{
UIElement *pointer = (UIElement*)eventData[Urho3D::UIMouseClick::P_ELEMENT].GetPtr();
PODVector<UIElement*> childrens;
GetChildren(childrens, true);
if (childrens.Contains(pointer))
{
int buttons = (int)eventData[Urho3D::UIMouseClick::P_BUTTONS].GetInt();
if (buttons == Urho3D::MOUSEB_RIGHT)
{
if (hint)
{
if (gHint)
{
gUIRoot->RemoveChild(gHint);
}
int x = (int)eventData[Urho3D::UIMouseClick::P_X].GetInt();
int y = (int)eventData[Urho3D::UIMouseClick::P_Y].GetInt();
hint->SetPosition(x, y - hint->GetHeight());
gUIRoot->AddChild(hint);
hint->BringToFront();
gHint = hint;
gCounterHint = 0;
}
}
}
}
示例2: UnsubscribeFromAllEventsExcept
void Object::UnsubscribeFromAllEventsExcept(const PODVector<StringHash>& exceptions, bool onlyUserData)
{
EventHandler* handler = eventHandlers_.First();
EventHandler* previous = 0;
while (handler)
{
EventHandler* next = eventHandlers_.Next(handler);
if ((!onlyUserData || handler->GetUserData()) && !exceptions.Contains(handler->GetEventType()))
{
if (handler->GetSender())
context_->RemoveEventReceiver(this, handler->GetSender(), handler->GetEventType());
else
context_->RemoveEventReceiver(this, handler->GetEventType());
eventHandlers_.Erase(handler, previous);
}
else
previous = handler;
handler = next;
}
}
示例3: ParseComponentClassJSON
bool CSComponentAssembly::ParseComponentClassJSON(const JSONValue& json)
{
if (!typeMap_.Size())
InitTypeMap();
String className = json.Get("name").GetString();
classNames_.Push(className);
const JSONValue& jfields = json.Get("fields");
PODVector<StringHash> enumsAdded;
if (jfields.IsArray())
{
for (unsigned i = 0; i < jfields.GetArray().Size(); i++)
{
const JSONValue& jfield = jfields.GetArray().At(i);
VariantType varType = VAR_NONE;
bool isEnum = jfield.Get("isEnum").GetBool();
String typeName = jfield.Get("typeName").GetString();
String fieldName = jfield.Get("name").GetString();
String defaultValue = jfield.Get("defaultValue").GetString();
if (!defaultValue.Length())
{
JSONArray caPos = jfield.Get("caPos").GetArray();
if (caPos.Size())
defaultValue = caPos[0].GetString();
}
if (!defaultValue.Length())
{
JSONObject caNamed = jfield.Get("caNamed").GetObject();
if (caNamed.Contains("DefaultValue"))
defaultValue = caNamed["DefaultValue"].GetString();
}
if (isEnum && assemblyEnums_.Contains(typeName) && !enumsAdded.Contains(fieldName))
{
varType = VAR_INT;
enumsAdded.Push(fieldName);
const Vector<EnumInfo>& einfos = assemblyEnums_[typeName];
for (unsigned i = 0; i < einfos.Size(); i++)
AddEnum(/*typeName*/fieldName, einfos[i], className);
}
if (varType == VAR_NONE && typeMap_.Contains(typeName))
varType = typeMap_[typeName];
if (varType == VAR_NONE)
{
// FIXME: We need to be able to test if a type is a ResourceRef, this isn't really the way to achieve that
const HashMap<StringHash, SharedPtr<ObjectFactory>>& factories = context_->GetObjectFactories();
HashMap<StringHash, SharedPtr<ObjectFactory>>::ConstIterator itr = factories.Begin();
while (itr != factories.End())
{
if (itr->second_->GetTypeName() == typeName)
{
varType = VAR_RESOURCEREF;
break;
}
itr++;
}
if (varType == VAR_NONE)
{
ATOMIC_LOGERRORF("Component Class %s contains unmappable type %s in field %s",
className.CString(), typeName.CString(), fieldName.CString());
continue;
}
}
if (!defaultValue.Length() && varType == VAR_RESOURCEREF)
{
// We still need a default value for ResourceRef's so we know the classtype
AddDefaultValue(fieldName, ResourceRef(typeName), className);
}
else
{
Variant value;
if (varType == VAR_RESOURCEREF)
{
ResourceRef rref(typeName);
rref.name_ = defaultValue;
value = rref;
}
else
{
value.FromString(varType, defaultValue);
}
AddDefaultValue(fieldName, value, className);
//.........这里部分代码省略.........
示例4: SetSelections
void ListView::SetSelections(const PODVector<unsigned>& indices)
{
// Make a weak pointer to self to check for destruction as a response to events
WeakPtr<ListView> self(this);
unsigned numItems = GetNumItems();
// Remove first items that should no longer be selected
for (PODVector<unsigned>::Iterator i = selections_.Begin(); i != selections_.End();)
{
unsigned index = *i;
if (!indices.Contains(index))
{
i = selections_.Erase(i);
using namespace ItemSelected;
VariantMap& eventData = GetEventDataMap();
eventData[P_ELEMENT] = this;
eventData[P_SELECTION] = index;
SendEvent(E_ITEMDESELECTED, eventData);
if (self.Expired())
return;
}
else
++i;
}
bool added = false;
// Then add missing items
for (PODVector<unsigned>::ConstIterator i = indices.Begin(); i != indices.End(); ++i)
{
unsigned index = *i;
if (index < numItems)
{
// In singleselect mode, resend the event even for the same selection
bool duplicate = selections_.Contains(index);
if (!duplicate || !multiselect_)
{
if (!duplicate)
{
selections_.Push(index);
added = true;
}
using namespace ItemSelected;
VariantMap& eventData = GetEventDataMap();
eventData[P_ELEMENT] = this;
eventData[P_SELECTION] = *i;
SendEvent(E_ITEMSELECTED, eventData);
if (self.Expired())
return;
}
}
// If no multiselect enabled, allow setting only one item
if (!multiselect_)
break;
}
// Re-sort selections if necessary
if (added)
Sort(selections_.Begin(), selections_.End());
UpdateSelectionEffect();
SendEvent(E_SELECTIONCHANGED);
}
示例5: HandlePrefabSave
void PrefabImporter::HandlePrefabSave(StringHash eventType, VariantMap& eventData)
{
using namespace PrefabSave;
PrefabComponent* component = static_cast<PrefabComponent*>(eventData[P_PREFABCOMPONENT].GetPtr());
if (component->GetPrefabGUID() != asset_->GetGUID())
return;
Node* node = component->GetNode();
if (!node)
return;
// flip temporary root children and components to not be temporary for save
const Vector<SharedPtr<Component>>& rootComponents = node->GetComponents();
const Vector<SharedPtr<Node> >& children = node->GetChildren();
PODVector<Component*> tempComponents;
PODVector<Node*> tempChildren;
PODVector<Node*> filterNodes;
for (unsigned i = 0; i < rootComponents.Size(); i++)
{
if (rootComponents[i]->IsTemporary())
{
rootComponents[i]->SetTemporary(false);
tempComponents.Push(rootComponents[i]);
// Animated sprites contain a temporary node we don't want to save in the prefab
// it would be nice if this was general purpose because have to test this when
// breaking node as well
if (rootComponents[i]->GetType() == AnimatedSprite2D::GetTypeStatic())
{
AnimatedSprite2D* asprite = (AnimatedSprite2D*) rootComponents[i].Get();
if (asprite->GetRootNode())
filterNodes.Push(asprite->GetRootNode());
}
}
}
for (unsigned i = 0; i < children.Size(); i++)
{
if (filterNodes.Contains(children[i].Get()))
continue;
if (children[i]->IsTemporary())
{
children[i]->SetTemporary(false);
tempChildren.Push(children[i]);
}
}
// store original transform
Vector3 pos = node->GetPosition();
Quaternion rot = node->GetRotation();
Vector3 scale = node->GetScale();
node->SetPosition(Vector3::ZERO);
node->SetRotation(Quaternion::IDENTITY);
node->SetScale(Vector3::ONE);
component->SetTemporary(true);
SharedPtr<File> file(new File(context_, asset_->GetPath(), FILE_WRITE));
node->SaveXML(*file);
file->Close();
component->SetTemporary(false);
// restore
node->SetPosition(pos);
node->SetRotation(rot);
node->SetScale(scale);
for (unsigned i = 0; i < tempComponents.Size(); i++)
{
tempComponents[i]->SetTemporary(true);
}
for (unsigned i = 0; i < tempChildren.Size(); i++)
{
tempChildren[i]->SetTemporary(true);
}
FileSystem* fs = GetSubsystem<FileSystem>();
fs->Copy(asset_->GetPath(), asset_->GetCachePath());
// reload it immediately so it is ready for use
// TODO: The resource cache is reloading after this reload due to catching the file cache
ResourceCache* cache = GetSubsystem<ResourceCache>();
XMLFile* xmlfile = cache->GetResource<XMLFile>(asset_->GetGUID());
cache->ReloadResource(xmlfile);
VariantMap changedData;
changedData[PrefabChanged::P_GUID] = asset_->GetGUID();
SendEvent(E_PREFABCHANGED, changedData);
//.........这里部分代码省略.........