Beispiel #1
0
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
}
Beispiel #2
0
CInventory::CInventory() :
	m_HighestCursorId(0),
	m_LootItemCount(0),
	m_Gold(0),
	m_Jewelry(0),
	m_Goods(0)
{
	m_Owner = NULL;

	CreateCategory(TDM_INVENTORY_DEFAULT_GROUP);	// We always have a defaultgroup if nothing else
}
Beispiel #3
0
int IGFManager :: EditObject(AccountData *callerAccount, int categoryType, int parentID, int renameID, const char *name)
{
	//categoryType is either a Category or Thread
	//parentID is only used if creating a category.  This is the parent category ID.
	//renameID is only used if renaming an object.  This is ID being renamed.
	if(GetEditPermission(callerAccount, -1) == false)
		return ERROR_PERMISSIONDENIED;

	if(name == NULL)
		return ERROR_INVALIDTITLETEXT;
	if(strlen(name) == 0)
		return ERROR_INVALIDTITLETEXT;
	if(HasInvalidCharacters(name, false)) return ERROR_INVALIDTITLETEXT;

	if(categoryType == TYPE_CATEGORY)
	{
		if(strlen(name) > MAX_TITLE_LENGTH)
			return ERROR_TITLELENGTH;

		if(renameID == 0)
		{
			return CreateCategory(callerAccount, parentID, name);
		}
		else
		{
			IGFCategory *category = GetPagedCategoryPtr(renameID);
			if(category == NULL)
				return ERROR_INVALIDCATEGORY;
			category->mTitle = name;
			MarkChangedCategory(renameID);
		}
	}
	else if(categoryType == TYPE_THREAD)
	{
		//Only supports rename for threads.
		if(strlen(name) > MAX_TITLE_LENGTH)
			return ERROR_TITLELENGTH;

		if(renameID != 0)
		{
			IGFThread *thread = GetPagedThreadPtr(renameID);
			if(thread == NULL)
				return ERROR_INVALIDTHREAD;
			thread->mTitle = name;
			MarkChangedThread(renameID);
		}
	}
	else
		return ERROR_UNHANDLED;

	return ERROR_NONE;
}
Beispiel #4
0
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
	);
}
void CBCGPRibbonConstructor::ConstructRibbonBar (CBCGPRibbonBar& bar) const
{
	const CBCGPRibbonInfo::XRibbonBar& infoBar = GetInfo ().GetRibbonBar ();

	CBCGPRibbonPanel::m_nNextPanelID = (UINT)-10;

	bar.m_VersionStamp = GetInfo ().GetVersionStamp ();
	bar.EnableToolTips     (infoBar.m_bToolTip, infoBar.m_bToolTipDescr);
	bar.EnableKeyTips      (infoBar.m_bKeyTips);
	bar.EnablePrintPreview (infoBar.m_bPrintPreview);
	bar.SetBackstageMode   (infoBar.m_bBackstageMode);

	CBCGPRibbonFontComboBox::m_bDrawUsingFont = infoBar.m_bDrawUsingFont;

	const_cast<CBCGPToolBarImages&>(infoBar.m_Images.m_Image).CopyTo (bar.m_PanelIcons);

	if (infoBar.m_btnMain != NULL)
	{
		CBCGPRibbonMainButton* btnMain = bar.GetMainButton ();
		if (btnMain == NULL)
		{
			btnMain = CreateMainButton (bar);
		}

		if (btnMain != NULL)
		{
			ConstructElement (*btnMain, *infoBar.m_btnMain);
		}
	}

	if (infoBar.m_MainCategory != NULL)
	{
		ConstructCategoryMain (bar, *infoBar.m_MainCategory);
	}

	if (infoBar.m_BackstageCategory != NULL)
	{
		ConstructCategoryBackstage (bar, *infoBar.m_BackstageCategory);
	}

	ConstructTabElements (bar, infoBar);

	int i = 0;
	for (i = 0; i < infoBar.m_arCategories.GetSize (); i++)
	{
		const CBCGPRibbonInfo::XCategory& infoCategory = 
			*(const CBCGPRibbonInfo::XCategory*)infoBar.m_arCategories[i];

		CBCGPRibbonCategory* pCategory = CreateCategory (bar, infoCategory);
		if (pCategory != NULL)
		{
			ASSERT_VALID (pCategory);
			ConstructCategory (*pCategory, infoCategory);
		}
	}

	for (i = 0; i < infoBar.m_arContexts.GetSize (); i++)
	{
		const CBCGPRibbonInfo::XContext* context = infoBar.m_arContexts[i];
		for (int j = 0; j < context->m_arCategories.GetSize (); j++)
		{
			const CBCGPRibbonInfo::XCategory& infoCategory = 
				*(const CBCGPRibbonInfo::XCategory*)context->m_arCategories[j];

			CBCGPRibbonCategory* pCategory = CreateCategoryContext (bar, *context, infoCategory);
			if (pCategory != NULL)
			{
				ASSERT_VALID (pCategory);
				ConstructCategory (*pCategory, infoCategory);
			}
		}
	}

	ConstructQATElements (bar, infoBar);
}