当前位置: 首页>>代码示例>>C++>>正文


C++ CItemType::GetApparentLevel方法代码示例

本文整理汇总了C++中CItemType::GetApparentLevel方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemType::GetApparentLevel方法的具体用法?C++ CItemType::GetApparentLevel怎么用?C++ CItemType::GetApparentLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CItemType的用法示例。


在下文中一共展示了CItemType::GetApparentLevel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: CalcRowHeight

int CGItemListArea::CalcRowHeight (int iRow)

//	CalcRowHeight
//
//	Returns the height of the given row

	{
	//	Set the position

	int iOldPos = m_pListData->GetCursor();
	m_pListData->SetCursor(iRow);

	//	Compute the rect where we're painting (we only care about width)

	RECT rcRect = GetRect();

	//	Compute row height based on type of list

	int cyHeight;
	switch (m_iType)
		{
		case listItem:
			{
			//	Get the item

			if (!m_pListData->IsCursorValid())
				{
				cyHeight = DEFAULT_ROW_HEIGHT;
				break;
				}

			const CItem &Item = m_pListData->GetItemAtCursor();
			CItemCtx Ctx(&Item, m_pListData->GetSource());
			CItemType *pType = Item.GetType();
			if (pType == NULL)
				{
				cyHeight = DEFAULT_ROW_HEIGHT;
				break;
				}

			int iLevel = pType->GetApparentLevel();

			//	Compute the height of the row

			cyHeight = 0;

			//	Account for margin

			cyHeight += ITEM_TEXT_MARGIN_Y;

			//	Item title

			cyHeight += m_pFonts->LargeBold.GetHeight();

			//	Reference

			CString sReference = pType->GetReference(Ctx);

			//	If this is a weapon, then add room for the weapon damage

			if (Item.GetReferenceDamageType(m_pListData->GetSource(), -1, 0, NULL, NULL))
				cyHeight += m_pFonts->Medium.GetHeight();

			//	If this is armor or a shield, then add room for damage resistance

			else if (Item.GetReferenceDamageAdj(m_pListData->GetSource(), 0, NULL, NULL))
				cyHeight += m_pFonts->Medium.GetHeight();

			//	Otherwise, we add the level to the reference

			else
				{
				if (sReference.IsBlank())
					sReference = strPatternSubst("Level %s", strLevel(iLevel));
				else
					sReference = strPatternSubst("Level %s — %s", 
							strLevel(iLevel),
							sReference);
				}

			//	Compute the rect where the reference text will paint

			RECT rcDrawRect = rcRect;
			rcDrawRect.left += ICON_WIDTH + ITEM_TEXT_MARGIN_X;
			rcDrawRect.right -= ITEM_TEXT_MARGIN_X;

			//	Measure the reference text

			int iLines = m_pFonts->Medium.BreakText(sReference, RectWidth(rcDrawRect), NULL, 0);
			cyHeight += iLines * m_pFonts->Medium.GetHeight();

			//	Measure the description

			CString sDesc = Item.GetDesc();
			iLines = m_pFonts->Medium.BreakText(sDesc, RectWidth(rcDrawRect), NULL, 0);
			cyHeight += iLines * m_pFonts->Medium.GetHeight();

			//	Margin

			cyHeight += ITEM_TEXT_MARGIN_BOTTOM;
//.........这里部分代码省略.........
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:CGItemListArea.cpp

示例2: PaintItem

void CGItemListArea::PaintItem (CG16bitImage &Dest, const CItem &Item, const RECT &rcRect, bool bSelected)

//	PaintItem
//
//	Paints the item

	{
	//	Item context

	CItemCtx Ctx(&Item, m_pListData->GetSource());
	CItemType *pItemType = Item.GetType();

	//	Paint the image

	DrawItemTypeIcon(Dest, rcRect.left, rcRect.top, pItemType);

	RECT rcDrawRect = rcRect;
	rcDrawRect.left += ICON_WIDTH + ITEM_TEXT_MARGIN_X;
	rcDrawRect.right -= ITEM_TEXT_MARGIN_X;
	rcDrawRect.top += ITEM_TEXT_MARGIN_Y;

	//	Paint the attribute blocks

	RECT rcAttrib;
	rcAttrib = rcDrawRect;
	rcAttrib.bottom = rcAttrib.top + m_pFonts->MediumHeavyBold.GetHeight();

	if (Item.IsDamaged())
		PaintItemModifier(Dest,
				CONSTLIT("Damaged"),
				RGB_ILLEGAL_BACKGROUND,
				&rcAttrib);
	else if (Item.IsDisrupted())
		PaintItemModifier(Dest,
				CONSTLIT("Ionized"),
				RGB_ILLEGAL_BACKGROUND,
				&rcAttrib);

	if (pItemType->IsKnown()
			&& pItemType->HasAttribute(CONSTLIT("Military")))
		PaintItemModifier(Dest, 
				CONSTLIT("Military"),
				RGB_MILITARY_BACKGROUND,
				&rcAttrib);

	if (pItemType->IsKnown()
			&& pItemType->HasAttribute(CONSTLIT("Illegal")))
		PaintItemModifier(Dest, 
				CONSTLIT("Illegal"),
				RGB_ILLEGAL_BACKGROUND,
				&rcAttrib);

	CString sEnhanced = Item.GetEnhancedDesc(m_pListData->GetSource());
	if (!sEnhanced.IsBlank())
		{
		bool bDisadvantage = (*(sEnhanced.GetASCIIZPointer()) == '-');
		PaintItemModifier(Dest,
				sEnhanced,
				(bDisadvantage ? RGB_ILLEGAL_BACKGROUND : RGB_MILITARY_BACKGROUND),
				&rcAttrib);
		}

	//	Paint the item name

	int cyHeight;
	RECT rcTitle = rcDrawRect;
	rcTitle.right = rcAttrib.right;
	m_pFonts->LargeBold.DrawText(Dest,
			rcTitle,
			m_pFonts->wItemTitle,
			Item.GetNounPhrase(nounCount | nounNoModifiers),
			0,
			CG16bitFont::SmartQuotes | CG16bitFont::TruncateLine,
			&cyHeight);

	rcDrawRect.top += cyHeight;

	//	Stats

	CString sStat;

	int iLevel = pItemType->GetApparentLevel();
	CString sReference = pItemType->GetReference(Ctx);
	DamageTypes iDamageType;
	CString sDamageRef;
	int iDamageAdj[damageCount];
	int iHP;

	if (Item.GetReferenceDamageType(m_pListData->GetSource(), -1, 0, &iDamageType, &sDamageRef))
		{
		//	Paint the initial text

		sStat = strPatternSubst("Level %s —", strLevel(iLevel));
		int cxWidth = m_pFonts->Medium.MeasureText(sStat, &cyHeight);
		m_pFonts->Medium.DrawText(Dest, 
				rcDrawRect,
				m_pFonts->wItemRef,
				sStat,
				0,
				0,
//.........这里部分代码省略.........
开发者ID:Sdw195,项目名称:Transcendence,代码行数:101,代码来源:CGItemListArea.cpp


注:本文中的CItemType::GetApparentLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。