本文整理汇总了C++中idStr::IsEmpty方法的典型用法代码示例。如果您正苦于以下问题:C++ idStr::IsEmpty方法的具体用法?C++ idStr::IsEmpty怎么用?C++ idStr::IsEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idStr
的用法示例。
在下文中一共展示了idStr::IsEmpty方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetItemById
CInventoryItemPtr CInventory::GetItemById(const idStr& id, const idStr& categoryName, bool createCategory)
{
// Do we have a specific category to search in?
if (!categoryName.IsEmpty())
{
// We have a category name, look it up
CInventoryCategoryPtr category = GetCategory(categoryName);
if (category == NULL && createCategory)
{
// Special case, the caller requested to create this category if not found
category = CreateCategory(categoryName);
}
// Let the category search for the item, may return NULL
return (category != NULL) ? category->GetItemById(id) : CInventoryItemPtr();
}
// No specific category specified, look in all categories
for (int i = 0; i < m_Category.Num(); i++)
{
CInventoryItemPtr foundItem = m_Category[i]->GetItemById(id);
if (foundItem != NULL)
{
// Found the item
return foundItem;
}
}
return CInventoryItemPtr(); // nothing found
}
示例2: SetInherit
void DialogEntityDefEditor::SetInherit( idStr &inherit ) {
CWaitCursor wc;
for( int i = 0; i < keyValsList.GetCount(); i++ ) {
CPropertyItem *pItem = ( CPropertyItem * )keyValsList.GetItemDataPtr( i );
if( pItem ) {
if( pItem->m_propName[0] == '*' ) {
delete pItem;
keyValsList.DeleteString( i );
i--;
}
}
}
CString spawnclass;
// Fill up the rest of the box with inherited info
if( !inherit.IsEmpty() ) {
const idDecl *temp = declManager->FindType( DECL_ENTITYDEF, inherit, false );
const idDeclEntityDef *parent = static_cast<const idDeclEntityDef *>( temp );
if( parent ) {
size_t numPairs = parent->dict.Size();
for( unsigned int i = 0; i < numPairs; i++ ) {
const idKeyValue *keyVal = parent->dict.GetKeyVal( i );
if( keyVal ) {
if( spawnclass.IsEmpty() && keyVal->GetKey() == "spawnclass" ) {
spawnclass = keyVal->GetValue();
} else {
CString key = keyVal->GetKey();
key = "*" + key;
keyValsList.AddPropItem( new CPropertyItem( key, keyVal->GetValue().c_str(), PIT_EDIT, "" ) );
}
}
}
}
}
}
示例3: CreateCategory
CInventoryCategoryPtr CInventory::CreateCategory(const idStr& categoryName, int* index)
{
if (categoryName.IsEmpty()) return CInventoryCategoryPtr(); // empty category name
// Try to lookup the category, maybe it exists already
CInventoryCategoryPtr rc = GetCategory(categoryName, index);
if (rc != NULL) return rc; // Category already exists
// Try to allocate a new category with a link back to <this> Inventory
rc = CInventoryCategoryPtr(new CInventoryCategory(this, categoryName));
// Add the new Category to our list
int i = m_Category.AddUnique(rc);
// Should we return an index?
if (index != NULL)
{
*index = i;
}
return rc;
}
示例4: PutItem
void CInventory::PutItem(const CInventoryItemPtr& item, const idStr& categoryName)
{
if (item == NULL) return;
CInventoryCategoryPtr category;
// Check if it is the default group or not.
if (categoryName.IsEmpty())
{
// category is empty, assign the item to the default group
category = m_Category[0];
}
else
{
// Try to find the category with the given name
category = GetCategory(categoryName);
// If not found, create it
if (category == NULL)
{
category = CreateCategory(categoryName);
}
}
// Pack the item into the category
category->PutItemFront(item);
// Objective callback for non-loot items:
// non-loot item passes in inv_name and individual item count, SuperGroupVal of 1
gameLocal.m_MissionData->InventoryCallback(
item->GetItemEntity(),
item->GetName(),
item->GetCount(),
1,
true
);
}
示例5: GetCategoryItemIndex
int CInventory::GetCategoryItemIndex(const idStr& itemName, int* itemIndex)
{
// Set the returned index to -1 if applicable
if (itemIndex != NULL) *itemIndex = -1;
if (itemName.IsEmpty()) return -1;
for (int i = 0; i < m_Category.Num(); i++)
{
// Try to find the item within the category
int n = m_Category[i]->GetItemIndex(itemName);
if (n != -1)
{
// Found, set the item index if desired
if (itemIndex != NULL) *itemIndex = n;
// Return the category index
return i;
}
}
return -1; // not found
}
示例6: GetCategory
CInventoryCategoryPtr CInventory::GetCategory(const idStr& categoryName, int* index)
{
// If the groupname is empty we look for the default group
if (categoryName.IsEmpty())
{
return GetCategory(TDM_INVENTORY_DEFAULT_GROUP);
}
// Traverse the categories and find the one matching <CategoryName>
for (int i = 0; i < m_Category.Num(); i++)
{
if (m_Category[i]->GetName() == categoryName)
{
if (index != NULL)
{
*index = i;
}
return m_Category[i];
}
}
return CInventoryCategoryPtr(); // not found
}